aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionFreeForm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections/collectionFreeForm')
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx84
1 files changed, 26 insertions, 58 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 7d3c0569d..ba8dcff98 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -65,12 +65,6 @@ export interface ViewDefResult {
export namespace PivotView {
- // export let scripts: { arrangeInit: string, arrangeScript: string };
-
- // export async function loadLayouts() {
- // scripts = JSON.parse(await (await fetch(Utils.prepend("/layoutscripts"))).text());
- // }
-
export interface PivotData {
type: string;
text: string;
@@ -493,12 +487,11 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
@action
onPointerWheel = (e: React.WheelEvent): void => {
if (BoolCast(this.props.Document.lockedPosition)) return;
- // if (!this.props.active()) {
- // return;
- // }
- if (this.props.Document.type === "pdf") {
+ if (!e.ctrlKey && this.props.Document.scrollHeight !== undefined) { // things that can scroll vertically should do that instead of zooming
+ e.stopPropagation();
return;
}
+
let childSelected = this.childDocs.some(doc => {
var dv = DocumentManager.Instance.getDocumentView(doc);
return dv && SelectionManager.IsSelected(dv) ? true : false;
@@ -507,21 +500,20 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
return;
}
e.stopPropagation();
- const coefficient = 1000;
-
- if (e.ctrlKey) {
- let deltaScale = (1 - (e.deltaY / coefficient));
- let nw = this.nativeWidth * deltaScale;
- let nh = this.nativeHeight * deltaScale;
- if (nw && nh) {
- this.props.Document.nativeWidth = nw;
- this.props.Document.nativeHeight = nh;
- }
- e.stopPropagation();
- e.preventDefault();
- } else {
- // if (modes[e.deltaMode] === 'pixels') coefficient = 50;
- // else if (modes[e.deltaMode] === 'lines') coefficient = 1000; // This should correspond to line-height??
+
+ // bcz: this changes the nativewidth/height, but ImageBox will just revert it back to its defaults. need more logic to fix.
+ // if (e.ctrlKey && this.props.Document.scrollHeight === undefined) {
+ // let deltaScale = (1 - (e.deltaY / coefficient));
+ // let nw = this.nativeWidth * deltaScale;
+ // let nh = this.nativeHeight * deltaScale;
+ // if (nw && nh) {
+ // this.props.Document.nativeWidth = nw;
+ // this.props.Document.nativeHeight = nh;
+ // }
+ // e.preventDefault();
+ // }
+ // else
+ {
let deltaScale = e.deltaY > 0 ? (1 / 1.1) : 1.1;
if (deltaScale * this.zoomScaling() < 1 && this.isAnnotationOverlay) {
deltaScale = 1 / this.zoomScaling();
@@ -533,21 +525,19 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
let safeScale = Math.min(Math.max(0.15, localTransform.Scale), 40);
this.props.Document.scale = Math.abs(safeScale);
this.setPan(-localTransform.TranslateX / safeScale, -localTransform.TranslateY / safeScale);
- e.stopPropagation();
+ e.preventDefault();
}
}
@action
setPan(panX: number, panY: number) {
- if (BoolCast(this.props.Document.lockedPosition)) return;
- this.props.Document.panTransformType = "None";
- var scale = this.getLocalTransform().inverse().Scale;
- const newPanX = Math.min((1 - 1 / scale) * this.nativeWidth, Math.max(0, panX));
- const newPanY = Math.min((1 - 1 / scale) * this.nativeHeight, Math.max(0, panY));
- this.props.Document.panX = this.isAnnotationOverlay ? newPanX : panX;
- this.props.Document.panY = this.isAnnotationOverlay && StrCast(this.props.Document.backgroundLayout).indexOf("PDFBox") === -1 ? newPanY : panY;
- if (this.props.Document.scrollY) {
- this.props.Document.scrollY = panY - scale * this.props.Document[HeightSym]();
+ if (!BoolCast(this.props.Document.lockedPosition)) {
+ this.props.Document.panTransformType = "None";
+ var scale = this.getLocalTransform().inverse().Scale;
+ const newPanX = Math.min((1 - 1 / scale) * this.nativeWidth, Math.max(0, panX));
+ const newPanY = Math.min((this.props.Document.scrollHeight !== undefined ? NumCast(this.props.Document.scrollHeight) : (1 - 1 / scale) * this.nativeHeight), Math.max(0, panY));
+ this.props.Document.panX = this.isAnnotationOverlay ? newPanX : panX;
+ this.props.Document.panY = this.isAnnotationOverlay ? newPanY : panY;
}
}
@@ -631,12 +621,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
this.Document.scale = scale;
}
- getScale = () => {
- if (this.Document.scale) {
- return this.Document.scale;
- }
- return 1;
- }
+ getScale = () => this.Document.scale ? this.Document.scale : 1;
getChildDocumentViewProps(childDocLayout: Doc): DocumentViewProps {
let pair = Doc.GetLayoutDataDocPair(this.props.Document, this.props.DataDoc, this.props.fieldKey, childDocLayout);
@@ -935,23 +920,6 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
};
}
- // public static SetPivotLayout = (target: Doc) => {
- // let setSpecifiedLayoutField = (originalText: string, key: string, params: Record<string, string>, requiredType?: string) => {
- // const script = CompileScript(originalText, {
- // params,
- // requiredType,
- // typecheck: false
- // });
- // if (!script.compiled) {
- // console.log(script.errors.map(error => error.messageText).join("\n"));
- // return;
- // }
- // target[key] = new ScriptField(script);
- // };
- // setSpecifiedLayoutField(PivotView.scripts.arrangeInit, "arrangeInit", { collection: "Doc", docs: "Doc[]" }, undefined);
- // setSpecifiedLayoutField(PivotView.scripts.arrangeScript, "arrangeScript", { doc: "Doc", index: "number", collection: "Doc", state: "any", docs: "Doc[]" }, "{x: number, y: number, width?: number, height?: number}");
- // }
-
render() {
const easing = () => this.props.Document.panTransformType === "Ease";
Doc.UpdateDocumentExtensionForField(this.props.DataDoc ? this.props.DataDoc : this.props.Document, this.props.fieldKey);