1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-10 23:30:03 +02:00

@steverandy fixed an issue with scrolling over the player on touch devices. closes #1809

This commit is contained in:
Steve Randy Tantra 2015-02-12 12:01:20 -08:00 committed by heff
parent 19058302bd
commit fbb2197dfa
3 changed files with 22 additions and 2 deletions

View File

@ -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))
--------------------

View File

@ -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

View File

@ -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;
});