UNPKG

@huluvu424242/honey-slideshow

Version:

Text to Speech component wich is reading texts from DOM elements.

79 lines (78 loc) 2.9 kB
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-a2883912.js'; import { g as getIonMode } from './ionic-global-c170bb31.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.ionImgWillLoad = createEvent(this, "ionImgWillLoad", 7); this.ionImgDidLoad = createEvent(this, "ionImgDidLoad", 7); this.ionError = createEvent(this, "ionError", 7); this.onLoad = function () { _this.ionImgDidLoad.emit(); }; this.onError = function () { _this.ionError.emit(); }; } 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: false, configurable: true }); Object.defineProperty(Img, "watchers", { get: function () { return { "src": ["srcChanged"] }; }, enumerable: false, configurable: true }); return Img; }()); Img.style = imgCss; export { Img as ion_img };