From f66eaad00dbfe27e8dbe28019d1148a70f6ba0d9 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Mon, 3 Feb 2025 12:44:38 -0500
Subject: fixed defaults for roll animations effect.  fixed hideBefore pres
 effect to not show Doc before effect starts

---
 src/client/views/nodes/trails/PresBox.tsx | 43 ++++++++++++++-----------------
 1 file changed, 20 insertions(+), 23 deletions(-)

(limited to 'src/client/views/nodes/trails/PresBox.tsx')

diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx
index f23b32a48..7ca0bbc8f 100644
--- a/src/client/views/nodes/trails/PresBox.tsx
+++ b/src/client/views/nodes/trails/PresBox.tsx
@@ -1,7 +1,8 @@
+import { Button, Dropdown, DropdownType, IconButton, Toggle, ToggleType, Type } from '@dash/components';
 import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
 import { Tooltip } from '@mui/material';
 import Slider from '@mui/material/Slider';
-import { Button, Dropdown, DropdownType, IconButton, Toggle, ToggleType, Type } from '@dash/components';
+import _ from 'lodash';
 import { IReactionDisposer, ObservableSet, action, computed, makeObservable, observable, reaction, runInAction } from 'mobx';
 import { observer } from 'mobx-react';
 import * as React from 'react';
@@ -40,7 +41,7 @@ import { CollectionFreeFormPannableContents } from '../../collections/collection
 import { Colors } from '../../global/globalEnums';
 import { DocumentView } from '../DocumentView';
 import { FieldView, FieldViewProps } from '../FieldView';
-import { FocusViewOptions } from '../FocusViewOptions';
+import { FocusEffectDelay, FocusViewOptions } from '../FocusViewOptions';
 import { OpenWhere, OpenWhereMod } from '../OpenWhere';
 import { ScriptingBox } from '../ScriptingBox';
 import CubicBezierEditor, { EaseFuncToPoints, TIMING_DEFAULT_MAPPINGS } from './CubicBezierEditor';
@@ -48,7 +49,6 @@ import './PresBox.scss';
 import { PresEffect, PresEffectDirection, PresMovement, PresStatus } from './PresEnums';
 import SlideEffect from './SlideEffect';
 import { AnimationSettings, SpringSettings, SpringType, easeItems, effectItems, effectTimings, movementItems, presEffectDefaultTimings, springMappings, springPreviewColors } from './SpringUtils';
-import _ from 'lodash';
 
 @observer
 export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@@ -547,8 +547,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
             if (!group) this.clearSelectedArray();
             this.childDocs[index] && this.addToSelectedArray(this.childDocs[index]); // Update selected array
             this.turnOffEdit();
-            this.navigateToActiveItem(finished); // Handles movement to element only when presentationTrail is list
-            this.doHideBeforeAfter(); // Handles hide after/before
+            this.navigateToActiveItem((options: FocusViewOptions) => {
+                setTimeout(this.doHideBeforeAfter, FocusEffectDelay(options)); // Handles hide after/before
+                finished?.();
+            }); // Handles movement to element only when presentationTrail is list
         }
     });
     static pinDataTypes(target?: Doc): dataTypes {
@@ -784,11 +786,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
                 });
             setTimeout(
                 () =>
-                    Array.from(transitioned).forEach(
-                        action(doc => {
-                            doc._dataTransition = undefined;
-                        })
-                    ),
+                    Array.from(transitioned).forEach(doc => {
+                        doc._dataTransition = undefined;
+                    }),
                 transTime + 10
             );
         }
@@ -826,16 +826,16 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
      * a new tab. If presCollection is undefined it will open the document
      * on the right.
      */
-    navigateToActiveItem = (afterNav?: () => void) => {
+    navigateToActiveItem = (afterNav?: (options: FocusViewOptions) => void) => {
         const { activeItem, targetDoc } = this;
-        const finished = () => {
-            afterNav?.();
+        const finished = (options: FocusViewOptions) => {
+            afterNav?.(options);
             targetDoc[Animation] = undefined;
         };
         const selViewCache = Array.from(this.selectedArray);
         const dragViewCache = Array.from(this._dragArray);
         const eleViewCache = Array.from(this._eleArray);
-        const resetSelection = action(() => {
+        const resetSelection = action((options: FocusViewOptions) => {
             if (!this._props.isSelected()) {
                 const presDocView = DocumentView.getDocumentView(this.Document);
                 if (presDocView) DocumentView.SelectView(presDocView, false);
@@ -844,14 +844,14 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
                 this._dragArray.splice(0, this._dragArray.length, ...dragViewCache);
                 this._eleArray.splice(0, this._eleArray.length, ...eleViewCache);
             }
-            finished();
+            finished(options);
         });
         PresBox.NavigateToTarget(targetDoc, activeItem, resetSelection);
     };
 
     public static PanelName = 'PRESBOX';
 
-    static NavigateToTarget(targetDoc: Doc, activeItem: Doc, finished?: () => void) {
+    static NavigateToTarget(targetDoc: Doc, activeItem: Doc, finished?: (options: FocusViewOptions) => void) {
         if (activeItem.presentation_movement === PresMovement.None && targetDoc.type === DocumentType.SCRIPTING) {
             (DocumentView.getFirstDocumentView(targetDoc)?.ComponentView as ScriptingBox)?.onRun?.();
             return;
@@ -886,9 +886,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
                 if (!DocumentView.getLightboxDocumentView(DocCast(targetDoc.annotationOn) ?? targetDoc)) {
                     DocumentView.SetLightboxDoc(undefined);
                 }
-                DocumentView.showDocument(targetDoc, options, finished);
+                DocumentView.showDocument(targetDoc, options, () => finished?.(options));
             });
-        } else finished?.();
+        } else finished?.(options);
     }
 
     /**
@@ -900,8 +900,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
         this.childDocs.forEach((doc, index) => {
             const curDoc = Cast(doc, Doc, null);
             const tagDoc = PresBox.targetRenderedDoc(curDoc);
-            const itemIndexes: number[] = this.getAllIndexes(this.tagDocs, curDoc);
-            let opacity: Opt<number> = index === this.itemIndex ? 1 : undefined;
+            const itemIndexes = this.getAllIndexes(this.tagDocs, curDoc);
+            let opacity = index === this.itemIndex ? 1 : undefined;
             if (curDoc.presentation_hide) {
                 if (index !== this.itemIndex) {
                     opacity = 1;
@@ -913,9 +913,6 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
                     opacity = 0;
                 } else if (index === this.itemIndex || !curDoc.presentation_hideAfter) {
                     opacity = 1;
-                    setTimeout(() => {
-                        tagDoc._dataTransition = undefined;
-                    }, 1000);
                 }
             }
             const hidingIndAft =
-- 
cgit v1.2.3-70-g09d2

