diff --git a/CHANGELOG.md b/CHANGELOG.md index 589f97020..22b630e4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ CHANGELOG * Export video.js as a named AMD module ([view](https://github.com/videojs/video.js/pull/1844)) * Hide the poster when play fires ([view](https://github.com/videojs/video.js/pull/1834)) * @chikathreesix fixed an object delete error in Chrome ([view](https://github.com/videojs/video.js/pull/1858)) +* @steverandy fixed an issue with scrolling over the player on touch devices ([view](https://github.com/videojs/video.js/pull/1809)) -------------------- diff --git a/src/js/component.js b/src/js/component.js index a6ebe3918..6bacabdc3 100644 --- a/src/js/component.js +++ b/src/js/component.js @@ -1043,7 +1043,7 @@ vjs.Component.prototype.emitTapEvents = function(){ this.on('touchstart', function(event) { // If more than one finger, don't consider treating this as a click if (event.touches.length === 1) { - firstTouch = event.touches[0]; + firstTouch = vjs.obj.copy(event.touches[0]); // Record start time so we can detect a tap vs. "touch and hold" touchStart = new Date().getTime(); // Reset couldBeTap tracking diff --git a/test/unit/component.js b/test/unit/component.js index 9614b2865..bdde70f30 100644 --- a/test/unit/component.js +++ b/test/unit/component.js @@ -462,13 +462,14 @@ test('should use a defined content el for appending children', function(){ }); test('should emit a tap event', function(){ - expect(2); + expect(3); // Fake touch support. Real touch support isn't needed for this test. var origTouch = vjs.TOUCH_ENABLED; vjs.TOUCH_ENABLED = true; var comp = new vjs.Component(getFakePlayer()); + var singleTouch = {}; comp.emitTapEvents(); comp.on('tap', function(){ @@ -497,6 +498,24 @@ test('should emit a tap event', function(){ ]}); comp.trigger('touchend'); + // A touchmove with a lot of movement by modifying the exisiting touch object + // should not trigger a tap + singleTouch = { pageX: 0, pageY: 0 }; + vjs.trigger(comp.el(), {type: 'touchstart', touches: [singleTouch]}); + singleTouch.pageX = 100; + singleTouch.pageY = 100; + vjs.trigger(comp.el(), {type: 'touchmove', touches: [singleTouch]}); + comp.trigger('touchend'); + + // A touchmove with not much movement by modifying the exisiting touch object + // should still allow a tap + singleTouch = { pageX: 0, pageY: 0 }; + vjs.trigger(comp.el(), {type: 'touchstart', touches: [singleTouch]}); + singleTouch.pageX = 10; + singleTouch.pageY = 10; + vjs.trigger(comp.el(), {type: 'touchmove', touches: [singleTouch]}); + comp.trigger('touchend'); + // Reset to orignial value vjs.TOUCH_ENABLED = origTouch; });