Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Pix2Pix Tablet enabled
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match http://affinelayer.com/pixsrv/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. console.log("Adding touch control event listeners");
  12. console.log(editors);
  13. for(var i in editors) {
  14. console.log("Adding touchmove to "+editors[i]);
  15. editors[i].view.ctx.canvas.addEventListener("touchmove", function(e) {
  16. mouse_pos = {x: e.targetTouches[0].clientX, y: e.targetTouches[0].clientY};
  17. mouse_down = true;
  18. mouse_pressed = false;
  19. e.preventDefault();
  20. update();
  21. });
  22. }
  23.  
  24. document.addEventListener("touchstart", function(e) {
  25. mouse_pos = {x: e.targetTouches[0].clientX, y: e.targetTouches[0].clientY};
  26. mouse_down = false;
  27. mouse_pressed = false;
  28. update();
  29. });
  30.  
  31. document.addEventListener("touchend", function(e) {
  32. mouse_pos = last_mouse_pos;
  33. mouse_down = false;
  34. mouse_released = true;
  35. update();
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement