mirror of
https://github.com/videojs/video.js.git
synced 2024-12-14 11:23:30 +02:00
Make buttons accept tap events as well as click. Prevent mouseevents when touch is available
This commit is contained in:
parent
f8706bbffe
commit
9555b80cc0
20
src/js/controls.js
vendored
20
src/js/controls.js
vendored
@ -42,7 +42,7 @@ vjs.ControlBar = function(player, options){
|
|||||||
this.player_.on('touchmove', function() {
|
this.player_.on('touchmove', function() {
|
||||||
touchstart = false;
|
touchstart = false;
|
||||||
});
|
});
|
||||||
this.player_.on('touchend', vjs.bind(this, function() {
|
this.player_.on('touchend', vjs.bind(this, function(event) {
|
||||||
var idx;
|
var idx;
|
||||||
if (touchstart) {
|
if (touchstart) {
|
||||||
idx = this.el().className.search('fade-in');
|
idx = this.el().className.search('fade-in');
|
||||||
@ -53,6 +53,8 @@ vjs.ControlBar = function(player, options){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
touchstart = false;
|
touchstart = false;
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
@ -104,6 +106,22 @@ vjs.ControlBar.prototype.lockShowing = function(){
|
|||||||
vjs.Button = function(player, options){
|
vjs.Button = function(player, options){
|
||||||
goog.base(this, player, options);
|
goog.base(this, player, options);
|
||||||
|
|
||||||
|
var touchstart = false;
|
||||||
|
this.on('touchstart', function() {
|
||||||
|
touchstart = true;
|
||||||
|
});
|
||||||
|
this.on('touchmove', function() {
|
||||||
|
touchstart = false;
|
||||||
|
});
|
||||||
|
var self = this;
|
||||||
|
this.on('touchend', function(event) {
|
||||||
|
if (touchstart) {
|
||||||
|
self.onClick(event);
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
this.on('click', this.onClick);
|
this.on('click', this.onClick);
|
||||||
this.on('focus', this.onFocus);
|
this.on('focus', this.onFocus);
|
||||||
this.on('blur', this.onBlur);
|
this.on('blur', this.onBlur);
|
||||||
|
Loading…
Reference in New Issue
Block a user