touch.js 979 B

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.touch = Behavior({
  4. methods: {
  5. touchStart: function (event) {
  6. var touch = event.touches[0];
  7. this.direction = '';
  8. this.deltaX = 0;
  9. this.deltaY = 0;
  10. this.offsetX = 0;
  11. this.offsetY = 0;
  12. this.startX = touch.clientX;
  13. this.startY = touch.clientY;
  14. },
  15. touchMove: function (event) {
  16. var touch = event.touches[0];
  17. this.deltaX = touch.clientX - this.startX;
  18. this.deltaY = touch.clientY - this.startY;
  19. this.offsetX = Math.abs(this.deltaX);
  20. this.offsetY = Math.abs(this.deltaY);
  21. this.direction =
  22. this.offsetX > this.offsetY
  23. ? 'horizontal'
  24. : this.offsetX < this.offsetY
  25. ? 'vertical'
  26. : '';
  27. }
  28. }
  29. });