New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

drive-in

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drive-in - npm Package Compare versions

Comparing version 1.4.1 to 1.4.2

6

dist/drive-in-browser.js

@@ -701,4 +701,6 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.DriveIn = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

this.isTouch = options.isTouch !== undefined ? options.isTouch : "ontouchstart" in window || !!options.slideshow;
this.isTouch = options.isTouch !== undefined ? options.isTouch : "ontouchstart" in window;
this.slideshow = options.slideshow;
this.parentEl = this._setParent(options.el);

@@ -973,3 +975,3 @@ var mediaEl = this._createMediaEl();

value: function pause(silent) {
clearTimeout(timerId);
clearTimeout(this.timerId);
this.remaining -= new Date() - this.start;

@@ -976,0 +978,0 @@

@@ -1,1 +0,1 @@

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.DriveIn=e()}}(function(){return function e(t,i,n){function s(o,a){if(!i[o]){if(!t[o]){var l="function"==typeof require&&require;if(!a&&l)return l(o,!0);if(r)return r(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var h=i[o]={exports:{}};t[o][0].call(h.exports,function(e){var i=t[o][1][e];return s(i?i:e)},h,h.exports,e,t,i,n)}return i[o].exports}for(var r="function"==typeof require&&require,o=0;o<n.length;o++)s(n[o]);return s}({1:[function(e,t){"use strict";function i(){}i.prototype.on=function(e,t){return this._collection=this._collection||{},this._collection[e]=this._collection[e]||[],this._collection[e].push(t),this},i.prototype.once=function(e,t){function i(){n.off(e,i),t.apply(this,arguments)}var n=this;return i.listener=t,this.on(e,i),this},i.prototype.off=function(e,t){var i=this._collection[e],n=0;if(void 0!==i)for(n;n<i.length;n+=1)if(i[n]===t||i[n].listener===t){i.splice(n,1);break}return 0===i.length&&this.removeAllListeners(e),this},i.prototype.removeAllListeners=function(e){return this._collection=this._collection||{},delete this._collection[e],this},i.prototype.listeners=function(e){return this._collection=this._collection||{},this._collection[e]},i.prototype.emit=function(){if(void 0===this._collection)return this;var e,t=[].slice.call(arguments,0),i=t.shift(),n=this._collection[i],s=0;if(n)for(n=n.slice(0),e=n.length,s;e>s;s+=1)n[s].apply(this,t);return this},t.exports=i},{}],2:[function(e,t){"use strict";var i=function(e){return e&&e.__esModule?e["default"]:e},n=function(){function e(e,t){for(var i in t){var n=t[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(e,t)}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)},r=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},o=i(e("jvent")),a=i(e("./timer")),l=i(e("./playlist")),u=i(e("./utils")),h=u.getWidth,c=u.getHeight,d=u.setStyles,p=u.findPoster,m=u.createEl,f=u.replaceChildren,y=function(e){function t(){r(this,t),this._listeners=[],this.parentEl=null,this.mediaEl=null,this.placeholderEl=null,this.mute=!0,this.currMediaType=null,this.mediaAspect=16/9,this.playlist=null,this.loop=!0,this.loopPlaylistItems=!1,this.slideshow=!1,this.playlistLength=0,this.currentItem=0,this.slideshowItemDuration=10,this._slideshowTimer=null,this._seeking=!1,this.poster=null,this.loading=!0}return s(t,e),n(t,{_updateSize:{value:function(e,t,i){var n=1,s=h(),r=c(),o=s/r;i>o?(d(this.parentEl,{width:Math.ceil(r*i)+"px",height:r+n+"px"}),"video"===t?d(e,{width:Math.ceil(r*i)+"px",height:r+"px"}):d(e,{width:"auto",height:r+n+"px"})):(d(this.parentEl,{width:s+"px",height:Math.ceil(s/i)+1+"px"}),"video"===t?d(e,{width:this.parentEl.offsetWidth+"px",height:"auto"}):d(e,{width:s+"px",height:"auto"}))}},_setVideoData:{value:function(){var e=this.mediaEl;this.mediaAspect=e.videoWidth/e.videoHeight,this._updateSize(e,"video",this.mediaAspect)}},_setImageData:{value:function(e){this.mediaAspect=e.naturalWidth/e.naturalHeight,this.isTouch||this._updateSize(this.mediaEl,"image",this.mediaAspect)}},_playVideoItem:{value:function(e,t){for(var i,n,s,r,o=this.mediaEl,a=[],l=e.length-1;l>=0;l--)i=e[l],0!==i.type.search(/^image/)||s?n=m("source",{src:i.src,type:i.type}):s=i.src,n&&(r=o.canPlayType(i.type),"probably"===r?a.unshift(n):a.push(n));a.length?(this.emit("media.loading"),o.preload="auto",(this.playlistLength<2||this.loopPlaylistItems)&&(o.loop=!0),this.mute&&this.setVolume(0),s&&(o.poster=s),f(o,a),this.currentItem=t,o.load()):s||this.poster?(this.slideshow=!0,this._createMediaEl(),this._playImageItem(e,t)):this.emit("media.error",new Error("No playable source"))}},_playImageItem:{value:function(e,t){var i,n;if(e&&e.length)for(var s in e)i=e[s],0!==i.type.search(/^image/)||n||(n=i.src);!n&&this.poster&&(n=this.poster.src),n?(this.emit("media.loading"),this.mediaEl.src=n,this.currentItem=t):this.emit("media.error",new Error("No playable source"))}},_setBackgroundItem:{value:function(){this.parentEl.style["background-image"]='url("'+this.poster.src+'")'}},_playItem:{value:function(e,t){return this.isTouch?(this._setBackgroundItem(),void this._playImageItem()):("video"===this.currMediaType&&this._playVideoItem(e,t),"image"===this.currMediaType&&this._playImageItem(e,t),void(this._seeking=!1))}},_loadPlaylist:{value:function(e){this.playlist=e,this.playlistLength=e.length,this._playItem(e[0],0)}},_addListener:{value:function(e,t,i){e.addEventListener(t,i),this._listeners.push({element:e,event:t,handler:i})}},_removeAllListeners:{value:function(){var e,t=this._listeners;for(var i in t)e=t[i],e.element.removeEventListener(e.event,e.handler)}},_attachVideoListeners:{value:function(){function e(e){o._setVideoData(e),o.emit("media.metadata",e)}function t(){o.emit("media.playing",o.currentItem)}function i(){o.emit("media.pause")}function n(e){var t=null,i=e.target;i.buffered&&i.buffered.length>0&&i.buffered.end&&i.duration?t=i.buffered.end(0)/i.duration:"undefined"!=typeof i.bytesTotal&&i.bytesTotal>0&&"undefined"!=typeof i.bufferedBytes&&(t=i.bufferedBytes/i.bytesTotal),null!==t&&(t=100*Math.min(1,Math.max(0,t))),1===i.networkState&&0===i.readyState&&(t=100),o.emit("media.progress",t)}function s(){o._seeking||o.emit("media.ended",o.currentItem)}function r(){o.emit("media.canplay"),a.play(),o._seeking&&(o._seeking=!1)}var o=this,a=this.mediaEl;this._addListener(a,"loadedmetadata",e),this._addListener(a,"playing",t),this._addListener(a,"pause",i),this._addListener(a,"ended",s),this._addListener(a,"canplay",r),this._addListener(a,"progress",n,!1)}},_attachImageListeners:{value:function(){function e(){var e=new Event("ended");s.mediaEl.dispatchEvent(e)}function t(){s.emit("media.pause")}function i(){s.emit("media.canplay"),s._setImageData(this),s.emit("media.metadata",this),s.emit("media.playing",s.currentItem),s.isTouch||s.playlistLength>1&&(s._slideshowTimer&&s._slideshowTimer.destroy(),s._slideshowTimer=new a(e,1e3*s.slideshowItemDuration),s._slideshowTimer.on("pause",t))}function n(){s.emit("media.ended",s.currentItem)}var s=this,r=this.mediaEl;this._addListener(r,"load",i),this._addListener(r,"ended",n)}},_attachListeners:{value:function(){function e(){window.requestAnimationFrame(function(){r.metadataLoaded&&r._updateSize(o,r.currMediaType,r.mediaAspect)})}function t(){if(!this._seeking){var e=0;return r.playlistLength>1&&r.loopPlaylistItems?void("image"===r.currMediaType&&r.play(r.currentItem)):void(r.playlistLength>1&&r.loop&&(r.currentItem+1<r.playlistLength&&(e=r.currentItem+1),r.play(e)))}}function i(){o.style.opacity=1,r.canplay=!0}function n(){r.metadataLoaded=!0}function s(){r.canplay=!1,r.metadataLoaded=!1}var r=this,o=this.mediaEl;return this.isTouch?void this._attachImageListeners():(this._addListener(window,"resize",e),"video"===this.currMediaType?this._attachVideoListeners():this._attachImageListeners(),this.on("media.ended",t),this.on("media.canplay",i),this.on("media.metadata",n),void this.on("media.loading",s))}},_setParent:{value:function(e){return this.isTouch?d(e,{width:"100%",height:"100%",display:"block","background-position":"50% 50%","background-repeat":"no-repeat no-repeat","background-attachment":"local","background-size":"cover"}):d(e,{position:"absolute",display:"block",transform:"translate3d(-50%,-50%,0)","-webkit-transform":"translate3d(-50%,-50%,0)",left:"50%",top:"50%"}),e}},_cleanup:{value:function(){for(var e=this.parentEl;e.firstChild;)e.removeChild(e.firstChild)}},_createMediaEl:{value:function(){var e;return this.mediaEl&&this._cleanup(),this.isTouch?(this.currMediaType="image",e=m("img"),d(e,{display:"none"}),e):(this.slideshow?(this.currMediaType="image",e=m("img")):(this.currMediaType="video",e=m("video",{height:1,width:1,preload:"metadata"})),e?(e.style.opacity=0,d(e,{display:"block"}),e):void 0)}},init:{value:function(e){e=e||{},this.isTouch=void 0!==e.isTouch?e.isTouch:"ontouchstart"in window||!!e.slideshow,this.parentEl=this._setParent(e.el);var t=this._createMediaEl();this.parentEl.appendChild(t),this.mediaEl=t,this._attachListeners()}},show:{value:function(e,t){return e.constructor===Array?this.showPlaylist([e],t):e.constructor===Object?this.showPlaylist([[e]],t):this.showPlaylist([l.makePlaylistItem(e)],t)}},showPlaylist:{value:function(e,t){t=t||{},t.hasOwnProperty("mute")&&(this.mute=t.mute),t.hasOwnProperty("loop")&&(this.loop=t.loop),t.hasOwnProperty("loopPlaylistItems")&&(this.loopPlaylistItems=t.loopPlaylistItems,this.loopPlaylistItems&&(this.loop=!1));var i=l.makePlaylist(e);this.poster=t.poster?"string"==typeof t.poster?{src:t.poster}:t.poster:p(i),this._loadPlaylist(i)}},setVolume:{value:function(e){"image"!==this.currMediaType&&(0===e?(this.mute=!0,this.mediaEl.muted=!0,this.mediaEl.volume=0):(this.mute=!1,this.mediaEl.muted=!1,this.mediaEl.volume=e))}},setPlaybackRate:{value:function(e){"image"!==this.currMediaType&&(this.mediaEl.playbackRate=e||1)}},getMedia:{value:function(){return this.mediaEl}},getPlaylist:{value:function(){return this.playlist}},getItem:{value:function(e){return this.playlist[e]}},play:{value:function(e){this._seeking=!0,"number"==typeof e?this._playItem(this.playlist[e],e):"video"===this.currMediaType?this.mediaEl.play():this._slideshowTimer&&this._slideshowTimer.resume()}},pause:{value:function(){"video"===this.currMediaType?this.mediaEl.pause():this._slideshowTimer&&this._slideshowTimer.pause()}},close:{value:function(){this._removeAllListeners(),this._cleanup(),this._slideshowTimer&&(this._slideshowTimer.destroy(),delete this._slideshowTimer)}},currentTime:{value:function(){return"video"===this.currMediaType?this.mediaEl.currentTime:this._slideshowTimer.currentTime()}},seekTo:{value:function(e){this._seeking=!0,"video"===this.currMediaType&&(this.mediaEl.currentTime=e)}},duration:{value:function(){return"video"===this.currMediaType?this.mediaEl.duration:this.slideshowItemDuration}}}),t}(o);t.exports=y},{"./playlist":3,"./timer":4,"./utils":5,jvent:1}],3:[function(e,t){"use strict";function i(e){var t={},i={mp4:!0,ogv:!0,webm:!0},n={jpg:!0,png:!0,gif:!0},s=e.replace(/[\?|\#].+/,"").match(/\.([mp4|ogv|webm|jpg|jpeg|png|gif]+)$/)[1];return i[s]&&(t.type="ogv"===s?"video/ogg":"video/"+s),n[s]&&(t.type="jpg"===s?"image/jpeg":"image/"+s),t.src=e,t}function n(e,t){t=t||0;var s,r=[];for(var o in e)s=e[o],s.constructor===Object&&r.push([s]),s.constructor===Array&&r.push(n(s,t+1)),"string"==typeof s&&r.push(0===t?[i(s)]:i(s));return r}t.exports={makePlaylist:n,makePlaylistItem:i}},{}],4:[function(e,t){"use strict";var i=function(e){return e&&e.__esModule?e["default"]:e},n=function(){function e(e,t){for(var i in t){var n=t[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(e,t)}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)},r=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},o=i(e("jvent")),a=function(e){function t(e,i){r(this,t),this.callback=e,this.remaining=i,this.timerId=null,this.start=null,this.resume()}return s(t,e),n(t,{pause:{value:function(e){clearTimeout(timerId),this.remaining-=new Date-this.start,e||this.emit("pause")}},resume:{value:function(e){this.start=new Date,clearTimeout(this.timerId),this.timerId=setTimeout(this.callback,this.remaining),e||this.emit("resume")}},currentTime:{value:function(){var e=new Date-this.start;return this.timerId&&(this.pause(!0),this.resume(!0)),e}},destroy:{value:function(){this.pause(!0),this.removeAllListeners()}}}),t}(o);t.exports=a},{jvent:1}],5:[function(e,t){"use strict";function i(){return self.innerHeight?self.innerWidth:document.documentElement&&document.documentElement.clientWidth?document.documentElement.clientWidth:document.body?document.body.clientWidth:void 0}function n(){return self.innerHeight?self.innerHeight:document.documentElement&&document.documentElement.clientHeight?document.documentElement.clientHeight:document.body?document.body.clientHeight:void 0}function s(e,t){var i="";for(var n in t)i+=n+":"+t[n]+";";e.style.cssText+=";"+i}function r(e){var t,i;for(var n in e){if(i=e[n],i.constructor===Array)t=r(i);else if(i.type.search(/^image/)>-1)return i;if(t)return t}}function o(e,t){[].slice.call(e).forEach(t)}function a(e,t){var i=e.children||e.childNodes;i.length&&o(i,function(i){var n=t.shift();n?e.replaceChild(n,i):e.removeChild(i)}),t.length&&t.forEach(function(t){e.appendChild(t)})}function l(e,t){var i=document.createElement(e);for(var n in t)i[n]=t[n];return i}t.exports={getWidth:i,getHeight:n,setStyles:s,findPoster:r,eachNode:o,replaceChildren:a,createEl:l}},{}]},{},[2])(2)});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.DriveIn=e()}}(function(){return function e(t,i,n){function s(o,a){if(!i[o]){if(!t[o]){var l="function"==typeof require&&require;if(!a&&l)return l(o,!0);if(r)return r(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var h=i[o]={exports:{}};t[o][0].call(h.exports,function(e){var i=t[o][1][e];return s(i?i:e)},h,h.exports,e,t,i,n)}return i[o].exports}for(var r="function"==typeof require&&require,o=0;o<n.length;o++)s(n[o]);return s}({1:[function(e,t){"use strict";function i(){}i.prototype.on=function(e,t){return this._collection=this._collection||{},this._collection[e]=this._collection[e]||[],this._collection[e].push(t),this},i.prototype.once=function(e,t){function i(){n.off(e,i),t.apply(this,arguments)}var n=this;return i.listener=t,this.on(e,i),this},i.prototype.off=function(e,t){var i=this._collection[e],n=0;if(void 0!==i)for(n;n<i.length;n+=1)if(i[n]===t||i[n].listener===t){i.splice(n,1);break}return 0===i.length&&this.removeAllListeners(e),this},i.prototype.removeAllListeners=function(e){return this._collection=this._collection||{},delete this._collection[e],this},i.prototype.listeners=function(e){return this._collection=this._collection||{},this._collection[e]},i.prototype.emit=function(){if(void 0===this._collection)return this;var e,t=[].slice.call(arguments,0),i=t.shift(),n=this._collection[i],s=0;if(n)for(n=n.slice(0),e=n.length,s;e>s;s+=1)n[s].apply(this,t);return this},t.exports=i},{}],2:[function(e,t){"use strict";var i=function(e){return e&&e.__esModule?e["default"]:e},n=function(){function e(e,t){for(var i in t){var n=t[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(e,t)}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)},r=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},o=i(e("jvent")),a=i(e("./timer")),l=i(e("./playlist")),u=i(e("./utils")),h=u.getWidth,c=u.getHeight,d=u.setStyles,p=u.findPoster,m=u.createEl,f=u.replaceChildren,y=function(e){function t(){r(this,t),this._listeners=[],this.parentEl=null,this.mediaEl=null,this.placeholderEl=null,this.mute=!0,this.currMediaType=null,this.mediaAspect=16/9,this.playlist=null,this.loop=!0,this.loopPlaylistItems=!1,this.slideshow=!1,this.playlistLength=0,this.currentItem=0,this.slideshowItemDuration=10,this._slideshowTimer=null,this._seeking=!1,this.poster=null,this.loading=!0}return s(t,e),n(t,{_updateSize:{value:function(e,t,i){var n=1,s=h(),r=c(),o=s/r;i>o?(d(this.parentEl,{width:Math.ceil(r*i)+"px",height:r+n+"px"}),"video"===t?d(e,{width:Math.ceil(r*i)+"px",height:r+"px"}):d(e,{width:"auto",height:r+n+"px"})):(d(this.parentEl,{width:s+"px",height:Math.ceil(s/i)+1+"px"}),"video"===t?d(e,{width:this.parentEl.offsetWidth+"px",height:"auto"}):d(e,{width:s+"px",height:"auto"}))}},_setVideoData:{value:function(){var e=this.mediaEl;this.mediaAspect=e.videoWidth/e.videoHeight,this._updateSize(e,"video",this.mediaAspect)}},_setImageData:{value:function(e){this.mediaAspect=e.naturalWidth/e.naturalHeight,this.isTouch||this._updateSize(this.mediaEl,"image",this.mediaAspect)}},_playVideoItem:{value:function(e,t){for(var i,n,s,r,o=this.mediaEl,a=[],l=e.length-1;l>=0;l--)i=e[l],0!==i.type.search(/^image/)||s?n=m("source",{src:i.src,type:i.type}):s=i.src,n&&(r=o.canPlayType(i.type),"probably"===r?a.unshift(n):a.push(n));a.length?(this.emit("media.loading"),o.preload="auto",(this.playlistLength<2||this.loopPlaylistItems)&&(o.loop=!0),this.mute&&this.setVolume(0),s&&(o.poster=s),f(o,a),this.currentItem=t,o.load()):s||this.poster?(this.slideshow=!0,this._createMediaEl(),this._playImageItem(e,t)):this.emit("media.error",new Error("No playable source"))}},_playImageItem:{value:function(e,t){var i,n;if(e&&e.length)for(var s in e)i=e[s],0!==i.type.search(/^image/)||n||(n=i.src);!n&&this.poster&&(n=this.poster.src),n?(this.emit("media.loading"),this.mediaEl.src=n,this.currentItem=t):this.emit("media.error",new Error("No playable source"))}},_setBackgroundItem:{value:function(){this.parentEl.style["background-image"]='url("'+this.poster.src+'")'}},_playItem:{value:function(e,t){return this.isTouch?(this._setBackgroundItem(),void this._playImageItem()):("video"===this.currMediaType&&this._playVideoItem(e,t),"image"===this.currMediaType&&this._playImageItem(e,t),void(this._seeking=!1))}},_loadPlaylist:{value:function(e){this.playlist=e,this.playlistLength=e.length,this._playItem(e[0],0)}},_addListener:{value:function(e,t,i){e.addEventListener(t,i),this._listeners.push({element:e,event:t,handler:i})}},_removeAllListeners:{value:function(){var e,t=this._listeners;for(var i in t)e=t[i],e.element.removeEventListener(e.event,e.handler)}},_attachVideoListeners:{value:function(){function e(e){o._setVideoData(e),o.emit("media.metadata",e)}function t(){o.emit("media.playing",o.currentItem)}function i(){o.emit("media.pause")}function n(e){var t=null,i=e.target;i.buffered&&i.buffered.length>0&&i.buffered.end&&i.duration?t=i.buffered.end(0)/i.duration:"undefined"!=typeof i.bytesTotal&&i.bytesTotal>0&&"undefined"!=typeof i.bufferedBytes&&(t=i.bufferedBytes/i.bytesTotal),null!==t&&(t=100*Math.min(1,Math.max(0,t))),1===i.networkState&&0===i.readyState&&(t=100),o.emit("media.progress",t)}function s(){o._seeking||o.emit("media.ended",o.currentItem)}function r(){o.emit("media.canplay"),a.play(),o._seeking&&(o._seeking=!1)}var o=this,a=this.mediaEl;this._addListener(a,"loadedmetadata",e),this._addListener(a,"playing",t),this._addListener(a,"pause",i),this._addListener(a,"ended",s),this._addListener(a,"canplay",r),this._addListener(a,"progress",n,!1)}},_attachImageListeners:{value:function(){function e(){var e=new Event("ended");s.mediaEl.dispatchEvent(e)}function t(){s.emit("media.pause")}function i(){s.emit("media.canplay"),s._setImageData(this),s.emit("media.metadata",this),s.emit("media.playing",s.currentItem),s.isTouch||s.playlistLength>1&&(s._slideshowTimer&&s._slideshowTimer.destroy(),s._slideshowTimer=new a(e,1e3*s.slideshowItemDuration),s._slideshowTimer.on("pause",t))}function n(){s.emit("media.ended",s.currentItem)}var s=this,r=this.mediaEl;this._addListener(r,"load",i),this._addListener(r,"ended",n)}},_attachListeners:{value:function(){function e(){window.requestAnimationFrame(function(){r.metadataLoaded&&r._updateSize(o,r.currMediaType,r.mediaAspect)})}function t(){if(!this._seeking){var e=0;return r.playlistLength>1&&r.loopPlaylistItems?void("image"===r.currMediaType&&r.play(r.currentItem)):void(r.playlistLength>1&&r.loop&&(r.currentItem+1<r.playlistLength&&(e=r.currentItem+1),r.play(e)))}}function i(){o.style.opacity=1,r.canplay=!0}function n(){r.metadataLoaded=!0}function s(){r.canplay=!1,r.metadataLoaded=!1}var r=this,o=this.mediaEl;return this.isTouch?void this._attachImageListeners():(this._addListener(window,"resize",e),"video"===this.currMediaType?this._attachVideoListeners():this._attachImageListeners(),this.on("media.ended",t),this.on("media.canplay",i),this.on("media.metadata",n),void this.on("media.loading",s))}},_setParent:{value:function(e){return this.isTouch?d(e,{width:"100%",height:"100%",display:"block","background-position":"50% 50%","background-repeat":"no-repeat no-repeat","background-attachment":"local","background-size":"cover"}):d(e,{position:"absolute",display:"block",transform:"translate3d(-50%,-50%,0)","-webkit-transform":"translate3d(-50%,-50%,0)",left:"50%",top:"50%"}),e}},_cleanup:{value:function(){for(var e=this.parentEl;e.firstChild;)e.removeChild(e.firstChild)}},_createMediaEl:{value:function(){var e;return this.mediaEl&&this._cleanup(),this.isTouch?(this.currMediaType="image",e=m("img"),d(e,{display:"none"}),e):(this.slideshow?(this.currMediaType="image",e=m("img")):(this.currMediaType="video",e=m("video",{height:1,width:1,preload:"metadata"})),e?(e.style.opacity=0,d(e,{display:"block"}),e):void 0)}},init:{value:function(e){e=e||{},this.isTouch=void 0!==e.isTouch?e.isTouch:"ontouchstart"in window,this.slideshow=e.slideshow,this.parentEl=this._setParent(e.el);var t=this._createMediaEl();this.parentEl.appendChild(t),this.mediaEl=t,this._attachListeners()}},show:{value:function(e,t){return e.constructor===Array?this.showPlaylist([e],t):e.constructor===Object?this.showPlaylist([[e]],t):this.showPlaylist([l.makePlaylistItem(e)],t)}},showPlaylist:{value:function(e,t){t=t||{},t.hasOwnProperty("mute")&&(this.mute=t.mute),t.hasOwnProperty("loop")&&(this.loop=t.loop),t.hasOwnProperty("loopPlaylistItems")&&(this.loopPlaylistItems=t.loopPlaylistItems,this.loopPlaylistItems&&(this.loop=!1));var i=l.makePlaylist(e);this.poster=t.poster?"string"==typeof t.poster?{src:t.poster}:t.poster:p(i),this._loadPlaylist(i)}},setVolume:{value:function(e){"image"!==this.currMediaType&&(0===e?(this.mute=!0,this.mediaEl.muted=!0,this.mediaEl.volume=0):(this.mute=!1,this.mediaEl.muted=!1,this.mediaEl.volume=e))}},setPlaybackRate:{value:function(e){"image"!==this.currMediaType&&(this.mediaEl.playbackRate=e||1)}},getMedia:{value:function(){return this.mediaEl}},getPlaylist:{value:function(){return this.playlist}},getItem:{value:function(e){return this.playlist[e]}},play:{value:function(e){this._seeking=!0,"number"==typeof e?this._playItem(this.playlist[e],e):"video"===this.currMediaType?this.mediaEl.play():this._slideshowTimer&&this._slideshowTimer.resume()}},pause:{value:function(){"video"===this.currMediaType?this.mediaEl.pause():this._slideshowTimer&&this._slideshowTimer.pause()}},close:{value:function(){this._removeAllListeners(),this._cleanup(),this._slideshowTimer&&(this._slideshowTimer.destroy(),delete this._slideshowTimer)}},currentTime:{value:function(){return"video"===this.currMediaType?this.mediaEl.currentTime:this._slideshowTimer.currentTime()}},seekTo:{value:function(e){this._seeking=!0,"video"===this.currMediaType&&(this.mediaEl.currentTime=e)}},duration:{value:function(){return"video"===this.currMediaType?this.mediaEl.duration:this.slideshowItemDuration}}}),t}(o);t.exports=y},{"./playlist":3,"./timer":4,"./utils":5,jvent:1}],3:[function(e,t){"use strict";function i(e){var t={},i={mp4:!0,ogv:!0,webm:!0},n={jpg:!0,png:!0,gif:!0},s=e.replace(/[\?|\#].+/,"").match(/\.([mp4|ogv|webm|jpg|jpeg|png|gif]+)$/)[1];return i[s]&&(t.type="ogv"===s?"video/ogg":"video/"+s),n[s]&&(t.type="jpg"===s?"image/jpeg":"image/"+s),t.src=e,t}function n(e,t){t=t||0;var s,r=[];for(var o in e)s=e[o],s.constructor===Object&&r.push([s]),s.constructor===Array&&r.push(n(s,t+1)),"string"==typeof s&&r.push(0===t?[i(s)]:i(s));return r}t.exports={makePlaylist:n,makePlaylistItem:i}},{}],4:[function(e,t){"use strict";var i=function(e){return e&&e.__esModule?e["default"]:e},n=function(){function e(e,t){for(var i in t){var n=t[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(e,t)}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)},r=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},o=i(e("jvent")),a=function(e){function t(e,i){r(this,t),this.callback=e,this.remaining=i,this.timerId=null,this.start=null,this.resume()}return s(t,e),n(t,{pause:{value:function(e){clearTimeout(this.timerId),this.remaining-=new Date-this.start,e||this.emit("pause")}},resume:{value:function(e){this.start=new Date,clearTimeout(this.timerId),this.timerId=setTimeout(this.callback,this.remaining),e||this.emit("resume")}},currentTime:{value:function(){var e=new Date-this.start;return this.timerId&&(this.pause(!0),this.resume(!0)),e}},destroy:{value:function(){this.pause(!0),this.removeAllListeners()}}}),t}(o);t.exports=a},{jvent:1}],5:[function(e,t){"use strict";function i(){return self.innerHeight?self.innerWidth:document.documentElement&&document.documentElement.clientWidth?document.documentElement.clientWidth:document.body?document.body.clientWidth:void 0}function n(){return self.innerHeight?self.innerHeight:document.documentElement&&document.documentElement.clientHeight?document.documentElement.clientHeight:document.body?document.body.clientHeight:void 0}function s(e,t){var i="";for(var n in t)i+=n+":"+t[n]+";";e.style.cssText+=";"+i}function r(e){var t,i;for(var n in e){if(i=e[n],i.constructor===Array)t=r(i);else if(i.type.search(/^image/)>-1)return i;if(t)return t}}function o(e,t){[].slice.call(e).forEach(t)}function a(e,t){var i=e.children||e.childNodes;i.length&&o(i,function(i){var n=t.shift();n?e.replaceChild(n,i):e.removeChild(i)}),t.length&&t.forEach(function(t){e.appendChild(t)})}function l(e,t){var i=document.createElement(e);for(var n in t)i[n]=t[n];return i}t.exports={getWidth:i,getHeight:n,setStyles:s,findPoster:r,eachNode:o,replaceChildren:a,createEl:l}},{}]},{},[2])(2)});

@@ -540,4 +540,6 @@ "use strict";

this.isTouch = options.isTouch !== undefined ? options.isTouch : "ontouchstart" in window || !!options.slideshow;
this.isTouch = options.isTouch !== undefined ? options.isTouch : "ontouchstart" in window;
this.slideshow = options.slideshow;
this.parentEl = this._setParent(options.el);

@@ -544,0 +546,0 @@ var mediaEl = this._createMediaEl();

@@ -30,3 +30,3 @@ "use strict";

value: function pause(silent) {
clearTimeout(timerId);
clearTimeout(this.timerId);
this.remaining -= new Date() - this.start;

@@ -33,0 +33,0 @@

{
"name": "drive-in",
"version": "1.4.1",
"version": "1.4.2",
"description": "Core library for React Drive-In",

@@ -38,2 +38,3 @@ "main": "index.js",

"scripts": {
"prepublish": "npm run build",
"build": "npm run build-drive-in; npm run build-drive-in-browser; npm run build-drive-in-browser-min;",

@@ -40,0 +41,0 @@ "build-drive-in": "babel src --out-dir lib",

@@ -517,4 +517,6 @@ import Jvent from 'jvent';

this.isTouch = options.isTouch !== undefined ?
options.isTouch : 'ontouchstart' in window || !!options.slideshow;
options.isTouch : 'ontouchstart' in window;
this.slideshow = options.slideshow;
this.parentEl = this._setParent(options.el);

@@ -521,0 +523,0 @@ var mediaEl = this._createMediaEl();

@@ -15,3 +15,3 @@ import Jvent from 'jvent';

pause(silent) {
clearTimeout(timerId);
clearTimeout(this.timerId);
this.remaining -= new Date() - this.start;

@@ -18,0 +18,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc