brightcove / videojs-thumbnails

A video.js plugin that displays thumbnail images over the scrubber.
Other
168 stars 97 forks source link

Thumbnails not updating with Firefox #9

Closed xbgmsharp closed 10 years ago

xbgmsharp commented 10 years ago

I test with Safari and IE9 and Firefox on Windows. The first 2 broswer are ok. However with Firefox only the first thumbnail is show. I test against VideoJS 4.0 and and 4.1 and 4.2.1, the result are the same. The variable 'mouseTime' is not updated with Firefox because 'event.offsetX' is undefined. I am using FF24.0 on Windows7 64bits.

I used this array:

video.thumbnails({
  0: {
    src: 'test_ogv-th_0.png'
  },
  10: {
    src: 'test_ogv-th_10.png'
  },
  20: {
    src: 'test_ogv-th_20.png'
  },
  30: {
    src: 'test_ogv-th_30.png'
  },
  40: {
    src: 'test_ogv-th_40.png'
  }
});
xbgmsharp commented 10 years ago

If i do apply this fix, it does work for Firefox but not anymore for IE. http://stackoverflow.com/questions/11334452/event-offsetx-in-firefox

  var offsetX = event.offsetX==undefined?event.layerX:event.offsetX;
  mouseTime = Math.floor(offsetX / progressControl.width() * duration);

From http://www.jacklmoore.com/notes/mouse-position/ Mouse Event Properties offsetX, offsetY Standard: W3C Working Draft Mouse position relative to the target element. This is implemented very inconsistently between browsers.

xbgmsharp commented 10 years ago

Hello,

Thanks for the update and sorry for the delay. It does works for FF/Chrome/Safari but not anymore on IE. All tested on Windows7 x64.

On Linux no problem with FF and Chrome.

On 2013-10-19 18:23, doublex wrote:

This here works fór me:

// apply updated styles to the thumbnail if necessary ! var offsetX = event.offsetX; ! if (offsetX==undefined) { // Firefox... ! var offsetLeft = 0, elem = this; ! do { ! if ( !isNaN(elem.offsetLeft) ) ! offsetLeft += elem.offsetLeft; ! } while( elem = elem.offsetParent ); ! offsetX = event.pageX - offsetLeft; ! } ! mouseTime = Math.floor(offsetX / progressControl.width() * duration); for (time in settings) {

Reply to this email directly or view it on GitHub [1].

Links:

[1] https://github.com/brightcove/videojs-thumbnails/issues/9#issuecomment-26653151

xbgmsharp commented 10 years ago

This fix my issue, it does work for all browser I tested. See code https://github.com/xbgmsharp/piwigo-videojs/commit/c0bc724a214731496c03d0947d32f3c7b73a3b1a

gkatsev commented 10 years ago

Looks like this has been fixed based on the code change in the last comment.