naver / egjs-imready Goto Github PK
View Code? Open in Web Editor NEWI'm Ready to check if the images or videos are loaded!
Home Page: https://naver.github.io/egjs-imready
License: Other
I'm Ready to check if the images or videos are loaded!
Home Page: https://naver.github.io/egjs-imready
License: Other
It is necessary to use a polyfill according to the browser coverage or use an alternative method.
<div data-skip="true">
</div>
import ImReady from "@egjs/imready";
new ImReady().check(document.querySelectorAll("div")).on("ready", e => {
// expected to be 1. but 0
console.log(e.totalCount);
});
https://angular.io/guide/attribute-directives
Support Angular
I need a method to know if an error has occurred.
import ImReady from "@egjs/imready";
const im = new ImReady();
im.check();
// ...
setTimeout(() => {
console.log(im.hasError());
});
<img src="...." />
<img data-src="...." />
Like native loading, preReady should also occur.
new ImReady({
prefix: "data-grid-",
});
Support Vue 2 Hooks
I will insert img element
<img />
<div>
<img loading="lazy" />
<img />
</div>
When loading images and non-loading images are used together, preReady occurs immediately.
import ImReady from "@egjs/imready";
const im = new ImReady();
im.check([div]).on("preReady", () => {
// error size
console.log(div.offsetWidth, div.offsetHeight);
});
<div>
<img loading="lazy">
</div>
import ImReady from "@egjs/imready";
new ImReady().check(document.querySelectorAll("div")).on("readyElement", e => {
// expected to be true. but false
console.log(e.hasLoading);
});
ImReady is not constructor.
import ImReady from "@egjs/imready";
ImReady; // { default: constructor }
exports.deafult = ImReady;
=>
module.exports = ImReady;
If you destroy before preReady occurs, an error occurs.
Cannot set property 'hasLoading' of undefined
<img data-lazy-src="..." data-lazy="true" />
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.