From 52a435b09013619209b8bcc6758baeca47d5d350 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 8 Dec 2022 10:08:33 -0500 Subject: cleaned up animation effects to not reference presBox. fixed anchors in text to have link properties set properly from properties view. --- src/client/views/nodes/trails/PresBox.tsx | 45 +++++++++---------------------- 1 file changed, 13 insertions(+), 32 deletions(-) (limited to 'src/client/views/nodes/trails') diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx index 2694cb350..e0f64e7aa 100644 --- a/src/client/views/nodes/trails/PresBox.tsx +++ b/src/client/views/nodes/trails/PresBox.tsx @@ -1,11 +1,10 @@ import React = require('react'); import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { Tooltip } from '@material-ui/core'; -import { action, computed, IReactionDisposer, observable, ObservableSet, reaction, runInAction } from 'mobx'; +import { action, computed, IReactionDisposer, observable, ObservableSet, observe, reaction, runInAction } from 'mobx'; import { observer } from 'mobx-react'; import { ColorState, SketchPicker } from 'react-color'; -import { Bounce, Fade, Flip, LightSpeed, Roll, Rotate, Zoom } from 'react-reveal'; -import { Doc, DocListCast, FieldResult, Opt, StrListCast } from '../../../../fields/Doc'; +import { AnimationSym, Doc, DocListCast, FieldResult, HighlightSym, Opt, StrListCast } from '../../../../fields/Doc'; import { Copy, Id } from '../../../../fields/FieldSymbols'; import { InkTool } from '../../../../fields/InkField'; import { List } from '../../../../fields/List'; @@ -64,36 +63,8 @@ export class PresBox extends ViewBoxBaseComponent() { return FieldView.LayoutString(PresBox, fieldKey); } - /** - * returns an entrance animation effect function to wrap a JSX element - * @param presEffectDoc presentation effects document that specifies the animation effect parameters - * @returns a function that will wrap a JSX animation element wrapping any JSX element - */ - public static AnimationEffect(renderDoc: JSX.Element, presEffectDoc: Opt, root: Doc) { - const effectProps = { - left: presEffectDoc?.presEffectDirection === PresEffectDirection.Left, - right: presEffectDoc?.presEffectDirection === PresEffectDirection.Right, - top: presEffectDoc?.presEffectDirection === PresEffectDirection.Top, - bottom: presEffectDoc?.presEffectDirection === PresEffectDirection.Bottom, - opposite: true, - delay: 0, - duration: Cast(presEffectDoc?.presTransition, 'number', null), - }; - //prettier-ignore - switch (StrCast(presEffectDoc?.presEffect)) { - default: - case PresEffect.None: return renderDoc; - case PresEffect.Zoom: return {renderDoc}; - case PresEffect.Fade: return {renderDoc}; - case PresEffect.Flip: return {renderDoc}; - case PresEffect.Rotate: return {renderDoc}; - case PresEffect.Bounce: return {renderDoc}; - case PresEffect.Roll: return {renderDoc}; - case PresEffect.Lightspeed: return {renderDoc}; - } - } - private _disposers: { [name: string]: IReactionDisposer } = {}; + private _obDisposers: { [name: string]: any } = {}; public selectedArray = new ObservableSet(); @observable public static Instance: PresBox; @@ -170,10 +141,20 @@ export class PresBox extends ViewBoxBaseComponent() { // Turn of progressivize editors this.turnOffEdit(true); Object.values(this._disposers).forEach(disposer => disposer?.()); + Object.values(this._obDisposers).forEach(disposer => disposer?.()); } @action componentDidMount() { + this._obDisposers.anim = observe( + this, + 'activeItem', + change => { + change.oldValue && (DocCast((change.oldValue as Doc).presentationTargetDoc)[AnimationSym] = undefined); + change.newValue && (DocCast((change.newValue as Doc).presentationTargetDoc)[AnimationSym] = change.newValue as Doc); + }, + true + ); this._disposers.keyboard = reaction( () => this.selectedDoc, selected => { -- cgit v1.2.3-70-g09d2