From 3bcbf32d54af121a84e86c6bd1c99575bfc99859 Mon Sep 17 00:00:00 2001 From: Sophie Zhang Date: Thu, 7 Mar 2024 00:55:02 -0500 Subject: feat: added dropdown for ease function --- src/client/util/DocumentManager.ts | 6 +++ .../CollectionFreeFormPannableContents.tsx | 2 + .../collectionFreeForm/CollectionFreeFormView.tsx | 18 +++++++- src/client/views/nodes/trails/PresBox.tsx | 49 +++++++++++++++++++++- 4 files changed, 72 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index a38a330da..b0352f6e0 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -276,10 +276,13 @@ export class DocumentManager { docContextPath.shift(); const childViewIterator = async (docView: DocumentView) => { const innerDoc = docContextPath.shift(); + + // point of interest? return { focused: false, viewSpec: innerDoc, childDocView: innerDoc && !innerDoc.layout_unrendered ? (await docView.ComponentView?.getView?.(innerDoc, options)) ?? this.getDocumentView(innerDoc) : undefined }; }; if (rootContextView) { + // try commenting out const target = await this.focusViewsInPath(rootContextView, options, childViewIterator); this.restoreDocView(target.viewSpec, target.docView, options, target.contextView ?? target.docView, targetDoc); finished?.(target.focused); @@ -293,7 +296,9 @@ export class DocumentManager { ) => { let contextView: DocumentView | undefined; // view containing context that contains target let focused = false; + let count = 0; while (true) { + console.log('Count: ', count); if (docView.Document.layout_fieldKey === 'layout_icon') { await new Promise(res => docView.iconify(res)); options.didMove = true; @@ -304,6 +309,7 @@ export class DocumentManager { if (!childDocView) return { viewSpec: options.anchorDoc ?? viewSpec ?? docView.Document, docView, contextView, focused }; contextView = options.anchorDoc?.layout_unrendered && !childDocView.Document.layout_unrendered ? childDocView : docView; docView = childDocView; + count += 1; } }; diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormPannableContents.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormPannableContents.tsx index 69cbae86f..a140dd4b1 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormPannableContents.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormPannableContents.tsx @@ -40,6 +40,8 @@ export class CollectionFreeFormPannableContents extends React.Component { + this._presEaseFunc = easeFunc; + }; + public get isAnnotationOverlay() { return this._props.isAnnotationOverlay; } @@ -312,6 +319,12 @@ export class CollectionFreeFormView extends CollectionSubView { + // incorporate the easefunc here + if (options.easeFunc) { + this.setPresEaseFunc(options.easeFunc); + console.log('Ease func', options.easeFunc); + } + if (this._lightboxDoc) return; if (anchor === this.Document) { // if (options.willZoomCentered && options.zoomScale) { @@ -319,6 +332,7 @@ export class CollectionFreeFormView extends CollectionSubView (this.layoutDoc.layout_scrollTop = relTop * maxScrollTop), 10); newPanY = minPanY; } + // updating pan state !this.Document._verticalScroll && (this.Document[this.panXFieldKey] = this.isAnnotationOverlay ? newPanX : panX); !this.Document._horizontalScroll && (this.Document[this.panYFieldKey] = this.isAnnotationOverlay ? newPanY : panY); } @@ -1870,7 +1885,8 @@ export class CollectionFreeFormView extends CollectionSubView {this.props.children ?? null} {/* most likely case of children is document content that's being annoated: eg., an image */} {this.contentViews} diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx index 7d78d4648..cd3114940 100644 --- a/src/client/views/nodes/trails/PresBox.tsx +++ b/src/client/views/nodes/trails/PresBox.tsx @@ -38,7 +38,7 @@ import './PresBox.scss'; import ReactLoading from 'react-loading'; import { PresEffect, PresEffectDirection, PresMovement, PresStatus } from './PresEnums'; import ReactTextareaAutosize from 'react-textarea-autosize'; -import { Button, Dropdown, IconButton, Type } from 'browndash-components'; +import { Button, Dropdown, DropdownType, IconButton, Type } from 'browndash-components'; import { BiMicrophone, BiX } from 'react-icons/bi'; import { AiOutlineSend } from 'react-icons/ai'; import { gptSlideProperties, gptTrailSlideCustomization } from '../../../apis/gpt/customization'; @@ -70,6 +70,29 @@ export interface PinProps { pinData?: pinDataTypes; } +const easeItems = [ + { + text: 'Ease', + val: 'ease', + }, + { + text: 'Ease In', + val: 'ease-in', + }, + { + text: 'Ease Out', + val: 'ease-out', + }, + { + text: 'Ease In Out', + val: 'ease-in-out', + }, + { + text: 'Linear', + val: 'linear', + }, +]; + @observer export class PresBox extends ViewBoxBaseComponent() { public static LayoutString(fieldKey: string) { @@ -397,6 +420,7 @@ export class PresBox extends ViewBoxBaseComponent() { // Called when the user activates 'next' - to move to the next part of the pres. trail @action next = () => { + console.log('next slide'); const progressiveReveal = (first: boolean) => { const presIndexed = Cast(this.activeItem?.presentation_indexed, 'number', null); if (presIndexed !== undefined) { @@ -854,7 +878,6 @@ export class PresBox extends ViewBoxBaseComponent() { */ navigateToActiveItem = (afterNav?: () => void) => { const activeItem: Doc = this.activeItem; - console.log('active item', activeItem); const targetDoc: Doc = this.targetDoc; const finished = () => { @@ -887,6 +910,7 @@ export class PresBox extends ViewBoxBaseComponent() { return; } const effect = activeItem.presentation_effect && activeItem.presentation_effect !== PresEffect.None ? activeItem.presentation_effect : undefined; + // default with effect: 750ms else 500ms const presTime = NumCast(activeItem.presentation_transition, effect ? 750 : 500); const options: FocusViewOptions = { willPan: activeItem.presentation_movement !== PresMovement.None, @@ -1581,6 +1605,12 @@ export class PresBox extends ViewBoxBaseComponent() { this.selectedArray.forEach(doc => (doc.presEaseFunc = activeItem.presEaseFunc)); }; + @undoBatch + setEaseFunc = (activeItem: Doc, easeFunc: string) => { + activeItem.presEaseFunc = easeFunc; + this.selectedArray.forEach(doc => (doc.presEaseFunc = activeItem.presEaseFunc)); + }; + @undoBatch updateEffectDirection = (effect: PresEffectDirection, all?: boolean) => (all ? this.childDocs : this.selectedArray).forEach(doc => (doc.presentation_effectDirection = effect)); @@ -1990,6 +2020,21 @@ export class PresBox extends ViewBoxBaseComponent() {
Medium
Slow
+ {/* Easing function */} + { + if (typeof val === 'string') this.setEaseFunc(this.activeItem, val); + }} + dropdownType={DropdownType.SELECT} + type={Type.TERT} + fillWidth + /> + {/* Custom */}
Effects -- cgit v1.2.3-70-g09d2