From 3b0c9a8a3282eb3c04123985a0512592fe0affae Mon Sep 17 00:00:00 2001 From: bob Date: Fri, 1 Feb 2019 11:33:59 -0500 Subject: added lightbox for images --- src/views/nodes/DocumentView.tsx | 3 +- src/views/nodes/ImageBox.scss | 11 ++++++ src/views/nodes/ImageBox.tsx | 82 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 src/views/nodes/ImageBox.scss create mode 100644 src/views/nodes/ImageBox.tsx (limited to 'src/views') diff --git a/src/views/nodes/DocumentView.tsx b/src/views/nodes/DocumentView.tsx index 634cd78be..34a95747b 100644 --- a/src/views/nodes/DocumentView.tsx +++ b/src/views/nodes/DocumentView.tsx @@ -15,6 +15,7 @@ import { CollectionDockingView } from "../collections/CollectionDockingView"; import { CollectionFreeFormView } from "../collections/CollectionFreeFormView"; import { ContextMenu } from "../ContextMenu"; import { FieldTextBox } from "../nodes/FieldTextBox"; +import { ImageBox } from "../nodes/ImageBox"; import "./NodeView.scss"; import React = require("react"); import { cpus } from "os"; @@ -82,7 +83,7 @@ class DocumentContents extends React.Component { } } return { + + public static LayoutString() { return ""; } + private _ref: React.RefObject; + private _wasSelected: boolean = false; + + constructor(props: DocumentFieldViewProps) { + super(props); + + this._ref = React.createRef(); + this.state = { + photoIndex: 0, + isOpen: false, + }; + } + + componentDidMount() { + } + + componentWillUnmount() { + } + + onPointerDown = (e: React.PointerEvent): void => { + const { containingDocumentView } = this.props; + this._wasSelected = SelectionManager.IsSelected(containingDocumentView); + let me = this; + if (e.buttons === 1 && SelectionManager.IsSelected(me.props.containingDocumentView)) { + e.stopPropagation(); + } + } + + render() { + const images = [this.props.doc.GetTextField(this.props.fieldKey, ""),]; + var lightbox = () => { + const { photoIndex } = this.state; + if (this.state.isOpen && SelectionManager.IsSelected(this.props.containingDocumentView)) { + return ( 0 ? images[(photoIndex + images.length - 1) % images.length] : undefined} + onCloseRequest={() => this.setState({ isOpen: false })} + onMovePrevRequest={() => + this.setState({ photoIndex: (photoIndex + images.length - 1) % images.length, }) + } + onMoveNextRequest={() => + this.setState({ photoIndex: (photoIndex + 1) % images.length, }) + } + />) + } + } + return ( +
+ + {lightbox()} +
) + } +} \ No newline at end of file -- cgit v1.2.3-70-g09d2