diff options
| author | Monika Hedman <monika_hedman@brown.edu> | 2019-02-12 16:27:45 -0500 |
|---|---|---|
| committer | Monika Hedman <monika_hedman@brown.edu> | 2019-02-12 16:27:45 -0500 |
| commit | 39a61758f87f59366a3464b72fdf249a39a78955 (patch) | |
| tree | 3bdcb59110a7eedfef3215439e77a09c1eeee0b4 /src/client/views/collections | |
| parent | 05a710e2a541a07347d1626489a1811874126c79 (diff) | |
| parent | 6ef7d8f10b2ec78491b66ea4e2f6cebce3b0230a (diff) | |
Merge branch 'transforms' of https://github.com/browngraphicslab/Dash-Web into hedmanLocal
Diffstat (limited to 'src/client/views/collections')
| -rw-r--r-- | src/client/views/collections/CollectionFreeFormView.tsx | 16 | ||||
| -rw-r--r-- | src/client/views/collections/CollectionViewBase.tsx | 4 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx index 15450d737..975eaaae8 100644 --- a/src/client/views/collections/CollectionFreeFormView.tsx +++ b/src/client/views/collections/CollectionFreeFormView.tsx @@ -123,14 +123,17 @@ export class CollectionFreeFormView extends CollectionViewBase { let coefficient = 1000; // if (modes[e.deltaMode] == 'pixels') coefficient = 50; // else if (modes[e.deltaMode] == 'lines') coefficient = 1000; // This should correspond to line-height?? + let transform = this.getTransform(); + let localTransform = this.getLocalTransform(); - let { LocalX, Ss, Panxx, Xx, LocalY, Panyy, Yy, ContainerX, ContainerY } = this.props.ContainingDocumentView!.TransformToLocalPoint(e.pageX, e.pageY); + let deltaScale = (1 - (e.deltaY / coefficient)) * transform.Scale; + let newDeltaScale = this.isAnnotationOverlay ? Math.max(1, deltaScale) : deltaScale; + let [x, y] = transform.transformPoint(e.clientX, e.clientY); - var deltaScale = (1 - (e.deltaY / coefficient)) * Ss; - var newDeltaScale = this.isAnnotationOverlay ? Math.max(1, deltaScale) : deltaScale; + localTransform.scaleAbout(newDeltaScale, x, y); this.props.DocumentForCollection.SetNumber(KeyStore.Scale, newDeltaScale); - this.SetPan(ContainerX - (LocalX * newDeltaScale + Xx), ContainerY - (LocalY * newDeltaScale + Yy)); + this.SetPan(localTransform.TranslateX, localTransform.TranslateY); } @action @@ -213,6 +216,11 @@ export class CollectionFreeFormView extends CollectionViewBase { return this.props.GetTransform().scaled(this.scale).translate(x, y); } + getLocalTransform = (): Transform => { + const [x, y] = this.translate; + return new Transform(x, y, this.scale); + } + render() { const Document: Document = this.props.DocumentForCollection; const value: Document[] = Document.GetList<Document>(this.props.CollectionFieldKey, []); diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx index 7e2fcb39d..a41196027 100644 --- a/src/client/views/collections/CollectionViewBase.tsx +++ b/src/client/views/collections/CollectionViewBase.tsx @@ -28,7 +28,9 @@ export const COLLECTION_BORDER_WIDTH = 2; export class CollectionViewBase extends React.Component<CollectionViewProps> { public static LayoutString(collectionType: string, fieldKey: string = "DataKey") { - return `<${collectionType} Scaling={Scaling} DocumentForCollection={Document} CollectionFieldKey={${fieldKey}} ContainingDocumentView={DocumentView} BackgroundView={BackgroundView} />`; + return `<${collectionType} DocumentForCollection={Document} CollectionFieldKey={${fieldKey}} + GetTransform={GetTransform} + ContainingDocumentView={DocumentView}/>`; } @computed public get active(): boolean { |
