From 2b232e6d3ef71822aafd211cd530a27a8bb5c086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Na=CC=88rhinen?= Date: Thu, 4 Jun 2015 10:26:33 +0300 Subject: [PATCH] Fix mousemove events for IE8 Fixes #829 --- lib/common.js | 6 ++++-- lib/ext/slider.js | 2 +- lib/ext/ui.js | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/common.js b/lib/common.js index b6c778296..852242b6c 100644 --- a/lib/common.js +++ b/lib/common.js @@ -139,13 +139,15 @@ common.offset = function(el) { common.width = function(el, val) { /*jshint -W093 */ if (val) return el.style.width = (''+val).replace(/px$/, '') + 'px'; - return common.offset(el).width; + var ret = common.offset(el).width; + return typeof ret === 'undefined' ? el.offsetWidth : ret; }; common.height = function(el, val) { /*jshint -W093 */ if (val) return el.style.height = (''+val).replace(/px$/, '') + 'px'; - return common.offset(el).height; + var ret = common.offset(el).height; + return typeof ret === 'undefined' ? el.offsetHeight : ret; }; common.lastChild = function(el) { diff --git a/lib/ext/slider.js b/lib/ext/slider.js index f5b963db5..543ed6406 100644 --- a/lib/ext/slider.js +++ b/lib/ext/slider.js @@ -58,7 +58,7 @@ var slider = function(root, rtl) { }, mousemove = function(e) { - var pageX = e.pageX; + var pageX = e.pageX || e.clientX; if (!pageX && e.originalEvent && e.originalEvent.touches && e.originalEvent.touches.length) { pageX = e.originalEvent.touches[0].pageX; } diff --git a/lib/ext/ui.js b/lib/ext/ui.js index 366969af9..914a367ef 100644 --- a/lib/ext/ui.js +++ b/lib/ext/ui.js @@ -287,7 +287,7 @@ flowplayer(function(api, root) { }); bean.on(root, 'mousemove', '.fp-timeline', function(ev) { - var x = ev.pageX, + var x = ev.pageX || ev.clientX, delta = x - common.offset(timeline).left, percentage = delta / common.width(timeline), seconds = percentage * api.video.duration;