new eg.ImReady(options)
-
options (default:
{}) optionalType: Partial<ImReadyOptions>ImReady's options
ImReady's options
Extends
- eg.Component
Methods
-
check(elements){this}
-
Checks whether elements are in the ready state.
엘리먼트가 준비 상태인지 체크한다.
-
elementsType: ArrayFormat<HTMLElement>
Returns:
Type Description this Example
<div> <img src="./1.jpg" data-width="1280" data-height="853" style="width:100%"/> <img src="./2.jpg" data-width="1280" data-height="853"/> <img src="ERR" data-width="1280" data-height="853"/> </div>Javascript
import ImReady from "@egjs/imready"; const im = new ImReady(); // umd: eg.ImReady im.check(document.querySelectorAll("img")).on({ preReadyElement: e => { // 1, 3 // 2, 3 // 3, 3 console.log(e.preReadyCount, e.totalCount), }, }); -
-
clear()
-
Clears events of elements being checked.
체크 중인 엘리먼트들의 이벤트를 해제 한다.
-
destroy()
-
Destory all events.
모든 이벤트를 해제 한다.
-
getTotalCount()
-
Gets the total count of elements to be checked.
체크하는 element의 총 개수를 가져온다.
-
hasError()
-
Whether an error has occurred in the elements in the current state.
현재 상태에서 엘리먼트들이 에러가 발생했는지 여부.
-
isPreReady()
-
Whether the elements are all pre-ready. (all sizes are known)
엘리먼트들이 모두 사전 준비가 됐는지 (사이즈를 전부 알 수 있는지) 여부.
-
isReady()
-
Whether the elements are all ready.
엘리먼트들이 모두 준비가 됐는지 여부.
Type Definitions
-
eg.ImReady.ImReadyEventsTSInterface
-
Properties:
Name Type Description preReadyElementOnPreReadyElement readyElementOnReadyElement errorOnError preReadyOnPreReady readyOnReady -
eg.ImReady.ImReadyHooksPropsTSInterface
-
- Deprecated
- Yes
Properties:
Name Type Description prefixstring Prefix for data size attribute.
데이터 사이즈 속성의 접두사.
loadersRecord<string, new (target: HTMLElement, options: ImReadyLoaderOptions) => Loader> The loader class map that determines how to ready for the element.
element에 대해 어떻게 준비할지 결정하는 loader 클래스 맵.
selectorstring Find the children of the element registered with the
registerfunction through the selector. (default: "")selector를 통해
register함수로 등록한 엘리먼트의 children을를 찾는다. (default: "")useReadyElementboolean Whether to use the
readyElementevent. You can use thereadyCount,isPreReadyOvervalue. (default: true)readyElement이벤트를 사용할지 여부.readyCount,isPreReadyOver값을 사용할 수 있다. (default: true)useReadyboolean Whether to use the
preReadyElementevent. You can use thepreReadyCountvalue. (default: true)preReadyElement이벤트를 사용할지 여부.preReadyCount값을 사용할 수 있다. (default: true)usePreReadyElementboolean Whether to use the
readyevent. You can use theisReadyvalue. (default: true)ready이벤트를 사용할지 여부.isReady값을 사용할 수 있다. (default: true)usePreReadyboolean Whether to use the
preReadyevent. You can use theisPreReadyvalue. (default: true)preReady이벤트를 사용할지 여부.isPreReady값을 사용할 수 있다. (default: true)useErrorboolean Whether to use the
errorevent. You can use thehasError,errorCount,totalErrorCountvalue. (default: true)error이벤트를 사용할지 여부.hasError,errorCount,totalErrorCount값을 사용할 수 있다. (default: true) -
eg.ImReady.ImReadyHooksValueTSInterface
-
Properties:
Name Type Description hasErrorboolean Whether there is an error in the element
해당 엘리먼트에 에러가 있는지 여부
errorCountnumber The number of elements with errors
에러가 있는 엘리먼트들의 개수
totalErrorCountnumber The total number of targets with errors
에러가 있는 타겟들의 총 개수
preReadyCountnumber Number of elements pre-ready
사전 준비된 엘리먼트들의 개수
readyCountnumber Number of elements ready
준비된 엘리먼트들의 개수
totalCountnumber Total number of elements
엘리먼트들의 총 개수
isPreReadyboolean Whether all elements are pre-ready
모든 엘리먼트가 사전 준비가 끝났는지 여부
isReadyboolean Whether all elements are ready
모든 엘리먼트가 준비가 끝났는지 여부
isPreReadyOverboolean Whether pre-ready is over
사전 준비가 끝났는지 여부
-
eg.ImReady.ImReadyLoaderEventsTSInterface
-
Properties:
Name Type Description errorOnLoaderError readyOnLoaderReady preReadyOnLoaderPreReady [key: string]any -
eg.ImReady.ImReadyLoaderOptionsTSInterface
-
Properties:
Name Type Description prefixstring Prefix for data size attribute.
데이터 사이즈 속성의 접두사.
-
eg.ImReady.ImReadyOptionsTSInterface
-
Properties:
Name Type Description prefixstring Prefix for data size attribute.
데이터 사이즈 속성의 접두사.
loadersRecord<string, new (target: HTMLElement, options: ImReadyLoaderOptions) => Loader> The loader class map that determines how to ready for the element.
element에 대해 어떻게 준비할지 결정하는 loader 클래스 맵.
-
eg.ImReady.ImReadyReactivePropsTSInterface
-
Properties:
Name Type Description prefixstring Prefix for data size attribute.
데이터 사이즈 속성의 접두사.
loadersRecord<string, new (target: HTMLElement, options: ImReadyLoaderOptions) => Loader> The loader class map that determines how to ready for the element.
element에 대해 어떻게 준비할지 결정하는 loader 클래스 맵.
selectorstring useReadyElementboolean useReadyboolean usePreReadyElementboolean usePreReadyboolean useErrorboolean -
eg.ImReady.OnErrorTSInterface
-
Properties:
Name Type Description elementHTMLElement The element with error images.
오류난 이미지가 있는 엘리먼트.
indexnumber The item's index with error images.
오류난 이미지가 있는 엘리먼트의 인덱스.
targetHTMLElement Error image target in element.
엘리먼트의 오류난 이미지 타겟.
errorCountnumber The number of elements with errors.
에러가 있는 엘리먼트들의 개수.
totalErrorCountnumber The total number of targets with errors.
에러가 있는 타겟들의 총 개수.
-
eg.ImReady.OnLoaderErrorTSInterface
-
Properties:
Name Type Description elementHTMLElement targetHTMLElement -
eg.ImReady.OnLoaderPreReadyTSInterface
-
Properties:
Name Type Description elementHTMLElement hasLoadingboolean isSkipboolean -
eg.ImReady.OnLoaderReadyTSInterface
-
Properties:
Name Type Description elementHTMLElement withPreReadyboolean hasLoadingboolean isSkipboolean -
eg.ImReady.OnPreReadyTSInterface
-
Properties:
Name Type Description readyCountnumber Number of elements ready
준비된 엘리먼트들의 개수
totalCountnumber Total number of elements
엘리먼트들의 총 개수
isReadyboolean Whether all elements are ready
모든 엘리먼트가 준비가 끝났는지 여부
hasLoadingboolean Whether the loading attribute has been applied
loading 속성이 적용되었는지 여부
-
eg.ImReady.OnPreReadyElementTSInterface
-
Properties:
Name Type Description elementHTMLElement The pre-ready element.
사전 준비된 엘리먼트.
indexnumber The index of the pre-ready element.
사전 준비된 엘리먼트의 인덱스.
preReadyCountnumber Number of elements pre-ready.
사전 준비된 엘리먼트들의 개수.
readyCountnumber Number of elements ready.
준비된 엘리먼트들의 개수.
totalCountnumber Total number of elements.
엘리먼트들의 총 개수.
hasLoadingboolean Whether all elements are pre-ready.
모든 엘리먼트가 사전 준비가 끝났는지 여부.
isPreReadyboolean Whether all elements are ready.
모든 엘리먼트가 준비가 끝났는지 여부.
isReadyboolean Whether the loading attribute has been applied.
loading 속성이 적용되었는지 여부.
isSkipboolean Whether the check is omitted due to skip attribute.
skip 속성으로 인하여 체크가 생략됐는지 여부.
-
eg.ImReady.OnReadyTSInterface
-
Properties:
Name Type Description errorCountnumber The number of elements with errors
에러가 있는 엘리먼트들의 개수
totalErrorCountnumber The total number of targets with errors
에러가 있는 타겟들의 총 개수
totalCountnumber Total number of elements
엘리먼트들의 총 개수
-
eg.ImReady.OnReadyElementTSInterface
-
Properties:
Name Type Description elementHTMLElement The ready element.
준비된 엘리먼트
indexnumber The index of the ready element.
준비된 엘리먼트의 인덱스
preReadyCountnumber Whether there is an error in the element
해당 엘리먼트에 에러가 있는지 여부
readyCountnumber The number of elements with errors
에러가 있는 엘리먼트들의 개수
errorCountnumber The total number of targets with errors
에러가 있는 타겟들의 총 개수
totalErrorCountnumber Number of elements pre-ready
사전 준비된 엘리먼트들의 개수
totalCountnumber Number of elements ready
준비된 엘리먼트들의 개수
hasLoadingboolean Total number of elements
엘리먼트들의 총 개수
isPreReadyboolean Whether all elements are pre-ready
모든 엘리먼트가 사전 준비가 끝났는지 여부
isReadyboolean Whether all elements are ready
모든 엘리먼트가 준비가 끝났는지 여부
hasErrorboolean Whether the loading attribute has been applied
loading 속성이 적용되었는지 여부
isPreReadyOverboolean Whether pre-ready is over
사전 준비가 끝났는지 여부
isSkipboolean Whether the check is omitted due to skip attribute
skip 속성으로 인하여 체크가 생략됐는지 여부
Events
-
error
-
An event occurs if the image, video fails to load.
이미지, 비디오가 로딩에 실패하면 이벤트가 발생한다.
-
eType: eg.ImReady.OnError
The object of data to be sent to an event
이벤트에 전달되는 데이터 객체
Example
<div> <img src="./1.jpg" data-width="1280" data-height="853" style="width:100%"/> <img src="./2.jpg"/> <img src="ERR"/> </div>Javascript
import ImReady from "@egjs/imready"; const im = new ImReady(); // umd: eg.ImReady im.check([document.querySelector("div")]).on({ error: e => { // <div>...</div>, 0, <img src="ERR"/> console.log(e.element, e.index, e.target), }, }); -
-
preReady
-
An event occurs when all element are pre-ready (When all elements have the loading attribute applied or the size is known)
모든 엘리먼트들이 사전 준비된 경우 (모든 엘리먼트들이 loading 속성이 적용되었거나 사이즈를 알 수 있는 경우) 이벤트가 발생한다.
-
eType: eg.ImReady.OnPreReady
The object of data to be sent to an event
이벤트에 전달되는 데이터 객체
Example
<div> <img src="./1.jpg" data-width="1280" data-height="853" style="width:100%"/> <img src="./2.jpg" data-width="1280" data-height="853"/> <img src="ERR" data-width="1280" data-height="853"/> </div>Javascript
import ImReady from "@egjs/imready"; const im = new ImReady(); // umd: eg.ImReady im.check(document.querySelectorAll("img")).on({ preReady: e => { // 0, 3 console.log(e.readyCount, e.totalCount), }, }); -
-
preReadyElement
-
An event occurs when the element is pre-ready (when the loading attribute is applied or the size is known)
해당 엘리먼트가 사전 준비되었을 때(loading 속성이 적용되었거나 사이즈를 알 수 있을 때) 이벤트가 발생한다.
-
e
The object of data to be sent to an event
이벤트에 전달되는 데이터 객체
Example
<div> <img src="./1.jpg" data-width="1280" data-height="853" style="width:100%"/> <img src="./2.jpg" data-width="1280" data-height="853"/> <img src="ERR" data-width="1280" data-height="853"/> </div>Javascript
import ImReady from "@egjs/imready"; const im = new ImReady(); // umd: eg.ImReady im.check(document.querySelectorAll("img")).on({ preReadyElement: e => { // 1, 3 // 2, 3 // 3, 3 console.log(e.preReadyCount, e.totalCount), }, }); -
-
ready
-
An event occurs when all element are ready
모든 엘리먼트들이 준비된 경우 이벤트가 발생한다.
-
eType: eg.ImReady.OnReady
The object of data to be sent to an event
이벤트에 전달되는 데이터 객체
Example
<div> <img src="./1.jpg" data-width="1280" data-height="853" style="width:100%"/> <img src="./2.jpg" data-width="1280" data-height="853"/> <img src="ERR" data-width="1280" data-height="853"/> </div>Javascript
import ImReady from "@egjs/imready"; const im = new ImReady(); // umd: eg.ImReady im.check(document.querySelectorAll("img")).on({ preReady: e => { // 0, 3 console.log(e.readyCount, e.totalCount), }, ready: e => { // 1, 3 console.log(e.errorCount, e.totalCount), }, }); -
-
readyElement
-
An event occurs when the element is ready
해당 엘리먼트가 준비가 되었을 때 이벤트가 발생한다.
-
e
The object of data to be sent to an event
이벤트에 전달되는 데이터 객체
Example
<div> <img src="./1.jpg" data-width="1280" data-height="853" style="width:100%"/> <img src="./2.jpg" data-width="1280" data-height="853"/> <img src="ERR" data-width="1280" data-height="853"/> </div>Javascript
import ImReady from "@egjs/imready"; const im = new ImReady(); // umd: eg.ImReady im.check(document.querySelectorAll("img")).on({ readyElement: e => { // 1, 0, false, 3 // 2, 1, false, 3 // 3, 2, true, 3 console.log(e.readyCount, e.index, e.hasError, e.totalCount), }, }); -