{"version":3,"file":"jarallax-video.min.js","sources":["../node_modules/video-worker/dist/video-worker.esm.js","../src/utils/global.js","../src/utils/ready.js","../src/ext-video.js","../src/ext-video.umd.js"],"sourcesContent":["/*!\n * Name : Video Worker\n * Version : 2.0.0\n * Author : nK \n * GitHub : https://github.com/nk-o/video-worker\n */\n\n/* eslint-disable import/no-mutable-exports */\n\n/* eslint-disable no-restricted-globals */\nlet win;\n\nif (typeof window !== 'undefined') {\n win = window;\n} else if (typeof global !== 'undefined') {\n win = global;\n} else if (typeof self !== 'undefined') {\n win = self;\n} else {\n win = {};\n}\n\nvar global$1 = win;\n\n// Deferred\n// thanks http://stackoverflow.com/questions/18096715/implement-deferred-object-without-using-jquery\nfunction Deferred() {\n this.doneCallbacks = [];\n this.failCallbacks = [];\n}\n\nDeferred.prototype = {\n execute(list, args) {\n let i = list.length; // eslint-disable-next-line no-param-reassign\n\n args = Array.prototype.slice.call(args);\n\n while (i) {\n i -= 1;\n list[i].apply(null, args);\n }\n },\n\n resolve(...args) {\n this.execute(this.doneCallbacks, args);\n },\n\n reject(...args) {\n this.execute(this.failCallbacks, args);\n },\n\n done(callback) {\n this.doneCallbacks.push(callback);\n },\n\n fail(callback) {\n this.failCallbacks.push(callback);\n }\n\n};\n\nlet ID = 0;\nlet YoutubeAPIadded = 0;\nlet VimeoAPIadded = 0;\nlet loadingYoutubePlayer = 0;\nlet loadingVimeoPlayer = 0;\nconst loadingYoutubeDefer = /*#__PURE__*/new Deferred();\nconst loadingVimeoDefer = /*#__PURE__*/new Deferred();\n\nclass VideoWorker {\n constructor(url, options) {\n const self = this;\n self.url = url;\n self.options_default = {\n autoplay: false,\n loop: false,\n mute: false,\n volume: 100,\n showControls: true,\n accessibilityHidden: false,\n // start / end video time in seconds\n startTime: 0,\n endTime: 0\n };\n self.options = self.extend({}, self.options_default, options); // Fix wrong option name.\n // Thanks to https://github.com/nk-o/video-worker/issues/13.\n\n if (typeof self.options.showContols !== 'undefined') {\n self.options.showControls = self.options.showContols;\n delete self.options.showContols;\n } // check URL\n\n\n self.videoID = self.parseURL(url); // init\n\n if (self.videoID) {\n self.ID = ID;\n ID += 1;\n self.loadAPI();\n self.init();\n }\n } // Extend like jQuery.extend\n // eslint-disable-next-line class-methods-use-this\n\n\n extend(...args) {\n const out = args[0] || {};\n Object.keys(args).forEach(i => {\n if (!args[i]) {\n return;\n }\n\n Object.keys(args[i]).forEach(key => {\n out[key] = args[i][key];\n });\n });\n return out;\n }\n\n parseURL(url) {\n // parse youtube ID\n function getYoutubeID(ytUrl) {\n // eslint-disable-next-line no-useless-escape\n const regExp = /.*(?:youtu.be\\/|v\\/|u\\/\\w\\/|embed\\/|watch\\?v=)([^#\\&\\?]*).*/;\n const match = ytUrl.match(regExp);\n return match && match[1].length === 11 ? match[1] : false;\n } // parse vimeo ID\n\n\n function getVimeoID(vmUrl) {\n // eslint-disable-next-line no-useless-escape\n const regExp = /https?:\\/\\/(?:www\\.|player\\.)?vimeo.com\\/(?:channels\\/(?:\\w+\\/)?|groups\\/([^/]*)\\/videos\\/|album\\/(\\d+)\\/video\\/|video\\/|)(\\d+)(?:$|\\/|\\?)/;\n const match = vmUrl.match(regExp);\n return match && match[3] ? match[3] : false;\n } // parse local string\n\n\n function getLocalVideos(locUrl) {\n // eslint-disable-next-line no-useless-escape\n const videoFormats = locUrl.split(/,(?=mp4\\:|webm\\:|ogv\\:|ogg\\:)/);\n const result = {};\n let ready = 0;\n videoFormats.forEach(val => {\n // eslint-disable-next-line no-useless-escape\n const match = val.match(/^(mp4|webm|ogv|ogg)\\:(.*)/);\n\n if (match && match[1] && match[2]) {\n // eslint-disable-next-line prefer-destructuring\n result[match[1] === 'ogv' ? 'ogg' : match[1]] = match[2];\n ready = 1;\n }\n });\n return ready ? result : false;\n }\n\n const Youtube = getYoutubeID(url);\n const Vimeo = getVimeoID(url);\n const Local = getLocalVideos(url);\n\n if (Youtube) {\n this.type = 'youtube';\n return Youtube;\n }\n\n if (Vimeo) {\n this.type = 'vimeo';\n return Vimeo;\n }\n\n if (Local) {\n this.type = 'local';\n return Local;\n }\n\n return false;\n }\n\n isValid() {\n return !!this.videoID;\n } // events\n\n\n on(name, callback) {\n this.userEventsList = this.userEventsList || []; // add new callback in events list\n\n (this.userEventsList[name] || (this.userEventsList[name] = [])).push(callback);\n }\n\n off(name, callback) {\n if (!this.userEventsList || !this.userEventsList[name]) {\n return;\n }\n\n if (!callback) {\n delete this.userEventsList[name];\n } else {\n this.userEventsList[name].forEach((val, key) => {\n if (val === callback) {\n this.userEventsList[name][key] = false;\n }\n });\n }\n }\n\n fire(name, ...args) {\n if (this.userEventsList && typeof this.userEventsList[name] !== 'undefined') {\n this.userEventsList[name].forEach(val => {\n // call with all arguments\n if (val) {\n val.apply(this, args);\n }\n });\n }\n }\n\n play(start) {\n const self = this;\n\n if (!self.player) {\n return;\n }\n\n if (self.type === 'youtube' && self.player.playVideo) {\n if (typeof start !== 'undefined') {\n self.player.seekTo(start || 0);\n }\n\n if (global$1.YT.PlayerState.PLAYING !== self.player.getPlayerState()) {\n self.player.playVideo();\n }\n }\n\n if (self.type === 'vimeo') {\n if (typeof start !== 'undefined') {\n self.player.setCurrentTime(start);\n }\n\n self.player.getPaused().then(paused => {\n if (paused) {\n self.player.play();\n }\n });\n }\n\n if (self.type === 'local') {\n if (typeof start !== 'undefined') {\n self.player.currentTime = start;\n }\n\n if (self.player.paused) {\n self.player.play();\n }\n }\n }\n\n pause() {\n const self = this;\n\n if (!self.player) {\n return;\n }\n\n if (self.type === 'youtube' && self.player.pauseVideo) {\n if (global$1.YT.PlayerState.PLAYING === self.player.getPlayerState()) {\n self.player.pauseVideo();\n }\n }\n\n if (self.type === 'vimeo') {\n self.player.getPaused().then(paused => {\n if (!paused) {\n self.player.pause();\n }\n });\n }\n\n if (self.type === 'local') {\n if (!self.player.paused) {\n self.player.pause();\n }\n }\n }\n\n mute() {\n const self = this;\n\n if (!self.player) {\n return;\n }\n\n if (self.type === 'youtube' && self.player.mute) {\n self.player.mute();\n }\n\n if (self.type === 'vimeo' && self.player.setVolume) {\n self.player.setVolume(0);\n }\n\n if (self.type === 'local') {\n self.$video.muted = true;\n }\n }\n\n unmute() {\n const self = this;\n\n if (!self.player) {\n return;\n }\n\n if (self.type === 'youtube' && self.player.mute) {\n self.player.unMute();\n }\n\n if (self.type === 'vimeo' && self.player.setVolume) {\n self.player.setVolume(self.options.volume);\n }\n\n if (self.type === 'local') {\n self.$video.muted = false;\n }\n }\n\n setVolume(volume = false) {\n const self = this;\n\n if (!self.player || !volume) {\n return;\n }\n\n if (self.type === 'youtube' && self.player.setVolume) {\n self.player.setVolume(volume);\n }\n\n if (self.type === 'vimeo' && self.player.setVolume) {\n self.player.setVolume(volume);\n }\n\n if (self.type === 'local') {\n self.$video.volume = volume / 100;\n }\n }\n\n getVolume(callback) {\n const self = this;\n\n if (!self.player) {\n callback(false);\n return;\n }\n\n if (self.type === 'youtube' && self.player.getVolume) {\n callback(self.player.getVolume());\n }\n\n if (self.type === 'vimeo' && self.player.getVolume) {\n self.player.getVolume().then(volume => {\n callback(volume);\n });\n }\n\n if (self.type === 'local') {\n callback(self.$video.volume * 100);\n }\n }\n\n getMuted(callback) {\n const self = this;\n\n if (!self.player) {\n callback(null);\n return;\n }\n\n if (self.type === 'youtube' && self.player.isMuted) {\n callback(self.player.isMuted());\n }\n\n if (self.type === 'vimeo' && self.player.getVolume) {\n self.player.getVolume().then(volume => {\n callback(!!volume);\n });\n }\n\n if (self.type === 'local') {\n callback(self.$video.muted);\n }\n }\n\n getImageURL(callback) {\n const self = this;\n\n if (self.videoImage) {\n callback(self.videoImage);\n return;\n }\n\n if (self.type === 'youtube') {\n const availableSizes = ['maxresdefault', 'sddefault', 'hqdefault', '0'];\n let step = 0;\n const tempImg = new Image();\n\n tempImg.onload = function () {\n // if no thumbnail, youtube add their own image with width = 120px\n if ((this.naturalWidth || this.width) !== 120 || step === availableSizes.length - 1) {\n // ok\n self.videoImage = `https://img.youtube.com/vi/${self.videoID}/${availableSizes[step]}.jpg`;\n callback(self.videoImage);\n } else {\n // try another size\n step += 1;\n this.src = `https://img.youtube.com/vi/${self.videoID}/${availableSizes[step]}.jpg`;\n }\n };\n\n tempImg.src = `https://img.youtube.com/vi/${self.videoID}/${availableSizes[step]}.jpg`;\n }\n\n if (self.type === 'vimeo') {\n let request = new XMLHttpRequest(); // https://vimeo.com/api/oembed.json?url=https://vimeo.com/235212527\n\n request.open('GET', `https://vimeo.com/api/oembed.json?url=${self.url}`, true);\n\n request.onreadystatechange = function () {\n if (this.readyState === 4) {\n if (this.status >= 200 && this.status < 400) {\n // Success!\n const response = JSON.parse(this.responseText);\n\n if (response.thumbnail_url) {\n self.videoImage = response.thumbnail_url;\n callback(self.videoImage);\n }\n }\n }\n };\n\n request.send();\n request = null;\n }\n } // fallback to the old version.\n\n\n getIframe(callback) {\n this.getVideo(callback);\n }\n\n getVideo(callback) {\n const self = this; // return generated video block\n\n if (self.$video) {\n callback(self.$video);\n return;\n } // generate new video block\n\n\n self.onAPIready(() => {\n let hiddenDiv;\n\n if (!self.$video) {\n hiddenDiv = document.createElement('div');\n hiddenDiv.style.display = 'none';\n } // Youtube\n\n\n if (self.type === 'youtube') {\n self.playerOptions = {\n // GDPR Compliance.\n host: 'https://www.youtube-nocookie.com',\n videoId: self.videoID,\n playerVars: {\n autohide: 1,\n rel: 0,\n autoplay: 0,\n // autoplay enable on mobile devices\n playsinline: 1\n }\n }; // hide controls\n\n if (!self.options.showControls) {\n self.playerOptions.playerVars.iv_load_policy = 3;\n self.playerOptions.playerVars.modestbranding = 1;\n self.playerOptions.playerVars.controls = 0;\n self.playerOptions.playerVars.showinfo = 0;\n self.playerOptions.playerVars.disablekb = 1;\n } // events\n\n\n let ytStarted;\n let ytProgressInterval;\n self.playerOptions.events = {\n onReady(e) {\n // mute\n if (self.options.mute) {\n e.target.mute();\n } else if (self.options.volume) {\n e.target.setVolume(self.options.volume);\n } // autoplay\n\n\n if (self.options.autoplay) {\n self.play(self.options.startTime);\n }\n\n self.fire('ready', e); // For seamless loops, set the endTime to 0.1 seconds less than the video's duration\n // https://github.com/nk-o/video-worker/issues/2\n\n if (self.options.loop && !self.options.endTime) {\n const secondsOffset = 0.1;\n self.options.endTime = self.player.getDuration() - secondsOffset;\n } // volumechange\n\n\n setInterval(() => {\n self.getVolume(volume => {\n if (self.options.volume !== volume) {\n self.options.volume = volume;\n self.fire('volumechange', e);\n }\n });\n }, 150);\n },\n\n onStateChange(e) {\n // loop\n if (self.options.loop && e.data === global$1.YT.PlayerState.ENDED) {\n self.play(self.options.startTime);\n }\n\n if (!ytStarted && e.data === global$1.YT.PlayerState.PLAYING) {\n ytStarted = 1;\n self.fire('started', e);\n }\n\n if (e.data === global$1.YT.PlayerState.PLAYING) {\n self.fire('play', e);\n }\n\n if (e.data === global$1.YT.PlayerState.PAUSED) {\n self.fire('pause', e);\n }\n\n if (e.data === global$1.YT.PlayerState.ENDED) {\n self.fire('ended', e);\n } // progress check\n\n\n if (e.data === global$1.YT.PlayerState.PLAYING) {\n ytProgressInterval = setInterval(() => {\n self.fire('timeupdate', e); // check for end of video and play again or stop\n\n if (self.options.endTime && self.player.getCurrentTime() >= self.options.endTime) {\n if (self.options.loop) {\n self.play(self.options.startTime);\n } else {\n self.pause();\n }\n }\n }, 150);\n } else {\n clearInterval(ytProgressInterval);\n }\n },\n\n onError(e) {\n self.fire('error', e);\n }\n\n };\n const firstInit = !self.$video;\n\n if (firstInit) {\n const div = document.createElement('div');\n div.setAttribute('id', self.playerID);\n hiddenDiv.appendChild(div);\n document.body.appendChild(hiddenDiv);\n }\n\n self.player = self.player || new global$1.YT.Player(self.playerID, self.playerOptions);\n\n if (firstInit) {\n self.$video = document.getElementById(self.playerID); // add accessibility attributes\n\n if (self.options.accessibilityHidden) {\n self.$video.setAttribute('tabindex', '-1');\n self.$video.setAttribute('aria-hidden', 'true');\n } // get video width and height\n\n\n self.videoWidth = parseInt(self.$video.getAttribute('width'), 10) || 1280;\n self.videoHeight = parseInt(self.$video.getAttribute('height'), 10) || 720;\n }\n } // Vimeo\n\n\n if (self.type === 'vimeo') {\n self.playerOptions = {\n // GDPR Compliance.\n dnt: 1,\n id: self.videoID,\n autopause: 0,\n transparent: 0,\n autoplay: self.options.autoplay ? 1 : 0,\n loop: self.options.loop ? 1 : 0,\n muted: self.options.mute ? 1 : 0\n };\n\n if (self.options.volume) {\n self.playerOptions.volume = self.options.volume;\n } // hide controls\n\n\n if (!self.options.showControls) {\n self.playerOptions.badge = 0;\n self.playerOptions.byline = 0;\n self.playerOptions.portrait = 0;\n self.playerOptions.title = 0;\n self.playerOptions.background = 1;\n }\n\n if (!self.$video) {\n let playerOptionsString = '';\n Object.keys(self.playerOptions).forEach(key => {\n if (playerOptionsString !== '') {\n playerOptionsString += '&';\n }\n\n playerOptionsString += `${key}=${encodeURIComponent(self.playerOptions[key])}`;\n }); // we need to create iframe manually because when we create it using API\n // js events won't triggers after iframe moved to another place\n\n self.$video = document.createElement('iframe');\n self.$video.setAttribute('id', self.playerID);\n self.$video.setAttribute('src', `https://player.vimeo.com/video/${self.videoID}?${playerOptionsString}`);\n self.$video.setAttribute('frameborder', '0');\n self.$video.setAttribute('mozallowfullscreen', '');\n self.$video.setAttribute('allowfullscreen', '');\n self.$video.setAttribute('title', 'Vimeo video player'); // add accessibility attributes\n\n if (self.options.accessibilityHidden) {\n self.$video.setAttribute('tabindex', '-1');\n self.$video.setAttribute('aria-hidden', 'true');\n }\n\n hiddenDiv.appendChild(self.$video);\n document.body.appendChild(hiddenDiv);\n }\n\n self.player = self.player || new global$1.Vimeo.Player(self.$video, self.playerOptions); // set current time for autoplay\n\n if (self.options.startTime && self.options.autoplay) {\n self.player.setCurrentTime(self.options.startTime);\n } // get video width and height\n\n\n self.player.getVideoWidth().then(width => {\n self.videoWidth = width || 1280;\n });\n self.player.getVideoHeight().then(height => {\n self.videoHeight = height || 720;\n }); // events\n\n let vmStarted;\n self.player.on('timeupdate', e => {\n if (!vmStarted) {\n self.fire('started', e);\n vmStarted = 1;\n }\n\n self.fire('timeupdate', e); // check for end of video and play again or stop\n\n if (self.options.endTime) {\n if (self.options.endTime && e.seconds >= self.options.endTime) {\n if (self.options.loop) {\n self.play(self.options.startTime);\n } else {\n self.pause();\n }\n }\n }\n });\n self.player.on('play', e => {\n self.fire('play', e); // check for the start time and start with it\n\n if (self.options.startTime && e.seconds === 0) {\n self.play(self.options.startTime);\n }\n });\n self.player.on('pause', e => {\n self.fire('pause', e);\n });\n self.player.on('ended', e => {\n self.fire('ended', e);\n });\n self.player.on('loaded', e => {\n self.fire('ready', e);\n });\n self.player.on('volumechange', e => {\n self.fire('volumechange', e);\n });\n self.player.on('error', e => {\n self.fire('error', e);\n });\n } // Local\n\n\n function addSourceToLocal(element, src, type) {\n const source = document.createElement('source');\n source.src = src;\n source.type = type;\n element.appendChild(source);\n }\n\n if (self.type === 'local') {\n if (!self.$video) {\n self.$video = document.createElement('video'); // show controls\n\n if (self.options.showControls) {\n self.$video.controls = true;\n } // mute\n\n\n if (self.options.mute) {\n self.$video.muted = true;\n } else if (self.$video.volume) {\n self.$video.volume = self.options.volume / 100;\n } // loop\n\n\n if (self.options.loop) {\n self.$video.loop = true;\n } // autoplay enable on mobile devices\n\n\n self.$video.setAttribute('playsinline', '');\n self.$video.setAttribute('webkit-playsinline', ''); // add accessibility attributes\n\n if (self.options.accessibilityHidden) {\n self.$video.setAttribute('tabindex', '-1');\n self.$video.setAttribute('aria-hidden', 'true');\n }\n\n self.$video.setAttribute('id', self.playerID);\n hiddenDiv.appendChild(self.$video);\n document.body.appendChild(hiddenDiv);\n Object.keys(self.videoID).forEach(key => {\n addSourceToLocal(self.$video, self.videoID[key], `video/${key}`);\n });\n }\n\n self.player = self.player || self.$video;\n let locStarted;\n self.player.addEventListener('playing', e => {\n if (!locStarted) {\n self.fire('started', e);\n }\n\n locStarted = 1;\n });\n self.player.addEventListener('timeupdate', function (e) {\n self.fire('timeupdate', e); // check for end of video and play again or stop\n\n if (self.options.endTime) {\n if (self.options.endTime && this.currentTime >= self.options.endTime) {\n if (self.options.loop) {\n self.play(self.options.startTime);\n } else {\n self.pause();\n }\n }\n }\n });\n self.player.addEventListener('play', e => {\n self.fire('play', e);\n });\n self.player.addEventListener('pause', e => {\n self.fire('pause', e);\n });\n self.player.addEventListener('ended', e => {\n self.fire('ended', e);\n });\n self.player.addEventListener('loadedmetadata', function () {\n // get video width and height\n self.videoWidth = this.videoWidth || 1280;\n self.videoHeight = this.videoHeight || 720;\n self.fire('ready'); // autoplay\n\n if (self.options.autoplay) {\n self.play(self.options.startTime);\n }\n });\n self.player.addEventListener('volumechange', e => {\n self.getVolume(volume => {\n self.options.volume = volume;\n });\n self.fire('volumechange', e);\n });\n self.player.addEventListener('error', e => {\n self.fire('error', e);\n });\n }\n\n callback(self.$video);\n });\n }\n\n init() {\n const self = this;\n self.playerID = `VideoWorker-${self.ID}`;\n }\n\n loadAPI() {\n const self = this;\n\n if (YoutubeAPIadded && VimeoAPIadded) {\n return;\n }\n\n let src = ''; // load Youtube API\n\n if (self.type === 'youtube' && !YoutubeAPIadded) {\n YoutubeAPIadded = 1;\n src = 'https://www.youtube.com/iframe_api';\n } // load Vimeo API\n\n\n if (self.type === 'vimeo' && !VimeoAPIadded) {\n VimeoAPIadded = 1; // Useful when Vimeo API added using RequireJS https://github.com/nk-o/video-worker/pull/7\n\n if (typeof global$1.Vimeo !== 'undefined') {\n return;\n }\n\n src = 'https://player.vimeo.com/api/player.js';\n }\n\n if (!src) {\n return;\n } // add script in head section\n\n\n let tag = document.createElement('script');\n let head = document.getElementsByTagName('head')[0];\n tag.src = src;\n head.appendChild(tag);\n head = null;\n tag = null;\n }\n\n onAPIready(callback) {\n const self = this; // Youtube\n\n if (self.type === 'youtube') {\n // Listen for global YT player callback\n if ((typeof global$1.YT === 'undefined' || global$1.YT.loaded === 0) && !loadingYoutubePlayer) {\n // Prevents Ready event from being called twice\n loadingYoutubePlayer = 1; // Creates deferred so, other players know when to wait.\n\n global$1.onYouTubeIframeAPIReady = function () {\n global$1.onYouTubeIframeAPIReady = null;\n loadingYoutubeDefer.resolve('done');\n callback();\n };\n } else if (typeof global$1.YT === 'object' && global$1.YT.loaded === 1) {\n callback();\n } else {\n loadingYoutubeDefer.done(() => {\n callback();\n });\n }\n } // Vimeo\n\n\n if (self.type === 'vimeo') {\n if (typeof global$1.Vimeo === 'undefined' && !loadingVimeoPlayer) {\n loadingVimeoPlayer = 1;\n const vimeoInterval = setInterval(() => {\n if (typeof global$1.Vimeo !== 'undefined') {\n clearInterval(vimeoInterval);\n loadingVimeoDefer.resolve('done');\n callback();\n }\n }, 20);\n } else if (typeof global$1.Vimeo !== 'undefined') {\n callback();\n } else {\n loadingVimeoDefer.done(() => {\n callback();\n });\n }\n } // Local\n\n\n if (self.type === 'local') {\n callback();\n }\n }\n\n}\n\nexport { VideoWorker as default };\n//# sourceMappingURL=video-worker.esm.js.map\n","/* eslint-disable import/no-mutable-exports */\n/* eslint-disable no-restricted-globals */\nlet win;\n\nif ('undefined' !== typeof window) {\n win = window;\n} else if ('undefined' !== typeof global) {\n win = global;\n} else if ('undefined' !== typeof self) {\n win = self;\n} else {\n win = {};\n}\n\nexport default win;\n","function ready(callback) {\n if ('complete' === document.readyState || 'interactive' === document.readyState) {\n // Already ready or interactive, execute callback\n callback();\n } else {\n document.addEventListener('DOMContentLoaded', callback, {\n capture: true,\n once: true,\n passive: true,\n });\n }\n}\n\nexport default ready;\n","import VideoWorker from 'video-worker';\n\nimport global from './utils/global';\n\nfunction jarallaxVideo(jarallax = global.jarallax) {\n if ('undefined' === typeof jarallax) {\n return;\n }\n\n const Jarallax = jarallax.constructor;\n\n // append video after when block will be visible.\n const defOnScroll = Jarallax.prototype.onScroll;\n Jarallax.prototype.onScroll = function () {\n const self = this;\n\n defOnScroll.apply(self);\n\n const isReady =\n !self.isVideoInserted &&\n self.video &&\n (!self.options.videoLazyLoading || self.isElementInViewport) &&\n !self.options.disableVideo();\n\n if (isReady) {\n self.isVideoInserted = true;\n\n self.video.getVideo((video) => {\n const $parent = video.parentNode;\n self.css(video, {\n position: self.image.position,\n top: '0px',\n left: '0px',\n right: '0px',\n bottom: '0px',\n width: '100%',\n height: '100%',\n maxWidth: 'none',\n maxHeight: 'none',\n pointerEvents: 'none',\n transformStyle: 'preserve-3d',\n backfaceVisibility: 'hidden',\n willChange: 'transform,opacity',\n margin: 0,\n zIndex: -1,\n });\n self.$video = video;\n\n // add Poster attribute to self-hosted video\n if ('local' === self.video.type) {\n if (self.image.src) {\n self.$video.setAttribute('poster', self.image.src);\n } else if (\n self.image.$item &&\n 'IMG' === self.image.$item.tagName &&\n self.image.$item.src\n ) {\n self.$video.setAttribute('poster', self.image.$item.src);\n }\n }\n\n // insert video tag\n self.image.$container.appendChild(video);\n\n // remove parent video element (created by VideoWorker)\n $parent.parentNode.removeChild($parent);\n\n // call onVideoInsert event\n if (self.options.onVideoInsert) {\n self.options.onVideoInsert.call(self);\n }\n });\n }\n };\n\n // cover video\n const defCoverImage = Jarallax.prototype.coverImage;\n Jarallax.prototype.coverImage = function () {\n const self = this;\n const imageData = defCoverImage.apply(self);\n const node = self.image.$item ? self.image.$item.nodeName : false;\n\n if (imageData && self.video && node && ('IFRAME' === node || 'VIDEO' === node)) {\n let h = imageData.image.height;\n let w = (h * self.image.width) / self.image.height;\n let ml = (imageData.container.width - w) / 2;\n let mt = imageData.image.marginTop;\n\n if (imageData.container.width > w) {\n w = imageData.container.width;\n h = (w * self.image.height) / self.image.width;\n ml = 0;\n mt += (imageData.image.height - h) / 2;\n }\n\n // add video height over than need to hide controls\n if ('IFRAME' === node) {\n h += 400;\n mt -= 200;\n }\n\n self.css(self.$video, {\n width: `${w}px`,\n marginLeft: `${ml}px`,\n height: `${h}px`,\n marginTop: `${mt}px`,\n });\n }\n\n return imageData;\n };\n\n // init video\n const defInitImg = Jarallax.prototype.initImg;\n Jarallax.prototype.initImg = function () {\n const self = this;\n const defaultResult = defInitImg.apply(self);\n\n if (!self.options.videoSrc) {\n self.options.videoSrc = self.$item.getAttribute('data-jarallax-video') || null;\n }\n\n if (self.options.videoSrc) {\n self.defaultInitImgResult = defaultResult;\n return true;\n }\n\n return defaultResult;\n };\n\n const defCanInitParallax = Jarallax.prototype.canInitParallax;\n Jarallax.prototype.canInitParallax = function () {\n const self = this;\n let defaultResult = defCanInitParallax.apply(self);\n\n if (!self.options.videoSrc) {\n return defaultResult;\n }\n\n // Init video api\n const video = new VideoWorker(self.options.videoSrc, {\n autoplay: true,\n loop: self.options.videoLoop,\n showControls: false,\n accessibilityHidden: true,\n startTime: self.options.videoStartTime || 0,\n endTime: self.options.videoEndTime || 0,\n mute: self.options.videoVolume ? 0 : 1,\n volume: self.options.videoVolume || 0,\n });\n\n // call onVideoWorkerInit event\n if (self.options.onVideoWorkerInit) {\n self.options.onVideoWorkerInit.call(self, video);\n }\n\n function resetDefaultImage() {\n if (self.image.$default_item) {\n self.image.$item = self.image.$default_item;\n self.image.$item.style.display = 'block';\n\n // set image width and height\n self.coverImage();\n self.onScroll();\n }\n }\n\n if (video.isValid()) {\n // Force enable parallax.\n // When the parallax disabled on mobile devices, we still need to display videos.\n // https://github.com/nk-o/jarallax/issues/159\n if (this.options.disableParallax()) {\n defaultResult = true;\n self.image.position = 'absolute';\n self.options.type = 'scroll';\n self.options.speed = 1;\n }\n\n // if parallax will not be inited, we can add thumbnail on background.\n if (!defaultResult) {\n if (!self.defaultInitImgResult) {\n video.getImageURL((url) => {\n // save default user styles\n const curStyle = self.$item.getAttribute('style');\n if (curStyle) {\n self.$item.setAttribute('data-jarallax-original-styles', curStyle);\n }\n\n // set new background\n self.css(self.$item, {\n 'background-image': `url(\"${url}\")`,\n 'background-position': 'center',\n 'background-size': 'cover',\n });\n });\n }\n\n // init video\n } else {\n video.on('ready', () => {\n if (self.options.videoPlayOnlyVisible) {\n const oldOnScroll = self.onScroll;\n self.onScroll = function () {\n oldOnScroll.apply(self);\n if (\n !self.videoError &&\n (self.options.videoLoop || (!self.options.videoLoop && !self.videoEnded))\n ) {\n if (self.isVisible()) {\n video.play();\n } else {\n video.pause();\n }\n }\n };\n } else {\n video.play();\n }\n });\n video.on('started', () => {\n self.image.$default_item = self.image.$item;\n self.image.$item = self.$video;\n\n // set video width and height\n self.image.width = self.video.videoWidth || 1280;\n self.image.height = self.video.videoHeight || 720;\n self.coverImage();\n self.onScroll();\n\n // hide image\n if (self.image.$default_item) {\n self.image.$default_item.style.display = 'none';\n }\n });\n\n video.on('ended', () => {\n self.videoEnded = true;\n\n if (!self.options.videoLoop) {\n // show default image if Loop disabled.\n resetDefaultImage();\n }\n });\n video.on('error', () => {\n self.videoError = true;\n\n // show default image if video loading error.\n resetDefaultImage();\n });\n\n self.video = video;\n\n // set image if not exists\n if (!self.defaultInitImgResult) {\n // set empty image on self-hosted video if not defined\n self.image.src =\n 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';\n\n if ('local' !== video.type) {\n video.getImageURL((url) => {\n self.image.bgImage = `url(\"${url}\")`;\n self.init();\n });\n\n return false;\n }\n }\n }\n }\n\n return defaultResult;\n };\n\n // Destroy video parallax\n const defDestroy = Jarallax.prototype.destroy;\n Jarallax.prototype.destroy = function () {\n const self = this;\n\n if (self.image.$default_item) {\n self.image.$item = self.image.$default_item;\n delete self.image.$default_item;\n }\n\n defDestroy.apply(self);\n };\n}\n\nexport default jarallaxVideo;\n","import VideoWorker from 'video-worker';\n\nimport domReady from './utils/ready';\nimport global from './utils/global';\nimport jarallaxVideo from './ext-video';\n\njarallaxVideo();\n\n// data-jarallax-video initialization\ndomReady(() => {\n if ('undefined' !== typeof global.jarallax) {\n global.jarallax(document.querySelectorAll('[data-jarallax-video]'));\n }\n});\n\n// We should add VideoWorker globally, since some project uses it.\nif (!global.VideoWorker) {\n global.VideoWorker = VideoWorker;\n}\n\nexport default jarallaxVideo;\n"],"names":["win","window","global","self","callback","jarallaxVideo","jarallax","Jarallax","constructor","defOnScroll","prototype","onScroll","this","apply","isVideoInserted","video","options","videoLazyLoading","isElementInViewport","disableVideo","getVideo","$parent","parentNode","css","position","image","top","left","right","bottom","width","height","maxWidth","maxHeight","pointerEvents","transformStyle","backfaceVisibility","willChange","margin","zIndex","$video","type","src","setAttribute","$item","tagName","$container","appendChild","removeChild","onVideoInsert","call","defCoverImage","coverImage","imageData","node","nodeName","h","w","ml","container","mt","marginTop","marginLeft","defInitImg","initImg","defaultResult","videoSrc","getAttribute","defaultInitImgResult","defCanInitParallax","canInitParallax","VideoWorker","autoplay","loop","videoLoop","showControls","accessibilityHidden","startTime","videoStartTime","endTime","videoEndTime","mute","videoVolume","volume","resetDefaultImage","$default_item","style","display","onVideoWorkerInit","isValid","disableParallax","speed","on","videoPlayOnlyVisible","oldOnScroll","videoError","videoEnded","isVisible","play","pause","videoWidth","videoHeight","getImageURL","url","bgImage","init","curStyle","defDestroy","destroy","document","querySelectorAll","readyState","addEventListener","capture","once","passive"],"mappings":";;;;;;;;;;;KAEA,IAAIA,IAEkB,oBAAXC,OACHA,OACqB,oBAAXC,OACVA,OACmB,oBAATC,KACVA,KAEA,GAGR,MAAeH,kgVCZf,IAAIA,EAGFA,EADE,oBAAuBC,OACnBA,OACG,oBAAuBC,OAC1BA,OACG,oBAAuBC,KAC1BA,KAEA,OCXOC,IDcAJ,EEVf,SAASK,EAAcC,EAAWJ,EAAOI,kBACnC,IAAuBA,eAIrBC,EAAWD,EAASE,YAGpBC,EAAcF,EAASG,UAAUC,SACvCJ,EAASG,UAAUC,SAAW,iBACtBR,EAAOS,KAEbH,EAAYI,MAAMV,IAGfA,EAAKW,iBACNX,EAAKY,SACHZ,EAAKa,QAAQC,kBAAoBd,EAAKe,uBACvCf,EAAKa,QAAQG,iBAGdhB,EAAKW,iBAAkB,EAEvBX,EAAKY,MAAMK,UAAUL,UACbM,EAAUN,EAAMO,WACtBnB,EAAKoB,IAAIR,EAAO,CACdS,SAAUrB,EAAKsB,MAAMD,SACrBE,IAAK,MACLC,KAAM,MACNC,MAAO,MACPC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