Showing content from https://unpkg.com/@jambonn/vue-lazyload/dist/vue-lazyload.umd.js below:
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["vue-lazyload"]={},t.Vue)}(this,(function(t,e){"use strict";const i="undefined"!=typeof window&&null!==window,s=function(){if(i&&"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)return"isIntersecting"in window.IntersectionObserverEntry.prototype||Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}}),!0;return!1}();const r="event",n="observer",o=function(){if(i)return"function"==typeof window.CustomEvent?window.CustomEvent:(t.prototype=window.Event.prototype,t);function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};const i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}}();function a(t,e){if(!t.length)return;const i=t.indexOf(e);return i>-1?t.splice(i,1):void 0}function h(t,e){if("IMG"!==t.tagName||!t.getAttribute("data-srcset"))return;let i=t.getAttribute("data-srcset");const s=t.parentNode.offsetWidth*e;let r,n,o;i=i.trim().split(/(?<=\d+w),/);const a=i.map((t=>(t=t.trim(),r=t.lastIndexOf(" "),-1===r?(n=t,o=999998):(n=t.substr(0,r),o=parseInt(t.substr(r+1,t.length-r-2),10)),[o,n])));a.sort((function(t,e){if(t[0] e[0])return-1;if(t[0]===e[0]){if(-1!==e[1].indexOf(".webp",e[1].length-5))return 1;if(-1!==t[1].indexOf(".webp",t[1].length-5))return-1}return 0}));let h,d="";for(let l=0;l i&&window.devicePixelRatio||t;function l(){if(!i)return!1;let t=!0;try{const e=document.createElement("canvas");e.getContext&&e.getContext("2d")&&(t=0===e.toDataURL("image/webp").indexOf("data:image/webp"))}catch(e){t=!1}return t}const c=function(){if(!i)return;let t=!1;try{let e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("test",null,e)}catch(e){}return t}(),u={on(t,e,i,s=!1){c?t.addEventListener(e,i,{capture:s,passive:!0}):t.addEventListener(e,i,s)},off(t,e,i,s=!1){t.removeEventListener(e,i,s)}},p=(t,e,i)=>{let s=new Image;if(!t||!t.src){const t=new Error("image src is required");return i(t)}s.src=t.src,t.cors&&(s.crossOrigin=t.cors),s.onload=function(){e({naturalHeight:s.naturalHeight,naturalWidth:s.naturalWidth,src:s.src})},s.onerror=function(t){i(t)}},g=(t,e)=>"undefined"!=typeof getComputedStyle?getComputedStyle(t,null).getPropertyValue(e):t.style[e],f=t=>g(t,"overflow")+g(t,"overflow-y")+g(t,"overflow-x");function m(){}class b{constructor({max:t}){this.options={max:t||100},this._caches=[]}has(t){return this._caches.indexOf(t)>-1}add(t){this.has(t)||(this._caches.push(t),this._caches.length>this.options.max&&this.free())}free(){this._caches.shift()}}class v{constructor({el:t,src:e,error:i,loading:s,bindType:r,$parent:n,options:o,cors:a,elRenderer:h,imageCache:d}){this.el=t,this.src=e,this.error=i,this.loading=s,this.bindType=r,this.attempt=0,this.cors=a,this.naturalHeight=0,this.naturalWidth=0,this.options=o,this.rect=null,this.$parent=n,this.elRenderer=h,this._imageCache=d,this.performanceData={init:Date.now(),loadStart:0,loadEnd:0},this.filter(),this.initState(),this.render("loading",!1)}initState(){"dataset"in this.el?this.el.dataset.src=this.src:this.el.setAttribute("data-src",this.src),this.state={loading:!1,error:!1,loaded:!1,rendered:!1}}record(t){this.performanceData[t]=Date.now()}update({src:t,loading:e,error:i}){const s=this.src;this.src=t,this.loading=e,this.error=i,this.filter(),s!==this.src&&(this.attempt=0,this.initState())}getRect(){this.rect=this.el.getBoundingClientRect()}checkInView(){return this.getRect(),this.rect.top this.options.preLoadTop&&this.rect.left 0}filter(){Object.keys(this.options.filter).map((t=>{this.options.filter[t](this,this.options)}))}renderLoading(t){this.state.loading=!0,p({src:this.loading,cors:this.cors},(()=>{this.render("loading",!1),this.state.loading=!1,t()}),(()=>{t(),this.state.loading=!1,this.options.silent||console.warn(`VueLazyload log: load failed with loading image(${this.loading})`)}))}load(t=m){return this.attempt>this.options.attempt-1&&this.state.error?(this.options.silent||console.log(`VueLazyload log: ${this.src} tried too more than ${this.options.attempt} times`),void t()):this.state.rendered&&this.state.loaded?void 0:this._imageCache.has(this.src)?(this.state.loaded=!0,this.render("loaded",!0),this.state.rendered=!0,t()):void this.renderLoading((()=>{this.attempt++,this.options.adapter.beforeLoad&&this.options.adapter.beforeLoad(this,this.options),this.record("loadStart"),p({src:this.src,cors:this.cors},(e=>{this.naturalHeight=e.naturalHeight,this.naturalWidth=e.naturalWidth,this.state.loaded=!0,this.state.error=!1,this.record("loadEnd"),this.render("loaded",!1),this.state.rendered=!0,this._imageCache.add(this.src),t()}),(t=>{!this.options.silent&&console.error(t),this.state.error=!0,this.state.loaded=!1,this.render("error",!1)}))}))}render(t,e){this.elRenderer(this,t,e)}performance(){let t="loading",e=0;return this.state.loaded&&(t="loaded",e=(this.performanceData.loadEnd-this.performanceData.loadStart)/1e3),this.state.error&&(t="error"),{src:this.src,state:t,time:e}}$destroy(){this.el=null,this.src=null,this.error=null,this.loading=null,this.bindType=null,this.attempt=0}}const y="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",w=["scroll","wheel","mousewheel","resize","animationend","transitionend","touchmove"],L={rootMargin:"0px",threshold:0};function _(){return class{constructor({preLoad:t,error:e,throttleWait:i,preLoadTop:s,dispatchEvent:o,loading:a,attempt:h,silent:c=!0,scale:u,listenEvents:p,filter:g,adapter:f,observer:m,observerOptions:v}){this.mode=r,this.ListenerQueue=[],this.TargetIndex=0,this.TargetQueue=[],this.options={silent:c,dispatchEvent:!!o,throttleWait:i||200,preLoad:t||1.3,preLoadTop:s||0,error:e||y,loading:a||y,attempt:h||3,scale:u||d(u),ListenEvents:p||w,hasbind:!1,supportWebp:l(),filter:g||{},adapter:f||{},observer:!!m,observerOptions:v||L},this._initEvent(),this._imageCache=new b({max:200}),this.lazyLoadHandler=function(t,e){let i=null,s=0;return function(...r){if(i)return;let n=function(){s=Date.now(),i=!1,t.apply(this,r)};Date.now()-s>=e?n():i=setTimeout(n,e)}}(this._lazyLoadHandler.bind(this),this.options.throttleWait),this.setMode(this.options.observer?n:r)}config(t={}){Object.assign(this.options,t)}performance(){return this.ListenerQueue.map((t=>t.performance()))}addLazyBox(t){this.ListenerQueue.push(t),i&&(this._addListenerTarget(window),this._observer&&this._observer.observe(t.el),t.$el&&t.$el.parentNode&&this._addListenerTarget(t.$el.parentNode))}add(t,s){if(this.ListenerQueue.some((e=>e.el===t)))return this.update(t,s),void e.nextTick((()=>this.lazyLoadHandler()));const r=this._valueFormatter(s.value);let{src:n}=r;e.nextTick((()=>{n=h(t,this.options.scale)||n,this._observer&&this._observer.observe(t);const o=Object.keys(s.modifiers)[0];let a;o&&(a=s.instance.$refs[o],a=a?a.$el||a:document.getElementById(o)),a||(a=(t=>{if(!i)return;if(!(t instanceof HTMLElement))return window;let e=t;for(;e&&e!==document.body&&e!==document.documentElement&&e.parentNode;){if(/(scroll|auto)/.test(f(e)))return e;e=e.parentNode}return window})(t));const d=new v({el:t,$parent:a,src:n,loading:r.loading,error:r.error,cors:r.cors,bindType:s.arg,elRenderer:this._elRenderer.bind(this),options:this.options,imageCache:this._imageCache});this.ListenerQueue.push(d),i&&(this._addListenerTarget(window),this._addListenerTarget(a)),this.lazyLoadHandler(),e.nextTick((()=>this.lazyLoadHandler()))}))}update(t,i){const s=this._valueFormatter(i.value);let{src:r}=s;r=h(t,this.options.scale)||r;const n=this.ListenerQueue.find((e=>e.el===t));n?n.update({src:r,error:s.error,loading:s.loading}):this.add(t,i),this._observer&&(this._observer.unobserve(t),this._observer.observe(t)),this.lazyLoadHandler(),e.nextTick((()=>this.lazyLoadHandler()))}remove(t){if(!t)return;this._observer&&this._observer.unobserve(t);const e=this.ListenerQueue.find((e=>e.el===t));e&&(this._removeListenerTarget(e.$parent),this._removeListenerTarget(window),a(this.ListenerQueue,e),e.$destroy&&e.$destroy())}removeComponent(t){t&&(a(this.ListenerQueue,t),this._observer&&this._observer.unobserve(t.el),t.$parent&&t.$el.parentNode&&this._removeListenerTarget(t.$el.parentNode),this._removeListenerTarget(window))}setMode(t){s||t!==n||(t=r),this.mode=t,t===r?(this._observer&&(this.ListenerQueue.forEach((t=>{this._observer.unobserve(t.el)})),this._observer=null),this.TargetQueue.forEach((t=>{this._initListen(t.el,!0)}))):(this.TargetQueue.forEach((t=>{this._initListen(t.el,!1)})),this._initIntersectionObserver())}_addListenerTarget(t){if(!t)return;let e=this.TargetQueue.find((e=>e.el===t));return e?e.childrenCount++:(e={el:t,id:++this.TargetIndex,childrenCount:1,listened:!0},this.mode===r&&this._initListen(e.el,!0),this.TargetQueue.push(e)),this.TargetIndex}_removeListenerTarget(t){this.TargetQueue.forEach(((e,i)=>{e.el===t&&(e.childrenCount--,e.childrenCount||(this._initListen(e.el,!1),this.TargetQueue.splice(i,1),e=null))}))}_initListen(t,e){this.options.ListenEvents.forEach((i=>u[e?"on":"off"](t,i,this.lazyLoadHandler)))}_initEvent(){this.Event={listeners:{loading:[],loaded:[],error:[]}},this.$on=(t,e)=>{this.Event.listeners[t]||(this.Event.listeners[t]=[]),this.Event.listeners[t].push(e)},this.$once=(t,e)=>{const i=(...s)=>{this.$off(t,i),e.apply(this,s)};this.$on(t,i)},this.$off=(t,e)=>{if(e)a(this.Event.listeners[t],e);else{if(!this.Event.listeners[t])return;this.Event.listeners[t].length=0}},this.$emit=(t,e,i)=>{this.Event.listeners[t]&&this.Event.listeners[t].forEach((t=>t(e,i)))}}_lazyLoadHandler(){const t=[];this.ListenerQueue.forEach((e=>{e.el&&e.el.parentNode||t.push(e);e.checkInView()&&e.load()})),t.forEach((t=>{a(this.ListenerQueue,t),t.$destroy&&t.$destroy()}))}_initIntersectionObserver(){s&&(this._observer=new IntersectionObserver(this._observerHandler.bind(this),this.options.observerOptions),this.ListenerQueue.length&&this.ListenerQueue.forEach((t=>{this._observer.observe(t.el)})))}_observerHandler(t){t.forEach((t=>{t.isIntersecting&&this.ListenerQueue.forEach((e=>{if(e.el===t.target){if(e.state.loaded)return this._observer.unobserve(e.el);e.load()}}))}))}_elRenderer(t,e,i){if(!t.el)return;const{el:s,bindType:r}=t;let n;switch(e){case"loading":n=t.loading;break;case"error":n=t.error;break;default:n=t.src}if(r?s.style[r]='url("'+n+'")':s.getAttribute("src")!==n&&s.setAttribute("src",n),s.setAttribute("lazy",e),this.$emit(e,t,i),this.options.adapter[e]&&this.options.adapter[e](t,this.options),this.options.dispatchEvent){const i=new o(e,{detail:t});s.dispatchEvent(i)}}_valueFormatter(t){let e=t,{loading:i,error:s}=this.options;var r;return null!==(r=t)&&"object"==typeof r&&(t.src||this.options.silent||console.error("Vue Lazyload warning: miss src with "+t),e=t.src,i=t.loading||this.options.loading,s=t.error||this.options.error),{src:e,loading:i,error:s}}}}var E=t=>({props:{tag:{type:String,default:"div"}},emits:["show"],render(){return e.h(this.tag,null,this.show&&this.$slots.default?this.$slots.default():null)},data:()=>({el:null,state:{loaded:!1},rect:{},show:!1}),mounted(){this.el=this.$el,t.addLazyBox(this),t.lazyLoadHandler()},beforeUnmount(){t.removeComponent(this)},methods:{getRect(){this.rect=this.$el.getBoundingClientRect()},checkInView(){return this.getRect(),i&&this.rect.top 0&&this.rect.left 0},load(){this.show=!0,this.state.loaded=!0,this.$emit("show",this)},destroy(){return this.$destroy}}});const z={selector:"img"};class A{constructor({el:t,binding:e,lazy:i}){this.el=null,this.binding=e,this.options={},this.lazy=i,this.update({el:t,binding:e})}update({el:t,binding:e}){this.el=t,this.options=Object.assign({},z,e.value);this.getImgs().forEach((t=>{this.lazy.add(t,Object.assign({},this.binding,{value:{src:"dataset"in t?t.dataset.src:t.getAttribute("data-src"),error:("dataset"in t?t.dataset.error:t.getAttribute("data-error"))||this.options.error,loading:("dataset"in t?t.dataset.loading:t.getAttribute("data-loading"))||this.options.loading}}))}))}getImgs(){return Array.from(this.el.querySelectorAll(this.options.selector))}clear(){this.getImgs().forEach((t=>this.lazy.remove(t))),this.binding=null,this.lazy=null}}class ${constructor({lazy:t}){this.lazy=t,this._queue=[]}bind(t,e){const i=new A({el:t,binding:e,lazy:this.lazy});this._queue.push(i)}update(t,e){const i=this._queue.find((e=>e.el===t));i&&i.update({el:t,binding:e})}unbind(t){const e=this._queue.find((e=>e.el===t));e&&(e.clear(),a(this._queue,e))}}var T=t=>({props:{src:[String,Object],tag:{type:String,default:"img"}},render(){return e.h(this.tag,{src:this.renderSrc},this.$slots.default?this.$slots.default():null)},data:()=>({el:null,options:{src:"",error:"",loading:"",attempt:t.options.attempt},state:{loaded:!1,error:!1,attempt:0},rect:{},renderSrc:""}),watch:{src(){this.init(),t.addLazyBox(this),t.lazyLoadHandler()}},created(){this.init(),this.renderSrc=this.options.loading},mounted(){this.el=this.$el,t.addLazyBox(this),t.lazyLoadHandler()},beforeUnmount(){t.removeComponent(this)},methods:{init(){const{src:e,loading:i,error:s}=t._valueFormatter(this.src);this.state.loaded=!1,this.options.src=e,this.options.error=s,this.options.loading=i,this.renderSrc=this.options.loading},getRect(){this.rect=this.$el.getBoundingClientRect()},checkInView(){return this.getRect(),i&&this.rect.top 0&&this.rect.left 0},load(e=m){if(this.state.attempt>this.options.attempt-1&&this.state.error)return t.options.silent||console.log(`VueLazyload log: ${this.options.src} tried too more than ${this.options.attempt} times`),void e();const i=this.options.src;p({src:i},(({src:t})=>{this.renderSrc=t,this.state.loaded=!0}),(()=>{this.state.attempt++,this.renderSrc=this.options.error,this.state.error=!0}))}}}),I={install(t,e={}){if(Number(t.version.split(".")[0])<3)return new Error("Vue version at least 3.0");const i=new(_())(e),s=new $({lazy:i});t.provide("Lazyload",i),t.config.globalProperties.$Lazyload=i,e.lazyComponent&&t.component("LazyComponent",E(i)),e.lazyImage&&t.component("LazyImage",T(i)),t.directive("lazy",{beforeMount:i.add.bind(i),updated:i.update.bind(i),unmounted:i.remove.bind(i)}),t.directive("lazy-container",{beforeMount:s.bind.bind(s),updated:s.update.bind(s),unmounted:s.unbind.bind(s)})}};t.default=I,Object.defineProperty(t,"__esModule",{value:!0}),t[Symbol.toStringTag]="Module"}));
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4