second
This commit is contained in:
parent
5f7fcb96ed
commit
01204dfa2f
34 changed files with 1498 additions and 0 deletions
5
gestures.js
Normal file
5
gestures.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Keep the world point under the gesture midpoint while fingers move or zoom.
|
||||
export function pinchCamera(start,a,b,rect,view,worldWidth,worldHeight){
|
||||
const zoom=Math.max(1,Math.min(32,start.zoom*Math.hypot(a.x-b.x,a.y-b.y)/start.distance)),s=zoom*view.base;
|
||||
return {zoom,panX:(a.x+b.x)/2-rect.left-start.anchorX*s-(view.width-worldWidth*s)/2,panY:(a.y+b.y)/2-rect.top-start.anchorY*s-(view.height-worldHeight*s)/2};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue