Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- onTouchStart: function(e, win, eventInfo) {
- if(!this.config.panning) return;
- if(this.config.panning == 'avoid nodes' && (this.dom? this.isLabel(e, win) : eventInfo.getNode())) return;
- this.pressed = true;
- this.pos = eventInfo.getPos();
- var canvas = this.canvas,
- ox = canvas.translateOffsetX,
- oy = canvas.translateOffsetY,
- sx = canvas.scaleOffsetX,
- sy = canvas.scaleOffsetY;
- this.pos.x *= sx;
- this.pos.x += ox;
- this.pos.y *= sy;
- this.pos.y += oy;
- },
- onTouchMove: function(e, win, eventInfo) {
- if(!this.config.panning) return;
- if(!this.pressed) return;
- if(this.config.panning == 'avoid nodes' && (this.dom? this.isLabel(e, win) : eventInfo.getNode())) return;
- var thispos = this.pos,
- currentPos = eventInfo.getPos(),
- canvas = this.canvas,
- ox = canvas.translateOffsetX,
- oy = canvas.translateOffsetY,
- sx = canvas.scaleOffsetX,
- sy = canvas.scaleOffsetY;
- currentPos.x *= sx;
- currentPos.y *= sy;
- currentPos.x += ox;
- currentPos.y += oy;
- var x = currentPos.x - thispos.x,
- y = currentPos.y - thispos.y;
- this.pos = currentPos;
- this.canvas.translate(x * 1/sx, y * 1/sy);
- },
- onTouchEnd: function(e, win, eventInfo) {
- if(!this.config.panning) return;
- this.pressed = false;
- },
- onTouchCancel: function(e, win, eventInfo) {
- if(!this.config.panning) return;
- this.pressed = false;
- }
- event.touches.length
- e.touches.length
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement