@odopod/odo-background-video
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,2 +0,2 @@ | ||
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("@odopod/odo-video"),require("@odopod/odo-window-events"),require("@odopod/odo-viewport"),require("@odopod/odo-object-fit"),require("@odopod/odo-responsive-images")):"function"==typeof define&&define.amd?define(["@odopod/odo-video","@odopod/odo-window-events","@odopod/odo-viewport","@odopod/odo-object-fit","@odopod/odo-responsive-images"],o):e.OdoBackgroundVideo=o(e.OdoVideo,e.OdoWindowEvents,e.OdoViewport,e.OdoObjectFit,e.OdoResponsiveImages)}(this,function(e,o,t,i,n){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,o=o&&o.hasOwnProperty("default")?o.default:o,t=t&&t.hasOwnProperty("default")?t.default:t,i=i&&i.hasOwnProperty("default")?i.default:i,n=n&&n.hasOwnProperty("default")?n.default:n;var d=function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")},s=function(){function e(e,o){for(var t=0;t<o.length;t++){var i=o[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(o,t,i){return t&&e(o.prototype,t),i&&e(o,i),o}}();return function(){function r(t){var i=this;d(this,r),this.element=t,this._odoVideoElement=this.element.querySelector(".odo-video"),this._odoImageElement=this.element.querySelector(".odo-background-video__fallback-img"),this.isVideo=null,this.ready=new Promise(function(e){i._resolve=e}),this._odoVideoElement?e.autoplay.then(this._handleAutoplayResult.bind(this)):this._cannotAutoplay(),this._resizeId=o.onResize(this._handleResize.bind(this))}return r.prototype._handleAutoplayResult=function(e){e?this._canAutoplay():this._cannotAutoplay()},r.prototype._canAutoplay=function(){function o(){this.removeEventListener("loadedmetadata",o),this.removeEventListener("error",o),n._ready()}this._odoVideoElement.classList.remove("hidden"),this._video=new e(this._odoVideoElement,{controls:e.Controls.NONE,pauseOnClick:!1}),this._viewportId=t.add({element:this._odoVideoElement,threshold:"20%",enter:this._play.bind(this),exit:this._pause.bind(this)});var n=this,d=this._video.getVideoElement();d.addEventListener("loadedmetadata",o),d.addEventListener("error",o),this._video.listenOnData(e.VideoEvents.LOADED_DATA,this._showFirstFrame.bind(this)),this.isVideo=!0,i.cover(d)},r.prototype._cannotAutoplay=function(){function e(){this.removeEventListener("load",e),this.removeEventListener("error",e),t._ready()}var o=this._odoImageElement.querySelector("img");this._odoImageElement.classList.add("odo-responsive-img"),this._odoImageElement.classList.remove("hidden"),n.add(this._odoImageElement);var t=this;o.addEventListener("load",e),o.addEventListener("error",e),this.isVideo=!1,i.cover(o)},r.prototype._play=function(){this._video.play()},r.prototype._pause=function(){this._video.pause()},r.prototype._ready=function(){this._resolve()},r.prototype._showFirstFrame=function(){this._video.isPlaying||(this._video.getVideoElement().currentTime=0)},r.prototype._handleResize=function(){i.cover(this.mediaElement)},r.prototype.dispose=function(){o.remove(this._resizeId),this._resizeId=null,this._video&&(this._video.dispose(),t.remove(this._viewportId),this._viewportId=null,this.isVideo=null)},s(r,[{key:"videoElement",get:function(){return this._odoVideoElement}},{key:"imageElement",get:function(){return this._odoImageElement}},{key:"mediaElement",get:function(){return this.isVideo?this._video.getVideoElement():this._odoImageElement.querySelector("img")}}]),r}()}); | ||
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("@odopod/odo-video"),require("@odopod/odo-window-events"),require("@odopod/odo-viewport"),require("@odopod/odo-object-fit"),require("@odopod/odo-responsive-images")):"function"==typeof define&&define.amd?define(["@odopod/odo-video","@odopod/odo-window-events","@odopod/odo-viewport","@odopod/odo-object-fit","@odopod/odo-responsive-images"],o):e.OdoBackgroundVideo=o(e.OdoVideo,e.OdoWindowEvents,e.OdoViewport,e.OdoObjectFit,e.OdoResponsiveImages)}(this,function(e,o,t,i,n){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,o=o&&o.hasOwnProperty("default")?o.default:o,t=t&&t.hasOwnProperty("default")?t.default:t,i=i&&i.hasOwnProperty("default")?i.default:i,n=n&&n.hasOwnProperty("default")?n.default:n;var d=function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")},s=function(){function e(e,o){for(var t=0;t<o.length;t++){var i=o[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(o,t,i){return t&&e(o.prototype,t),i&&e(o,i),o}}();return function(){function r(t){var i=this;d(this,r),this.element=t,this._odoVideoElement=this.element.querySelector(".odo-video"),this._odoImageElement=this.element.querySelector(".odo-background-video__fallback-img"),this.isVideo=null,this.ready=new Promise(function(e){i._resolve=e}),this._odoVideoElement?e.autoplay.then(this._handleAutoplayResult.bind(this)):this._cannotAutoplay(),this._resizeId=o.onResize(this._handleResize.bind(this))}return r.prototype._handleAutoplayResult=function(e){e?this._canAutoplay():this._cannotAutoplay()},r.prototype._canAutoplay=function(){this._odoVideoElement.classList.remove("hidden"),this._video=new e(this._odoVideoElement,{controls:e.Controls.NONE,pauseOnClick:!1}),this._viewportId=t.add({element:this._odoVideoElement,threshold:"20%",enter:this._play.bind(this),exit:this._pause.bind(this)});var o=this;function n(){this.removeEventListener("loadedmetadata",n),this.removeEventListener("error",n),o._ready()}var d=this._video.getVideoElement();d.addEventListener("loadedmetadata",n),d.addEventListener("error",n),this._video.listenOnData(e.VideoEvents.LOADED_DATA,this._showFirstFrame.bind(this)),this.isVideo=!0,i.cover(d)},r.prototype._cannotAutoplay=function(){var e=this._odoImageElement.querySelector("img");this._odoImageElement.classList.add("odo-responsive-img"),this._odoImageElement.classList.remove("hidden"),n.add(this._odoImageElement);var o=this;function t(){this.removeEventListener("load",t),this.removeEventListener("error",t),o._ready()}e.addEventListener("load",t),e.addEventListener("error",t),this.isVideo=!1,i.cover(e)},r.prototype._play=function(){this._video.play()},r.prototype._pause=function(){this._video.pause()},r.prototype._ready=function(){this._resolve()},r.prototype._showFirstFrame=function(){this._video.isPlaying||(this._video.getVideoElement().currentTime=0)},r.prototype._handleResize=function(){i.cover(this.mediaElement)},r.prototype.dispose=function(){o.remove(this._resizeId),this._resizeId=null,this._video&&(this._video.dispose(),t.remove(this._viewportId),this._viewportId=null,this.isVideo=null)},s(r,[{key:"videoElement",get:function(){return this._odoVideoElement}},{key:"imageElement",get:function(){return this._odoImageElement}},{key:"mediaElement",get:function(){return this.isVideo?this._video.getVideoElement():this._odoImageElement.querySelector("img")}}]),r}()}); | ||
//# sourceMappingURL=odo-background-video.min.js.map |
{ | ||
"name": "@odopod/odo-background-video", | ||
"description": "Plays in the background when the element comes into view and falls back to an image if the browser cannot autoplay video.", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"main": "dist/odo-background-video.js", | ||
@@ -16,7 +16,7 @@ "style": "css/odo-background-video.css", | ||
"dependencies": { | ||
"@odopod/odo-object-fit": "^1.0.2", | ||
"@odopod/odo-responsive-images": "^1.0.2", | ||
"@odopod/odo-video": "^1.1.0", | ||
"@odopod/odo-viewport": "^1.0.2", | ||
"@odopod/odo-window-events": "^1.0.2" | ||
"@odopod/odo-object-fit": "^1.0.3", | ||
"@odopod/odo-responsive-images": "^1.0.3", | ||
"@odopod/odo-video": "^1.1.1", | ||
"@odopod/odo-viewport": "^1.0.3", | ||
"@odopod/odo-window-events": "^1.0.3" | ||
}, | ||
@@ -40,3 +40,3 @@ "homepage": "https://github.com/odopod/code-library/tree/master/packages/odo-background-video", | ||
"license": "MIT", | ||
"repository": "odopod/odo", | ||
"repository": "odopod/code-library", | ||
"scripts": { | ||
@@ -43,0 +43,0 @@ "test": "gulp code-quality test" |
@@ -23,2 +23,2 @@ # Odo Background Video | ||
[permalink]: https://code.odopod.com/odo-background-video/ | ||
[permalink]: http://code.odopod.com/odo-background-video/ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
32889