Skip to content

Commit

Permalink
zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
tailuge committed Oct 27, 2023
1 parent 9d16955 commit daed4a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/diagram.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions src/events/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,15 @@ export class Keyboard {
}

mousetouch = (e) => {
const k = this.released
const factor = e.ctrlKey ? 0.5 : 1
const dx = e.dx * factor
const dy = e.dy * factor
if (Math.abs(dy) > 3 * Math.abs(dx)) {
const cy = this.released["movementY"] ?? 0.0
this.released["movementY"] = cy + dy
return
const dy = e.dy * 0.8
k["movementY"] = (k["movementY"] ?? 0.0) + dy
k["movementX"] = (k["movementX"] ?? 0.0) + dx
if (Math.abs(k["movementX"]) > Math.abs(k["movementY"])) {
k["movementY"] = 0
}
const cx = this.released["movementX"] ?? 0.0
this.released["movementX"] = cx + dx
}

private addHandlers(element: HTMLCanvasElement) {
Expand Down

0 comments on commit daed4a7

Please sign in to comment.