aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts4
-rw-r--r--src/client/views/.DS_Storebin6148 -> 6148 bytes
-rw-r--r--src/client/views/collections/CollectionCarousel3DView.scss52
-rw-r--r--src/client/views/collections/CollectionCarousel3DView.tsx182
-rw-r--r--src/client/views/collections/CollectionView.tsx4
-rw-r--r--src/client/views/collections/CollectionViewChromes.tsx1
6 files changed, 243 insertions, 0 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index f7e19eecd..8513da76c 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -693,6 +693,10 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { _chromeStatus: "collapsed", schemaColumns: new List([new SchemaHeaderField("title", "#f1efeb")]), ...options, _viewType: CollectionViewType.Carousel });
}
+ export function Carousel3DDocument(documents: Array<Doc>, options: DocumentOptions) {
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { _chromeStatus: "collapsed", schemaColumns: new List([new SchemaHeaderField("title", "#f1efeb")]), ...options, _viewType: CollectionViewType.Carousel3D });
+ }
+
export function SchemaDocument(schemaColumns: SchemaHeaderField[], documents: Array<Doc>, options: DocumentOptions) {
return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { _chromeStatus: "collapsed", schemaColumns: new List(schemaColumns), ...options, _viewType: CollectionViewType.Schema });
}
diff --git a/src/client/views/.DS_Store b/src/client/views/.DS_Store
index 5008ddfcf..3717a2923 100644
--- a/src/client/views/.DS_Store
+++ b/src/client/views/.DS_Store
Binary files differ
diff --git a/src/client/views/collections/CollectionCarousel3DView.scss b/src/client/views/collections/CollectionCarousel3DView.scss
new file mode 100644
index 000000000..d00a666f8
--- /dev/null
+++ b/src/client/views/collections/CollectionCarousel3DView.scss
@@ -0,0 +1,52 @@
+.collectionCarouselView-outer {
+ height: 100%;
+ position: relative;
+ background-color: white;
+}
+
+.carousel-wrapper {
+ display: flex;
+ position: absolute;
+ top: 15%;
+ align-items: center;
+ transition: transform 0.3s cubic-bezier(0.455, 0.03, 0.515, 0.955);
+
+ .collectionCarouselView-item,
+ .collectionCarouselView-item-active {
+ flex: 1;
+ transition: opacity 0.3s linear, transform 0.5s cubic-bezier(0.455, 0.03, 0.515, 0.955);
+ pointer-events: none;
+ }
+
+ .collectionCarouselView-item-active {
+ pointer-events: unset;
+ }
+}
+
+.dot-bar {
+ display: flex;
+ position: absolute;
+ justify-content: center;
+ bottom: 5%;
+ width: 100%;
+
+ .dot,
+ .dot-active {
+ height: 15px;
+ width: 15px;
+ border-radius: 50%;
+ margin: 3px;
+ display: inline-block;
+ background-color: lightgrey;
+ cursor: pointer;
+ }
+
+ .dot-active {
+ background-color: grey;
+ }
+}
+
+.carouselView-back,
+.carouselView-forward {
+ cursor: pointer;
+} \ No newline at end of file
diff --git a/src/client/views/collections/CollectionCarousel3DView.tsx b/src/client/views/collections/CollectionCarousel3DView.tsx
new file mode 100644
index 000000000..bad3096c8
--- /dev/null
+++ b/src/client/views/collections/CollectionCarousel3DView.tsx
@@ -0,0 +1,182 @@
+import { observable, computed } from 'mobx';
+import { observer } from 'mobx-react';
+import * as React from 'react';
+import { documentSchema, collectionSchema } from '../../../fields/documentSchemas';
+import { makeInterface } from '../../../fields/Schema';
+import { NumCast, StrCast, ScriptCast, Cast } from '../../../fields/Types';
+import { DragManager } from '../../util/DragManager';
+import { ContentFittingDocumentView } from '../nodes/ContentFittingDocumentView';
+import "./CollectionCarousel3DView.scss";
+import { CollectionSubView } from './CollectionSubView';
+import { Doc } from '../../../fields/Doc';
+import { ContextMenu } from '../ContextMenu';
+import { ObjectField } from '../../../fields/ObjectField';
+import { returnFalse, Utils } from '../../../Utils';
+import { ScriptField } from '../../../fields/ScriptField';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { Id } from '../../../fields/FieldSymbols';
+
+type Carousel3DDocument = makeInterface<[typeof documentSchema, typeof collectionSchema]>;
+const Carousel3DDocument = makeInterface(documentSchema, collectionSchema);
+
+@observer
+export class CollectionCarousel3DView extends CollectionSubView(Carousel3DDocument) {
+ private _dropDisposer?: DragManager.DragDropDisposer;
+
+ componentWillUnmount() { this._dropDisposer?.(); }
+
+ protected createDashEventsTarget = (ele: HTMLDivElement) => { //used for stacking and masonry view
+ this._dropDisposer?.();
+ if (ele) {
+ this._dropDisposer = DragManager.MakeDropTarget(ele, this.onInternalDrop.bind(this), this.layoutDoc);
+ }
+ }
+
+ panelWidth = () => this.props.PanelWidth() / 3;
+ panelHeight = () => this.props.PanelHeight() * 0.6;
+ @computed get content() {
+ const currentIndex = NumCast(this.layoutDoc._itemIndex);
+ const displayDoc = (childPair: { layout: Doc, data: Doc }) => {
+ return <ContentFittingDocumentView {...this.props}
+ onDoubleClick={ScriptCast(this.layoutDoc.onChildDoubleClick)}
+ onClick={ScriptField.MakeScript(
+ "child._showCaption = 'caption'",
+ { child: Doc.name },
+ { child: childPair.layout }
+ )}
+ renderDepth={this.props.renderDepth + 1}
+ LayoutTemplate={this.props.ChildLayoutTemplate}
+ LayoutTemplateString={this.props.ChildLayoutString}
+ Document={childPair.layout}
+ DataDoc={childPair.data}
+ PanelWidth={this.panelWidth}
+ PanelHeight={this.panelHeight}
+ ScreenToLocalTransform={this.props.ScreenToLocalTransform}
+ bringToFront={returnFalse}
+ parentActive={this.props.active}
+ />;
+ };
+
+ return (
+ this.childLayoutPairs.map((childPair, index) => {
+ return (
+ <div key={childPair.layout[Id]}
+ className={`collectionCarouselView-item${index === currentIndex ? "-active" : ""} ${index}`}
+ style={index === currentIndex ?
+ { opacity: '1', transform: 'scale(1.3)' } :
+ { opacity: '0.5', transform: 'scale(0.6)', userSelect: 'none' }}>
+ {displayDoc(childPair)}
+ </div>);
+ }));
+ }
+
+ changeSlide = (direction: number) => {
+ this.layoutDoc._itemIndex = (NumCast(this.layoutDoc._itemIndex) + direction + this.childLayoutPairs.length) % this.childLayoutPairs.length;
+ }
+
+ timer?: number;
+ interval?: number;
+ onArrowDown = (e: React.PointerEvent, direction: number) => {
+ e.stopPropagation;
+ document.removeEventListener("pointerup", () => this.onArrowRelease(direction));
+ document.addEventListener("pointerup", () => this.onArrowRelease(direction));
+
+ this.layoutDoc.startScrollTimeout = 1500;
+ this.timer = window.setTimeout(() => { // if arrow is held down long enough, activate automatic scrolling
+ window.clearTimeout(this.timer);
+ this.timer = undefined;
+ this.startScroll(direction);
+ }, this.layoutDoc.startScrollTimeout);
+ }
+
+ startScroll = (direction: number) => {
+ this.layoutDoc.scrollInterval = 500;
+ this.interval = window.setInterval(() => {
+ this.changeSlide(direction);
+ }, this.layoutDoc.scrollInterval);
+ }
+
+ onArrowRelease = (direction: number) => {
+ document.removeEventListener("pointerup", () => this.onArrowRelease(direction));
+
+ if (this.timer) {
+ this.changeSlide(direction); // if click wasn't long enough to activate autoscroll, only advance/go back 1 slide
+ window.clearTimeout(this.timer);
+ this.timer = undefined;
+ }
+
+ if (this.interval) {
+ window.clearInterval(this.interval); // stop scrolling
+ this.interval = undefined;
+ }
+ }
+
+ onContextMenu = (e: React.MouseEvent): void => {
+ // need to test if propagation has stopped because GoldenLayout forces a parallel react hierarchy to be created for its top-level layout
+ if (!e.isPropagationStopped()) {
+ ContextMenu.Instance.addItem({
+ description: "Make Hero Image", event: () => {
+ const index = NumCast(this.layoutDoc._itemIndex);
+ (this.dataDoc || Doc.GetProto(this.props.Document)).hero = ObjectField.MakeCopy(this.childLayoutPairs[index].layout.data as ObjectField);
+ }, icon: "plus"
+ });
+ }
+ }
+ _downX = 0;
+ _downY = 0;
+ onPointerDown = (e: React.PointerEvent) => {
+ this._downX = e.clientX;
+ this._downY = e.clientY;
+ console.log("CAROUSEL down");
+ document.addEventListener("pointerup", this.onpointerup);
+ }
+ private _lastTap: number = 0;
+ private _doubleTap = false;
+ onpointerup = (e: PointerEvent) => {
+ console.log("CAROUSEL up");
+ this._doubleTap = (Date.now() - this._lastTap < 300 && e.button === 0 && Math.abs(e.clientX - this._downX) < 2 && Math.abs(e.clientY - this._downY) < 2);
+ this._lastTap = Date.now();
+ }
+
+ onClick = (e: React.MouseEvent) => {
+ if (this._doubleTap) {
+ e.stopPropagation();
+ this.props.Document.isLightboxOpen = true;
+ }
+ }
+
+ @computed get buttons() {
+ return <>
+ <div key="back" className="carouselView-back" style={{ background: `${StrCast(this.props.Document.backgroundColor)}` }}
+ onPointerDown={(e) => this.onArrowDown(e, -1)}>
+ <FontAwesomeIcon icon={"caret-left"} size={"2x"} />
+ </div>
+ <div key="fwd" className="carouselView-fwd" style={{ background: `${StrCast(this.props.Document.backgroundColor)}` }}
+ onPointerDown={(e) => this.onArrowDown(e, 1)}>
+ <FontAwesomeIcon icon={"caret-right"} size={"2x"} />
+ </div>
+ </>;
+ }
+
+ @computed get dots() {
+ return (this.childLayoutPairs.map((_child, index) => {
+ return <div key={Utils.GenerateGuid()} className={`dot${index === NumCast(this.layoutDoc._itemIndex) ? "-active" : ""}`}
+ onClick={() => this.layoutDoc._itemIndex = index} />;
+ }));
+ }
+
+ render() {
+ const index = NumCast(this.layoutDoc._itemIndex);
+ const translateX = (1 - index) / this.childLayoutPairs.length * 100;
+
+ return <div className="collectionCarouselView-outer" onClick={this.onClick} onPointerDown={this.onPointerDown} ref={this.createDashEventsTarget} onContextMenu={this.onContextMenu}>
+ <div className="carousel-wrapper" style={{ transform: `translateX(calc(${translateX}%` }}>
+ {this.content}
+ </div>
+ {this.props.Document._chromeStatus !== "replaced" ? this.buttons : (null)}
+ <div className="dot-bar">
+ {this.dots}
+ </div>
+ </div>;
+ }
+} \ No newline at end of file
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index fecba32c5..a0f6ad9c7 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -21,6 +21,7 @@ import { FieldView, FieldViewProps } from '../nodes/FieldView';
import { ScriptBox } from '../ScriptBox';
import { Touchable } from '../Touchable';
import { CollectionCarouselView } from './CollectionCarouselView';
+import { CollectionCarousel3DView } from './CollectionCarousel3DView';
import { CollectionDockingView } from "./CollectionDockingView";
import { AddCustomFreeFormLayout } from './collectionFreeForm/CollectionFreeFormLayoutEngines';
import { CollectionFreeFormView } from './collectionFreeForm/CollectionFreeFormView';
@@ -63,6 +64,7 @@ export enum CollectionViewType {
Multirow = "multirow",
Time = "time",
Carousel = "carousel",
+ Carousel3D = "3D carousel",
Linear = "linear",
Staff = "staff",
Map = "map",
@@ -188,6 +190,7 @@ export class CollectionView extends Touchable<FieldViewProps & CollectionViewCus
case CollectionViewType.Linear: { return (<CollectionLinearView key="collview" {...props} />); }
case CollectionViewType.Pile: { return (<CollectionPileView key="collview" {...props} />); }
case CollectionViewType.Carousel: { return (<CollectionCarouselView key="collview" {...props} />); }
+ case CollectionViewType.Carousel3D: { return (<CollectionCarousel3DView key="collview" {...props} />); }
case CollectionViewType.Stacking: { this.props.Document.singleColumn = true; return (<CollectionStackingView key="collview" {...props} />); }
case CollectionViewType.Masonry: { this.props.Document.singleColumn = false; return (<CollectionStackingView key="collview" {...props} />); }
case CollectionViewType.Time: { return (<CollectionTimeView key="collview" {...props} />); }
@@ -227,6 +230,7 @@ export class CollectionView extends Touchable<FieldViewProps & CollectionViewCus
subItems.push({ description: "Multirow", event: () => func(CollectionViewType.Multirow), icon: "columns" });
subItems.push({ description: "Masonry", event: () => func(CollectionViewType.Masonry), icon: "columns" });
subItems.push({ description: "Carousel", event: () => func(CollectionViewType.Carousel), icon: "columns" });
+ subItems.push({ description: "3D Carousel", event: () => func(CollectionViewType.Carousel3D), icon: "columns" });
subItems.push({ description: "Pivot/Time", event: () => func(CollectionViewType.Time), icon: "columns" });
subItems.push({ description: "Map", event: () => func(CollectionViewType.Map), icon: "globe-americas" });
if (addExtras && this.props.Document._viewType === CollectionViewType.Freeform) {
diff --git a/src/client/views/collections/CollectionViewChromes.tsx b/src/client/views/collections/CollectionViewChromes.tsx
index 29a3e559a..199902923 100644
--- a/src/client/views/collections/CollectionViewChromes.tsx
+++ b/src/client/views/collections/CollectionViewChromes.tsx
@@ -76,6 +76,7 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
case CollectionViewType.Freeform: return this._freeform_commands;
case CollectionViewType.Time: return this._freeform_commands;
case CollectionViewType.Carousel: return this._freeform_commands;
+ case CollectionViewType.Carousel3D: return this._freeform_commands;
}
return [];
}