aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
diff options
context:
space:
mode:
authormadelinegr <mgriswold99@gmail.com>2019-06-14 18:24:01 -0400
committermadelinegr <mgriswold99@gmail.com>2019-06-14 18:24:01 -0400
commit218c8b6476621ef0ffe151014f77bb1d506705a3 (patch)
tree32685d7033cfed5cb9c539e327f8ec964482c680 /src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
parent19d5016acc3ff058a9665babb202e945c1fac766 (diff)
Zooming added to presentation, and done
Diffstat (limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx')
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 5d26cb0c2..419d95b5f 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -244,7 +244,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
doc.zIndex = docs.length + 1;
}
- focusDocument = (doc: Doc) => {
+ focusDocument = (doc: Doc, willZoom: boolean) => {
const panX = this.Document.panX;
const panY = this.Document.panY;
const id = this.Document[Id];
@@ -271,9 +271,12 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
newState.initializers[id] = { panX: newPanX, panY: newPanY };
HistoryUtil.pushState(newState);
this.setPan(newPanX, newPanY);
+
this.props.Document.panTransformType = "Ease";
this.props.focus(this.props.Document);
- //this.setScaleToZoom(doc);
+ if (willZoom) {
+ this.setScaleToZoom(doc);
+ }
}
@@ -281,21 +284,29 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
let p = this.props;
let PanelHeight = p.PanelHeight();
let panelWidth = p.PanelWidth();
- // let heightDif: number = PanelHeight - NumCast(doc.height);
- // let widthDif: number = panelWidth - NumCast(doc.width);
+
let docHeight = NumCast(doc.height);
let docWidth = NumCast(doc.width);
- let targetHeight = 0.8 * PanelHeight;
- let targetWidth = 0.8 * panelWidth;
+ let targetHeight = 0.5 * PanelHeight;
+ let targetWidth = 0.5 * panelWidth;
let maxScaleX: number = targetWidth / docWidth;
let maxScaleY: number = targetHeight / docHeight;
- // let maxScaleX: number = NumCast(doc.width) / (panelWidth - 10);
- // let maxScaleY: number = NumCast(doc.height) / (PanelHeight - 10);
let maxApplicableScale = Math.min(maxScaleX, maxScaleY);
this.Document.scale = maxApplicableScale;
}
+ zoomToScale = (scale: number) => {
+ this.Document.scale = scale;
+ }
+
+ getScale = () => {
+ if (this.Document.scale) {
+ return this.Document.scale;
+ }
+ return 1;
+ }
+
getDocumentViewProps(document: Doc): DocumentViewProps {
return {
@@ -315,6 +326,8 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
whenActiveChanged: this.props.whenActiveChanged,
bringToFront: this.bringToFront,
addDocTab: this.props.addDocTab,
+ zoomToScale: this.zoomToScale,
+ getScale: this.getScale
};
}
@@ -346,7 +359,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
private childViews = () => [
<CollectionFreeFormBackgroundView key="backgroundView" {...this.props} {...this.getDocumentViewProps(this.props.Document)} />,
...this.views
- ];
+ ]
render() {
const containerName = `collectionfreeformview${this.isAnnotationOverlay ? "-overlay" : "-container"}`;
const easing = () => this.props.Document.panTransformType === "Ease";