From 4a9d6d1409327fd99c5f554caebd917a316db32b Mon Sep 17 00:00:00 2001 From: bobzel Date: Fri, 12 Feb 2021 11:00:29 -0500 Subject: changed lightbox to navigate within frame if next target is alreay there, otherwise create it. changed focus default to call afterFocus(). fixed bug of zooming on target doc to compute scale correctly. --- src/client/views/LightboxView.tsx | 52 ++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 15 deletions(-) (limited to 'src/client/views/LightboxView.tsx') diff --git a/src/client/views/LightboxView.tsx b/src/client/views/LightboxView.tsx index 4e9491ec6..fbfc9672f 100644 --- a/src/client/views/LightboxView.tsx +++ b/src/client/views/LightboxView.tsx @@ -9,6 +9,8 @@ import { Transform } from '../util/Transform'; import "./LightboxView.scss"; import { DocumentView } from './nodes/DocumentView'; import { DefaultStyleProvider } from './StyleProvider'; +import { DocUtils } from '../documents/Documents'; +import { DocumentManager } from '../util/DocumentManager'; interface LightboxViewProps { PanelWidth: number; @@ -18,7 +20,16 @@ interface LightboxViewProps { @observer export class LightboxView extends React.Component { - @observable public static LightboxDoc: Opt; + @observable static LightboxDoc: Opt; + @action public static SetLightboxDoc(doc: Opt, future?: Doc[]) { + LightboxView.LightboxDoc = doc; + if (!doc) { + LightboxView.LightboxFuture = LightboxView.LightboxHistory = []; + } else if (future) { + LightboxView.LightboxFuture = future; + } + return true; + } public static IsLightboxDocView(path: DocumentView[]) { return path.includes(LightboxView.LightboxDocView.current!); } public static LightboxHistory: (Opt)[] = []; public static LightboxFuture: (Opt)[] = []; @@ -47,13 +58,11 @@ export class LightboxView extends React.Component { return !LightboxView.LightboxDoc ? (null) :
{ downx = e.clientX; downy = e.clientY; }} - onClick={action(e => { + onClick={e => { if (Math.abs(downx - e.clientX) < 4 && Math.abs(downy - e.clientY) < 4) { - LightboxView.LightboxHistory = []; - LightboxView.LightboxFuture = []; - LightboxView.LightboxDoc = undefined; + LightboxView.SetLightboxDoc(undefined); } - })} > + }} >
{ ScreenToLocalTransform={this.lightboxScreenToLocal} PanelWidth={this.lightboxWidth} PanelHeight={this.lightboxHeight} - focus={emptyFunction} + focus={DocUtils.DefaultFocus} parentActive={returnTrue} whenActiveChanged={emptyFunction} bringToFront={emptyFunction} @@ -87,18 +96,31 @@ export class LightboxView extends React.Component {
{this.navBtn(undefined, "chevron-left", () => LightboxView.LightboxDoc && LightboxView.LightboxHistory.length ? "" : "none", - action(e => { + e => { e.stopPropagation(); - const popped = LightboxView.LightboxHistory.pop(); - if (LightboxView.LightboxHistory.lastElement() !== LightboxView.LightboxFuture.lastElement()) LightboxView.LightboxFuture.push(popped); - LightboxView.LightboxDoc = LightboxView.LightboxHistory.lastElement(); - }))} + const previous = LightboxView.LightboxHistory.pop(); + const target = LightboxView.LightboxHistory.lastElement(); + const docView = target && DocumentManager.Instance.getLightboxDocumentView(target); + if (docView && target) { + if (LightboxView.LightboxFuture.lastElement() !== previous) LightboxView.LightboxFuture.push(previous); + docView.focus(target, true, 0.9); + } else { + LightboxView.SetLightboxDoc(target); + } + })} {this.navBtn(this.props.PanelWidth - Math.min(this.props.PanelWidth / 4, this.props.maxBorder[0]), "chevron-right", () => LightboxView.LightboxDoc && LightboxView.LightboxFuture.length ? "" : "none", - action(e => { + e => { e.stopPropagation(); - LightboxView.LightboxDoc = LightboxView.LightboxFuture.pop(); - }))} + const target = LightboxView.LightboxFuture.pop(); + const docView = target && DocumentManager.Instance.getLightboxDocumentView(target); + if (docView && target) { + docView.focus(target, true, 0.9); + if (LightboxView.LightboxHistory.lastElement() !== target) LightboxView.LightboxHistory.push(target); + } else { + LightboxView.SetLightboxDoc(target); + } + })}
; } -- cgit v1.2.3-70-g09d2