aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/linking
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2022-11-16 23:27:05 -0500
committerbobzel <zzzman@gmail.com>2022-11-16 23:27:05 -0500
commit56116231c4c0aa78d54a9ed4c1f167514596953c (patch)
tree4fc3e22d7ebdc998403f80f405518b345425d2e9 /src/client/views/linking
parentae324ff50865929be836edf3bbf129207638a9c9 (diff)
added presEffects to link anchors
Diffstat (limited to 'src/client/views/linking')
-rw-r--r--src/client/views/linking/LinkEditor.tsx74
1 files changed, 72 insertions, 2 deletions
diff --git a/src/client/views/linking/LinkEditor.tsx b/src/client/views/linking/LinkEditor.tsx
index 3e8867c50..d90a91ab7 100644
--- a/src/client/views/linking/LinkEditor.tsx
+++ b/src/client/views/linking/LinkEditor.tsx
@@ -3,13 +3,14 @@ import { Tooltip } from '@material-ui/core';
import { action, computed, observable } from 'mobx';
import { observer } from 'mobx-react';
import { Doc, NumListCast, StrListCast, Field } from '../../../fields/Doc';
-import { DateCast, StrCast, Cast, BoolCast } from '../../../fields/Types';
+import { DateCast, StrCast, Cast, BoolCast, DocCast, NumCast } from '../../../fields/Types';
import { LinkManager } from '../../util/LinkManager';
import { undoBatch } from '../../util/UndoManager';
import './LinkEditor.scss';
import { LinkRelationshipSearch } from './LinkRelationshipSearch';
import React = require('react');
import { emptyFunction, returnFalse, setupMoveUpEvents } from '../../../Utils';
+import { PresBox, PresEffect } from '../nodes/trails';
interface LinkEditorProps {
sourceDoc: Doc;
@@ -24,6 +25,7 @@ export class LinkEditor extends React.Component<LinkEditorProps> {
@observable zoomFollow = BoolCast(this.props.sourceDoc.followLinkZoom);
@observable audioFollow = BoolCast(this.props.sourceDoc.followLinkAudio);
@observable openDropdown: boolean = false;
+ @observable openEffectDropdown: boolean = false;
@observable private buttonColor: string = '';
@observable private relationshipButtonColor: string = '';
@observable private relationshipSearchVisibility: string = 'none';
@@ -295,6 +297,61 @@ export class LinkEditor extends React.Component<LinkEditorProps> {
);
}
+ @computed get sourceAnchor() {
+ const ldoc = this.props.linkDoc;
+ if (this.props.sourceDoc !== ldoc.anchor1 && this.props.sourceDoc !== ldoc.anchor2) {
+ if (Doc.AreProtosEqual(DocCast(DocCast(ldoc.anchor1).annotationOn), this.props.sourceDoc)) return DocCast(ldoc.anchor1);
+ if (Doc.AreProtosEqual(DocCast(DocCast(ldoc.anchor2).annotationOn), this.props.sourceDoc)) return DocCast(ldoc.anchor2);
+ }
+ return this.props.sourceDoc;
+ }
+ @action
+ changeEffectDropdown = () => {
+ this.openEffectDropdown = !this.openEffectDropdown;
+ };
+
+ @undoBatch
+ changeEffect = action((follow: string) => {
+ this.openEffectDropdown = false;
+ this.sourceAnchor.presEffect = follow;
+ });
+
+ @computed
+ get effectDropdown() {
+ return (
+ <div className="linkEditor-followingDropdown">
+ <div className="linkEditor-followingDropdown-label">Transition Effect:</div>
+ <div className="linkEditor-followingDropdown-dropdown">
+ <div className="linkEditor-followingDropdown-header" onPointerDown={this.changeEffectDropdown}>
+ {StrCast(this.sourceAnchor.presEffect, 'default')}
+ <FontAwesomeIcon className="linkEditor-followingDropdown-icon" icon={this.openEffectDropdown ? 'chevron-up' : 'chevron-down'} size={'lg'} />
+ </div>
+ <div className="linkEditor-followingDropdown-optionsList" style={{ display: this.openEffectDropdown ? '' : 'none' }}>
+ {[
+ PresEffect.None,
+ PresEffect.Zoom,
+ PresEffect.Lightspeed,
+ PresEffect.Fade,
+ PresEffect.Flip,
+ PresEffect.Rotate,
+ PresEffect.Bounce,
+ PresEffect.Roll,
+ PresEffect.Left,
+ PresEffect.Right,
+ PresEffect.Center,
+ PresEffect.Top,
+ PresEffect.Bottom,
+ ].map(effect => (
+ <div className="linkEditor-followingDropdown-option" onPointerDown={() => this.changeEffect(effect.toString())}>
+ {effect.toString()}
+ </div>
+ ))}
+ </div>
+ </div>
+ </div>
+ );
+ }
+
autoMove = (e: React.PointerEvent) => {
setupMoveUpEvents(this, e, returnFalse, emptyFunction, undoBatch(action(() => (this.props.linkDoc.linkAutoMove = !this.props.linkDoc.linkAutoMove))));
};
@@ -348,7 +405,6 @@ export class LinkEditor extends React.Component<LinkEditorProps> {
</>
) : null}
</div>
-
{this.editDescription}
{this.editRelationship}
{this.editZoomFollow}
@@ -390,6 +446,20 @@ export class LinkEditor extends React.Component<LinkEditorProps> {
</Tooltip>
</div>
{this.followingDropdown}
+ {this.effectDropdown}
+ {PresBox.inputter('0.1', '0.1', '10', NumCast(this.sourceAnchor.presTransition) / 1000, true, (val: string) => PresBox.SetTransitionTime(val, (timeInMS: number) => (this.sourceAnchor.presTransition = timeInMS)))}
+ <div
+ className={'slider-headers'}
+ style={{
+ display: 'grid',
+ justifyContent: 'space-between',
+ width: '100%',
+ gridTemplateColumns: 'auto auto auto',
+ }}>
+ <div className="slider-text">Fast</div>
+ <div className="slider-text">Medium</div>
+ <div className="slider-text">Slow</div>
+ </div>{' '}
</div>
);
}