Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. onTouchStart: function(e, win, eventInfo) {
  2. if(!this.config.panning) return;
  3. if(this.config.panning == 'avoid nodes' && (this.dom? this.isLabel(e, win) : eventInfo.getNode())) return;
  4. this.pressed = true;
  5. this.pos = eventInfo.getPos();
  6. var canvas = this.canvas,
  7. ox = canvas.translateOffsetX,
  8. oy = canvas.translateOffsetY,
  9. sx = canvas.scaleOffsetX,
  10. sy = canvas.scaleOffsetY;
  11. this.pos.x *= sx;
  12. this.pos.x += ox;
  13. this.pos.y *= sy;
  14. this.pos.y += oy;
  15. },
  16.  
  17. onTouchMove: function(e, win, eventInfo) {
  18. if(!this.config.panning) return;
  19. if(!this.pressed) return;
  20. if(this.config.panning == 'avoid nodes' && (this.dom? this.isLabel(e, win) : eventInfo.getNode())) return;
  21. var thispos = this.pos,
  22. currentPos = eventInfo.getPos(),
  23. canvas = this.canvas,
  24. ox = canvas.translateOffsetX,
  25. oy = canvas.translateOffsetY,
  26. sx = canvas.scaleOffsetX,
  27. sy = canvas.scaleOffsetY;
  28. currentPos.x *= sx;
  29. currentPos.y *= sy;
  30. currentPos.x += ox;
  31. currentPos.y += oy;
  32. var x = currentPos.x - thispos.x,
  33. y = currentPos.y - thispos.y;
  34. this.pos = currentPos;
  35. this.canvas.translate(x * 1/sx, y * 1/sy);
  36. },
  37.  
  38. onTouchEnd: function(e, win, eventInfo) {
  39. if(!this.config.panning) return;
  40. this.pressed = false;
  41. },
  42. onTouchCancel: function(e, win, eventInfo) {
  43. if(!this.config.panning) return;
  44. this.pressed = false;
  45. }
  46.  
  47. event.touches.length
  48.  
  49. e.touches.length
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement