Skip to content

Commit

Permalink
demo: Fix scalable demo
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Aug 22, 2019
1 parent 0de44d8 commit 1ddc75d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions demo/src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ const scalable = new Moveable(document.body, {
scalable: true,
throttleScale: 0,
keepRatio: true,
}).on("scale", ({ target, dist }) => {
scale[0] *= dist[0];
scale[1] *= dist[1];
}).on("scale", ({ target, delta }) => {
scale[0] *= delta[0];
scale[1] *= delta[1];
target.style.transform = "scale(" + scale[0] + "," + scale[1] + ")";
});
`,
Expand All @@ -161,10 +161,10 @@ return (
scalable={true}
throttleScale={0}
keepRatio={true}
onScale={({ target, dist }) => {
onScale={({ target, delta }) => {
const scale = this.scale;
scale[0] *= dist[0];
scale[1] *= dist[1];
scale[0] *= delta[0];
scale[1] *= delta[1];
target.style.transform
= "scale(" + scale[0] + "," + scale[1] + ")";
}}
Expand Down Expand Up @@ -192,10 +192,10 @@ ${"`"},
})
export class AppComponent {
scale = [1, 1];
onScale({ target, dist }) {
onScale({ target, delta }) {
const scale = this.scale;
scale[0] *= dist[0];
scale[1] *= dist[1];
scale[0] *= delta[0];
scale[1] *= delta[1];
target.style.transform
= "scale(" + scale[0] + "," + scale[1] + ")";
}
Expand Down
6 changes: 3 additions & 3 deletions demo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ const moveable = new Moveable(moveableElement.parentElement, {
setTransform(target);
!isPinch && setLabel(clientX, clientY, `X: ${left}px<br/>Y: ${top}px`);

}).on("scale", ({ target, dist, clientX, clientY, isPinch }) => {
const scaleX = frame.get("transform", "scaleX") * dist[0];
const scaleY = frame.get("transform", "scaleY") * dist[1];
}).on("scale", ({ target, delta, clientX, clientY, isPinch }) => {
const scaleX = frame.get("transform", "scaleX") * delta[0];
const scaleY = frame.get("transform", "scaleY") * delta[1];
frame.set("transform", "scaleX", scaleX);
frame.set("transform", "scaleY", scaleY);
setTransform(target);
Expand Down
6 changes: 3 additions & 3 deletions packages/ngx-moveable/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ display: block; transform: translate(${clientX}px, ${clientY - 10}px) translate(
this.setLabel(clientX, clientY, `X: ${left}px<br/>Y: ${top}px`);
}
}
onScale({ target, dist, clientX, clientY, isPinch }: OnScale) {
const scaleX = this.frame.get('transform', 'scaleX') * dist[0];
const scaleY = this.frame.get('transform', 'scaleY') * dist[1];
onScale({ target, delta, clientX, clientY, isPinch }: OnScale) {
const scaleX = this.frame.get('transform', 'scaleX') * delta[0];
const scaleY = this.frame.get('transform', 'scaleY') * delta[1];
this.frame.set('transform', 'scaleX', scaleX);
this.frame.set('transform', 'scaleY', scaleY);
this.setTransform(target);
Expand Down

0 comments on commit 1ddc75d

Please sign in to comment.