test-isc
Version:
An Ionic component similar to Ionic Select, that allows to search items, including async search, group, add, edit, delete items, and much more.
79 lines (78 loc) • 2.82 kB
JavaScript
import { r as registerInstance, d as createEvent, h, H as Host, e as getElement } from './index-b6f64b02.js';
import { g as getIonMode } from './ionic-global-5d790111.js';
var imgCss = ":host{display:block;-o-object-fit:contain;object-fit:contain}img{display:block;width:100%;height:100%;-o-object-fit:inherit;object-fit:inherit;-o-object-position:inherit;object-position:inherit}";
var Img = /** @class */ (function () {
function Img(hostRef) {
var _this = this;
registerInstance(this, hostRef);
this.onLoad = function () {
_this.ionImgDidLoad.emit();
};
this.onError = function () {
_this.ionError.emit();
};
this.ionImgWillLoad = createEvent(this, "ionImgWillLoad", 7);
this.ionImgDidLoad = createEvent(this, "ionImgDidLoad", 7);
this.ionError = createEvent(this, "ionError", 7);
}
Img.prototype.srcChanged = function () {
this.addIO();
};
Img.prototype.componentDidLoad = function () {
this.addIO();
};
Img.prototype.addIO = function () {
var _this = this;
if (this.src === undefined) {
return;
}
if ('IntersectionObserver' in window) {
this.removeIO();
this.io = new IntersectionObserver(function (data) {
// because there will only ever be one instance
// of the element we are observing
// we can just use data[0]
if (data[0].isIntersecting) {
_this.load();
_this.removeIO();
}
});
this.io.observe(this.el);
}
else {
// fall back to setTimeout for Safari and IE
setTimeout(function () { return _this.load(); }, 200);
}
};
Img.prototype.load = function () {
this.loadError = this.onError;
this.loadSrc = this.src;
this.ionImgWillLoad.emit();
};
Img.prototype.removeIO = function () {
if (this.io) {
this.io.disconnect();
this.io = undefined;
}
};
Img.prototype.render = function () {
return (h(Host, { class: getIonMode(this) }, h("img", { decoding: "async", src: this.loadSrc, alt: this.alt, onLoad: this.onLoad, onError: this.loadError, part: "image" })));
};
Object.defineProperty(Img.prototype, "el", {
get: function () { return getElement(this); },
enumerable: true,
configurable: true
});
Object.defineProperty(Img, "watchers", {
get: function () {
return {
"src": ["srcChanged"]
};
},
enumerable: true,
configurable: true
});
return Img;
}());
Img.style = imgCss;
export { Img as ion_img };