radh-ui
Version:
Stencil Component Starter
1 lines • 2.75 kB
JavaScript
var __awaiter=this&&this.__awaiter||function(t,e,r,n){function i(t){return t instanceof r?t:new r((function(e){e(t)}))}return new(r||(r=Promise))((function(r,o){function a(t){try{u(n.next(t))}catch(e){o(e)}}function s(t){try{u(n["throw"](t))}catch(e){o(e)}}function u(t){t.done?r(t.value):i(t.value).then(a,s)}u((n=n.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(t){return function(e){return u([t,e])}}function u(a){if(n)throw new TypeError("Generator is already executing.");while(r)try{if(n=1,i&&(o=a[0]&2?i["return"]:a[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:r.label++;return{value:a[1],done:false};case 5:r.label++;i=a[1];a=[0];continue;case 7:a=r.ops.pop();r.trys.pop();continue;default:if(!(o=r.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1];o=a;break}if(o&&r.label<o[2]){r.label=o[2];r.ops.push(a);break}if(o[2])r.ops.pop();r.trys.pop();continue}a=e.call(t,r)}catch(s){a=[6,s];i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./p-72e8199d.system.js"],(function(t){"use strict";var e,r,n;return{setters:[function(t){e=t.r;r=t.h;n=t.g}],execute:function(){var i="img{max-width:100%}";var o=function(){function t(t){var r=this;e(this,t);this.onIntersection=function(t){return __awaiter(r,void 0,void 0,(function(){var e,r,n;return __generator(this,(function(i){for(e=0,r=t;e<r.length;e++){n=r[e];if(n.isIntersecting){if(this.observer){this.observer.disconnect()}if(n.target.getAttribute("data-src")){console.log(n.target.getAttribute("data-src"));n.target.setAttribute("src",n.target.getAttribute("data-src"));n.target.removeAttribute("data-src")}}}return[2]}))}))}}t.prototype.componentDidLoad=function(){return __awaiter(this,void 0,void 0,(function(){var t;var e=this;return __generator(this,(function(r){t=this.el.shadowRoot.querySelector("img");if(!this.time){this.time=0}if(t){setTimeout((function(){e.observer=new IntersectionObserver(e.onIntersection,{rootMargin:"100px 0px"});e.observer.observe(t)}),this.time)}return[2]}))}))};t.prototype.render=function(){return r("img",{"data-src":this.imgSrc,src:"assets/imgs/dummy-off.png"})};Object.defineProperty(t.prototype,"el",{get:function(){return n(this)},enumerable:false,configurable:true});return t}();t("radh_lazy_img",o);o.style=i}}}));