1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-19 10:54:16 +02:00

Make slider touch/mouse events removable

This commit is contained in:
Gary Katsevman 2013-03-12 11:45:59 -04:00
parent 85df20d736
commit f8706bbffe

21
src/js/controls.js vendored
View File

@ -521,6 +521,8 @@ vjs.Slider = function(player, options){
// this.player_.one('timeupdate', vjs.bind(this, this.update)); // this.player_.one('timeupdate', vjs.bind(this, this.update));
player.ready(vjs.bind(this, this.update)); player.ready(vjs.bind(this, this.update));
this.boundEvents = {};
}; };
goog.inherits(vjs.Slider, vjs.Component); goog.inherits(vjs.Slider, vjs.Component);
@ -540,20 +542,23 @@ vjs.Slider.prototype.onMouseDown = function(event){
event.preventDefault(); event.preventDefault();
vjs.blockTextSelection(); vjs.blockTextSelection();
vjs.on(document, 'mousemove', vjs.bind(this, this.onMouseMove)); this.boundEvents.move = vjs.bind(this, this.onMouseMove);
vjs.on(document, 'mouseup', vjs.bind(this, this.onMouseUp)); this.boundEvents.end = vjs.bind(this, this.onMouseUp);
vjs.on(document, 'touchmove', vjs.bind(this, this.onMouseMove));
vjs.on(document, 'touchend', vjs.bind(this, this.onMouseUp)); vjs.on(document, 'mousemove', this.boundEvents.move);
vjs.on(document, 'mouseup', this.boundEvents.end);
vjs.on(document, 'touchmove', this.boundEvents.move);
vjs.on(document, 'touchend', this.boundEvents.end);
this.onMouseMove(event); this.onMouseMove(event);
}; };
vjs.Slider.prototype.onMouseUp = function() { vjs.Slider.prototype.onMouseUp = function() {
vjs.unblockTextSelection(); vjs.unblockTextSelection();
vjs.off(document, 'mousemove', this.onMouseMove, false); vjs.off(document, 'mousemove', this.boundEvents.move, false);
vjs.off(document, 'mouseup', this.onMouseUp, false); vjs.off(document, 'mouseup', this.boundEvents.end, false);
vjs.off(document, 'touchmove', this.onMouseMove, false); vjs.off(document, 'touchmove', this.boundEvents.move, false);
vjs.off(document, 'touchend', this.onMouseUp, false); vjs.off(document, 'touchend', this.boundEvents.end, false);
this.update(); this.update();
}; };