touchDragZoom.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. $(function () {
  2. 'use strict';
  3. var $image = $(window.createCropperImage()),
  4. pageX = window.innerWidth / 2,
  5. pageY = window.innerHeight / 2;
  6. $image.cropper({
  7. touchDragZoom: false,
  8. built: function () {
  9. var cropper = $image.data('cropper'),
  10. _ratio = cropper.image.ratio;
  11. QUnit.test('options.touchDragZoom', function (assert) {
  12. cropper.$cropper.trigger($.Event('touchstart', {
  13. originalEvent: {
  14. touches: [
  15. {
  16. pageX: pageX,
  17. pageY: pageY
  18. },
  19. {
  20. pageX: pageX,
  21. pageY: pageY
  22. }
  23. ]
  24. }
  25. })).trigger($.Event('touchmove', {
  26. originalEvent: {
  27. touches: [
  28. {
  29. pageX: pageX - 10,
  30. pageY: pageY - 10
  31. },
  32. {
  33. pageX: pageX + 10,
  34. pageY: pageY + 10
  35. }
  36. ]
  37. }
  38. })).trigger('touchend');
  39. assert.equal(cropper.image.ratio, _ratio);
  40. });
  41. }
  42. });
  43. });