UNPKG

videojs-sprite-thumbnails

Version:

Plugin to display thumbnails from a sprite image when hovering over the progress bar.

3 lines (2 loc) 1.98 kB
/*! @name videojs-sprite-thumbnails @version 0.5.2 @license MIT */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("video.js")):"function"==typeof define&&define.amd?define(["video.js"],t):(e=e||self).videojsSpriteThumbnails=t(e.videojs)}(this,function(e){"use strict";var t=(e=e&&e.hasOwnProperty("default")?e.default:e).getPlugin("plugin"),o={url:"",width:0,height:0,interval:1,responsive:600},r=function(t){var r,i;function n(r,i){var n;return(n=t.call(this,r)||this).options=e.mergeOptions(o,i),n.player.ready(function(){!function(t,o){var r=o.url,i=o.height,n=o.width,a=o.responsive,p=e.dom||e,s=t.controlBar,l=s.progressControl,u=l.seekBar,d=u.mouseTimeDisplay;if(r&&i&&n&&d){var c=p.createEl("img",{src:r}),f=function(e){Object.keys(e).forEach(function(t){var o=e[t],r=d.timeTooltip.el_.style;""!==o?r.setProperty(t,o):r.removeProperty(t)})},h=function(){var e=c.naturalWidth,l=c.naturalHeight;if(e&&l){var h=u.el_,g=parseFloat(d.el_.style.left);if(g=t.duration()*(g/h.clientWidth),!isNaN(g)){g/=o.interval;var m=t.el_.clientWidth,v=a&&m<a?m/a:1,b=e/n,x=n*v,y=i*v,k=Math.floor(g%b)*-x,_=Math.floor(g/b)*-y,j=e*v+"px "+l*v+"px",w=p.getBoundingClientRect(s.el_).top,O=p.getBoundingClientRect(h).top,P=-y-Math.max(0,O-w);f({width:x+"px",height:y+"px","background-image":"url("+r+")","background-repeat":"no-repeat","background-position":k+"px "+_+"px","background-size":j,top:P+"px",color:"#fff","text-shadow":"1px 1px #000",border:"1px solid #000",margin:"0 1px"})}}};f({width:"",height:"","background-image":"","background-repeat":"","background-position":"","background-size":"",top:"",color:"","text-shadow":"",border:"",margin:""}),l.on("mousemove",h),l.on("touchmove",h),t.addClass("vjs-sprite-thumbnails")}}(n.player,n.options)}),n}return i=t,(r=n).prototype=Object.create(i.prototype),r.prototype.constructor=r,r.__proto__=i,n}(t);return r.defaultState={},r.VERSION="0.5.2",e.registerPlugin("spriteThumbnails",r),r});