1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-12 11:15:04 +02:00

Fix slider for android

This commit is contained in:
Gary Katsevman 2013-03-12 11:40:40 -04:00
parent cbcff6a168
commit 85df20d736
2 changed files with 12 additions and 2 deletions

9
src/js/controls.js vendored
View File

@ -612,7 +612,8 @@ vjs.Slider.prototype.calculateDistance = function(event){
var box = this.el_,
boxX = vjs.findPosX(box),
boxW = box.offsetWidth,
handle = this.handle;
handle = this.handle,
pageX = event.pageX;
if (handle) {
var handleW = handle.el().offsetWidth;
@ -622,8 +623,12 @@ vjs.Slider.prototype.calculateDistance = function(event){
boxW = boxW - handleW;
}
if (pageX === 0 && event.changedTouches) {
pageX = event.changedTouches[0].pageX;
}
// Percent that the click is through the adjusted area
return Math.max(0, Math.min(1, (event.pageX - boxX) / boxW));
return Math.max(0, Math.min(1, (pageX - boxX) / boxW));
};
vjs.Slider.prototype.onFocus = function(){

View File

@ -172,6 +172,11 @@ vjs.fixEvent = function(event) {
event[prop] = old[prop];
}
if (event.changedTouches && event.pageX === 0 && event.pageY === 0) {
event.pageX = event.changedTouches[0].pageX;
event.pageY = event.changedTouches[0].pageY;
}
// The event occurred on this element
if (!event.target) {
event.target = event.srcElement || document;