diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d20cd6be..94a1dae9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,35 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [4.11.1](https://github.com/naver/egjs-infinitegrid/compare/4.10.1...4.11.1) (2024-02-07) +### :sparkles: Packages +* `@egjs/infinitegrid` 4.11.1 +* `@egjs/react-infinitegrid` 4.11.1 +* `@egjs/svelte-infinitegrid` 4.11.1 +* `@egjs/vue-infinitegrid` 4.11.1 +* `@egjs/vue3-infinitegrid` 4.11.1 +* `@egjs/ngx-infinitegrid` 4.11.1 + + +### :rocket: New Features + +* `@egjs/infinitegrid` + * add contentAlign prop (#558) ([559a288](https://github.com/naver/egjs-infinitegrid/commit/559a28805f9b8d83e6b0c9fb0cfb6218172f32b7)) + + +### :bug: Bug Fix + +* All + * fix observe order (#563) ([e5bfcc4](https://github.com/naver/egjs-infinitegrid/commit/e5bfcc4c61ed03009ff35b6fca8a1f70969995ae)) + + +### :mega: Other + +* All + * update packages versions ([13597dd](https://github.com/naver/egjs-infinitegrid/commit/13597dd1e4ddcc28fdca0e9fa62f0a9c2df3b312)) + + + ## [4.10.1](https://github.com/naver/egjs-infinitegrid/compare/4.10.0...4.10.1) (2023-08-04) ### :sparkles: Packages * `@egjs/infinitegrid` 4.10.1 diff --git a/packages/docs/docs/api/FrameInfiniteGrid.mdx b/packages/docs/docs/api/FrameInfiniteGrid.mdx index 9f7205066..b0daa71cd 100644 --- a/packages/docs/docs/api/FrameInfiniteGrid.mdx +++ b/packages/docs/docs/api/FrameInfiniteGrid.mdx @@ -14,7 +14,7 @@ class FrameInfiniteGrid
Methods
Events
-
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
## constructor @@ -492,6 +492,183 @@ ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); **Returns**: void +### trigger {#trigger} + +
+ inherited +
+ +

Trigger a custom event.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||

The name of the custom event to be triggered or an instance of the ComponentEvent

| +|params|Array<any> \| $ts:...|||

Event data to be sent when triggering a custom event

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +

Executed event just one time.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +

Checks whether an event has been attached to a component.

+ +**Returns**: boolean +-

Indicates whether the event is attached.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||

The name of the event to be attached

| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +

Attaches an event to a component.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +

Detaches an event from the component.
If the eventName is not given this will detach all event handlers attached.
If the handlerToDetach is not given, this will detach all event handlers for eventName.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||

The name of the event to be detached

| +|handlerToDetach|function \| $ts:...|✔️||

The handler function of the event to be detached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + ## Events ### changeScroll {#event-changeScroll} diff --git a/packages/docs/docs/api/Grid.mdx b/packages/docs/docs/api/Grid.mdx index d76ca85bf..b1fc572ae 100644 --- a/packages/docs/docs/api/Grid.mdx +++ b/packages/docs/docs/api/Grid.mdx @@ -12,7 +12,7 @@ class Grid
Properties
Methods
Events
-
gap
defaultDirection
useFit
preserveUIOnDestroy
outlineLength
outlineSize
applyGrid
getContainerElement
getItems
getChildren
setItems
getContainerInlineSize
getOutlines
setOutlines
syncElements
updateItems
renderItems
getStatus
setStatus
getComputedOutlineSize
getComputedOutlineLength
destroy
contentError
renderComplete
+
gap
defaultDirection
useFit
preserveUIOnDestroy
outlineLength
outlineSize
applyGrid
getContainerElement
getItems
getChildren
setItems
getContainerInlineSize
getOutlines
setOutlines
syncElements
updateItems
renderItems
getStatus
setStatus
getComputedOutlineSize
getComputedOutlineLength
destroy
trigger
once
hasOn
on
off
contentError
renderComplete
## constructor @@ -367,6 +367,183 @@ grid.renderItems(); |:---:|:---:|:---:|:---:|:---:| |Options|DestroyOptions|✔️|{}|

for destroy.

| +### trigger {#trigger} + +
+ inherited +
+ +

Trigger a custom event.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||

The name of the custom event to be triggered or an instance of the ComponentEvent

| +|params|Array<any> \| $ts:...|||

Event data to be sent when triggering a custom event

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +

Executed event just one time.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +

Checks whether an event has been attached to a component.

+ +**Returns**: boolean +-

Indicates whether the event is attached.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||

The name of the event to be attached

| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +

Attaches an event to a component.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +

Detaches an event from the component.
If the eventName is not given this will detach all event handlers attached.
If the handlerToDetach is not given, this will detach all event handlers for eventName.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||

The name of the event to be detached

| +|handlerToDetach|function \| $ts:...|✔️||

The handler function of the event to be detached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + ## Events ### contentError {#event-contentError} diff --git a/packages/docs/docs/api/InfiniteGrid.mdx b/packages/docs/docs/api/InfiniteGrid.mdx index b6a1f5477..82e5ec995 100644 --- a/packages/docs/docs/api/InfiniteGrid.mdx +++ b/packages/docs/docs/api/InfiniteGrid.mdx @@ -14,7 +14,7 @@ class InfiniteGrid extends Component
Methods
Events
-
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
## constructor @@ -523,6 +523,183 @@ ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); **Returns**: void +### trigger {#trigger} + +
+ inherited +
+ +

Trigger a custom event.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||

The name of the custom event to be triggered or an instance of the ComponentEvent

| +|params|Array<any> \| $ts:...|||

Event data to be sent when triggering a custom event

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +

Executed event just one time.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +

Checks whether an event has been attached to a component.

+ +**Returns**: boolean +-

Indicates whether the event is attached.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||

The name of the event to be attached

| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +

Attaches an event to a component.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +

Detaches an event from the component.
If the eventName is not given this will detach all event handlers attached.
If the handlerToDetach is not given, this will detach all event handlers for eventName.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||

The name of the event to be detached

| +|handlerToDetach|function \| $ts:...|✔️||

The handler function of the event to be detached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + ## Events ### changeScroll {#event-changeScroll} diff --git a/packages/docs/docs/api/JustifiedInfiniteGrid.mdx b/packages/docs/docs/api/JustifiedInfiniteGrid.mdx index 6158a683a..6854e91ab 100644 --- a/packages/docs/docs/api/JustifiedInfiniteGrid.mdx +++ b/packages/docs/docs/api/JustifiedInfiniteGrid.mdx @@ -14,7 +14,7 @@ class JustifiedInfiniteGrid
Methods
Events
-
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
## constructor @@ -492,6 +492,183 @@ ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); **Returns**: void +### trigger {#trigger} + +
+ inherited +
+ +

Trigger a custom event.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||

The name of the custom event to be triggered or an instance of the ComponentEvent

| +|params|Array<any> \| $ts:...|||

Event data to be sent when triggering a custom event

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +

Executed event just one time.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +

Checks whether an event has been attached to a component.

+ +**Returns**: boolean +-

Indicates whether the event is attached.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||

The name of the event to be attached

| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +

Attaches an event to a component.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +

Detaches an event from the component.
If the eventName is not given this will detach all event handlers attached.
If the handlerToDetach is not given, this will detach all event handlers for eventName.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||

The name of the event to be detached

| +|handlerToDetach|function \| $ts:...|✔️||

The handler function of the event to be detached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + ## Events ### changeScroll {#event-changeScroll} diff --git a/packages/docs/docs/api/MasonryInfiniteGrid.mdx b/packages/docs/docs/api/MasonryInfiniteGrid.mdx index 159109699..f85c5d337 100644 --- a/packages/docs/docs/api/MasonryInfiniteGrid.mdx +++ b/packages/docs/docs/api/MasonryInfiniteGrid.mdx @@ -14,7 +14,7 @@ class MasonryInfiniteGrid
Methods
Events
-
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
## constructor @@ -492,6 +492,183 @@ ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); **Returns**: void +### trigger {#trigger} + +
+ inherited +
+ +

Trigger a custom event.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||

The name of the custom event to be triggered or an instance of the ComponentEvent

| +|params|Array<any> \| $ts:...|||

Event data to be sent when triggering a custom event

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +

Executed event just one time.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +

Checks whether an event has been attached to a component.

+ +**Returns**: boolean +-

Indicates whether the event is attached.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||

The name of the event to be attached

| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +

Attaches an event to a component.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +

Detaches an event from the component.
If the eventName is not given this will detach all event handlers attached.
If the handlerToDetach is not given, this will detach all event handlers for eventName.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||

The name of the event to be detached

| +|handlerToDetach|function \| $ts:...|✔️||

The handler function of the event to be detached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + ## Events ### changeScroll {#event-changeScroll} diff --git a/packages/docs/docs/api/MasonryInfiniteGridOptions.mdx b/packages/docs/docs/api/MasonryInfiniteGridOptions.mdx index ecf9a0437..ca88395a6 100644 --- a/packages/docs/docs/api/MasonryInfiniteGridOptions.mdx +++ b/packages/docs/docs/api/MasonryInfiniteGridOptions.mdx @@ -35,6 +35,7 @@ custom_edit_url: null |columnSize|number|0|

The size of the columns. If it is 0, it is calculated as the size of the first item in items. Can be used instead of outlineSize.

| |columnSizeRatio|number|0|

The size ratio(inlineSize / contentSize) of the columns. 0 is not set.

| |align|GridAlign|"justify"|

Align of the position of the items. If you want to use stretch, be sure to set column, columnSize or maxStretchColumnSize option. ("start", "center", "end", "justify", "stretch")

| +|contentAlign|MasonryGridVerticalAlign|"masonry"|

Content direction alignment of items. “Masonry” is sorted in the form of masonry. Others are applied as content direction alignment, similar to vertical-align of inline-block.
If you set multiple columns (data-grid-column), the screen may look strange.

| |columnCalculationThreshold|number|1|

Difference Threshold for Counting Columns. Since offsetSize is calculated by rounding, the number of columns may not be accurate.

| |maxStretchColumnSize|number|Infinity|

If stretch is used, the column can be automatically calculated by setting the maximum size of the column that can be stretched.

| |horizontal|boolean|false|

Direction of the scroll movement. (true: horizontal, false: vertical) If horizontal is false, inlinePos is left, inlineSize is width, contentPos is top, and contentSize is height. If horizontal is true, inlinePos is top, inlineSize is height, contentPos is left, and contentSize is width.

| diff --git a/packages/docs/docs/api/PackingInfiniteGrid.mdx b/packages/docs/docs/api/PackingInfiniteGrid.mdx index 0ba08fdef..5cedfdb3c 100644 --- a/packages/docs/docs/api/PackingInfiniteGrid.mdx +++ b/packages/docs/docs/api/PackingInfiniteGrid.mdx @@ -14,7 +14,7 @@ class PackingInfiniteGrid
Methods
Events
-
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
## constructor @@ -492,6 +492,183 @@ ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); **Returns**: void +### trigger {#trigger} + +
+ inherited +
+ +

Trigger a custom event.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||

The name of the custom event to be triggered or an instance of the ComponentEvent

| +|params|Array<any> \| $ts:...|||

Event data to be sent when triggering a custom event

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +

Executed event just one time.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +

Checks whether an event has been attached to a component.

+ +**Returns**: boolean +-

Indicates whether the event is attached.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||

The name of the event to be attached

| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +

Attaches an event to a component.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +

Detaches an event from the component.
If the eventName is not given this will detach all event handlers attached.
If the handlerToDetach is not given, this will detach all event handlers for eventName.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||

The name of the event to be detached

| +|handlerToDetach|function \| $ts:...|✔️||

The handler function of the event to be detached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + ## Events ### changeScroll {#event-changeScroll} diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/FrameInfiniteGrid.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/FrameInfiniteGrid.mdx index d33115b9f..71ed0aae2 100644 --- a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/FrameInfiniteGrid.mdx +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/FrameInfiniteGrid.mdx @@ -14,7 +14,7 @@ class FrameInfiniteGrid
Methods
Events
-
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
## constructor @@ -492,6 +492,183 @@ InfiniteGrid의 보이는 그룹들을 반환한다. **Returns**: void +### trigger {#trigger} + +
+ inherited +
+ +커스텀 이벤트를 발생시킨다 + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스| +|params|Array<any> \| $ts:...|||커스텀 이벤트가 발생할 때 전달할 데이터| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +이벤트가 한번만 실행된다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +컴포넌트에 이벤트가 등록됐는지 확인한다. + +**Returns**: boolean +- 이벤트 등록 여부 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||등록 여부를 확인할 이벤트의 이름| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +컴포넌트에 이벤트를 등록한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +컴포넌트에 등록된 이벤트를 해제한다.
`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.
`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||해제할 이벤트의 이름| +|handlerToDetach|function \| $ts:...|✔️||해제할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + ## Events ### changeScroll {#event-changeScroll} diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/Grid.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/Grid.mdx index 911c15249..51a6eb11f 100644 --- a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/Grid.mdx +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/Grid.mdx @@ -12,7 +12,7 @@ class Grid
Properties
Methods
Events
-
gap
defaultDirection
useFit
preserveUIOnDestroy
outlineLength
outlineSize
applyGrid
getContainerElement
getItems
getChildren
setItems
getContainerInlineSize
getOutlines
setOutlines
syncElements
updateItems
renderItems
getStatus
setStatus
getComputedOutlineSize
getComputedOutlineLength
destroy
contentError
renderComplete
+
gap
defaultDirection
useFit
preserveUIOnDestroy
outlineLength
outlineSize
applyGrid
getContainerElement
getItems
getChildren
setItems
getContainerInlineSize
getOutlines
setOutlines
syncElements
updateItems
renderItems
getStatus
setStatus
getComputedOutlineSize
getComputedOutlineLength
destroy
trigger
once
hasOn
on
off
contentError
renderComplete
## constructor @@ -367,6 +367,183 @@ outline에 해당하는 length를 가져온다. |:---:|:---:|:---:|:---:|:---:| |Options|DestroyOptions|✔️|{}|destory()를 위한 옵션| +### trigger {#trigger} + +
+ inherited +
+ +커스텀 이벤트를 발생시킨다 + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스| +|params|Array<any> \| $ts:...|||커스텀 이벤트가 발생할 때 전달할 데이터| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +이벤트가 한번만 실행된다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +컴포넌트에 이벤트가 등록됐는지 확인한다. + +**Returns**: boolean +- 이벤트 등록 여부 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||등록 여부를 확인할 이벤트의 이름| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +컴포넌트에 이벤트를 등록한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +컴포넌트에 등록된 이벤트를 해제한다.
`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.
`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||해제할 이벤트의 이름| +|handlerToDetach|function \| $ts:...|✔️||해제할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + ## Events ### contentError {#event-contentError} diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/InfiniteGrid.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/InfiniteGrid.mdx index c31de1fd3..bf87e55bc 100644 --- a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/InfiniteGrid.mdx +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/InfiniteGrid.mdx @@ -14,7 +14,7 @@ class InfiniteGrid extends Component
Methods
Events
-
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
## constructor @@ -523,6 +523,183 @@ InfiniteGrid의 보이는 그룹들을 반환한다. **Returns**: void +### trigger {#trigger} + +
+ inherited +
+ +커스텀 이벤트를 발생시킨다 + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스| +|params|Array<any> \| $ts:...|||커스텀 이벤트가 발생할 때 전달할 데이터| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +이벤트가 한번만 실행된다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +컴포넌트에 이벤트가 등록됐는지 확인한다. + +**Returns**: boolean +- 이벤트 등록 여부 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||등록 여부를 확인할 이벤트의 이름| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +컴포넌트에 이벤트를 등록한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +컴포넌트에 등록된 이벤트를 해제한다.
`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.
`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||해제할 이벤트의 이름| +|handlerToDetach|function \| $ts:...|✔️||해제할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + ## Events ### changeScroll {#event-changeScroll} diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/JustifiedInfiniteGrid.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/JustifiedInfiniteGrid.mdx index 7952822bc..434399c69 100644 --- a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/JustifiedInfiniteGrid.mdx +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/JustifiedInfiniteGrid.mdx @@ -14,7 +14,7 @@ class JustifiedInfiniteGrid
Methods
Events
-
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
## constructor @@ -492,6 +492,183 @@ InfiniteGrid의 보이는 그룹들을 반환한다. **Returns**: void +### trigger {#trigger} + +
+ inherited +
+ +커스텀 이벤트를 발생시킨다 + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스| +|params|Array<any> \| $ts:...|||커스텀 이벤트가 발생할 때 전달할 데이터| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +이벤트가 한번만 실행된다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +컴포넌트에 이벤트가 등록됐는지 확인한다. + +**Returns**: boolean +- 이벤트 등록 여부 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||등록 여부를 확인할 이벤트의 이름| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +컴포넌트에 이벤트를 등록한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +컴포넌트에 등록된 이벤트를 해제한다.
`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.
`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||해제할 이벤트의 이름| +|handlerToDetach|function \| $ts:...|✔️||해제할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + ## Events ### changeScroll {#event-changeScroll} diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/MasonryInfiniteGrid.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/MasonryInfiniteGrid.mdx index a57023c24..5d32abb5d 100644 --- a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/MasonryInfiniteGrid.mdx +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/MasonryInfiniteGrid.mdx @@ -14,7 +14,7 @@ MasonryInfiniteGrid는 벽돌을 쌓아 올린 모양처럼 동일한 너비를
Methods
Events
-
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
## constructor @@ -492,6 +492,183 @@ InfiniteGrid의 보이는 그룹들을 반환한다. **Returns**: void +### trigger {#trigger} + +
+ inherited +
+ +커스텀 이벤트를 발생시킨다 + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스| +|params|Array<any> \| $ts:...|||커스텀 이벤트가 발생할 때 전달할 데이터| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +이벤트가 한번만 실행된다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +컴포넌트에 이벤트가 등록됐는지 확인한다. + +**Returns**: boolean +- 이벤트 등록 여부 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||등록 여부를 확인할 이벤트의 이름| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +컴포넌트에 이벤트를 등록한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +컴포넌트에 등록된 이벤트를 해제한다.
`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.
`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||해제할 이벤트의 이름| +|handlerToDetach|function \| $ts:...|✔️||해제할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + ## Events ### changeScroll {#event-changeScroll} diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/MasonryInfiniteGridOptions.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/MasonryInfiniteGridOptions.mdx index 62b43fddf..1f9a60bfa 100644 --- a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/MasonryInfiniteGridOptions.mdx +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/MasonryInfiniteGridOptions.mdx @@ -35,6 +35,7 @@ custom_edit_url: null |columnSize|number|0|열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. outlineSize 대신 사용할 수 있다.| |columnSizeRatio|number|0|열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다.| |align|GridAlign|"justify"|아이템들의 위치의 정렬. stretch를 사용하고 싶다면 column, columnSize 또는 maxStretchColumnSize 옵션을 설정해라. ("start", "center", "end", "justify", "stretch")| +|contentAlign|MasonryGridVerticalAlign|"masonry"|아이템들의 Content 방향의 정렬. "masonry"는 masonry 형태로 정렬이 된다. 그 외는 inline-block의 vertical-align과 유사하게 content 방향 정렬로 적용이 된다.칼럼(data-grid-column )을 여러개 설정하면 화면이 이상하게 보일 수 있다. | |columnCalculationThreshold|number|1|칼럼 개수를 계산하기 위한 차이 임계값. offset 사이즈는 반올림으로 게산하기 때문에 정확하지 않을 수 있다.| |maxStretchColumnSize|number|Infinity|stretch를 사용한 경우 최대로 늘릴 수 있는 column의 사이즈를 설정하여 column을 자동 계산할 수 있다.| |horizontal|boolean|false|스크롤 이동 방향. (true: 가로방향, false: 세로방향) horizontal이 false 면 inlinePos는 left, inlineSize는 width, contentPos는 top, contentSize는 height다. horizontal이 true면 inlinePos는 top, inlineSize는 height, contentPos는 left, contentSize는 width이다.| diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/PackingInfiniteGrid.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/PackingInfiniteGrid.mdx index f25421198..45df0e42f 100644 --- a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/PackingInfiniteGrid.mdx +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/current/api/PackingInfiniteGrid.mdx @@ -14,7 +14,7 @@ PackingInfiniteGrid는 아이템의 본래 크기에 따른 비중을 해치지
Methods
Events
-
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
## constructor @@ -492,6 +492,183 @@ InfiniteGrid의 보이는 그룹들을 반환한다. **Returns**: void +### trigger {#trigger} + +
+ inherited +
+ +커스텀 이벤트를 발생시킨다 + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스| +|params|Array<any> \| $ts:...|||커스텀 이벤트가 발생할 때 전달할 데이터| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +이벤트가 한번만 실행된다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +컴포넌트에 이벤트가 등록됐는지 확인한다. + +**Returns**: boolean +- 이벤트 등록 여부 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||등록 여부를 확인할 이벤트의 이름| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +컴포넌트에 이벤트를 등록한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +컴포넌트에 등록된 이벤트를 해제한다.
`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.
`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||해제할 이벤트의 이름| +|handlerToDetach|function \| $ts:...|✔️||해제할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + ## Events ### changeScroll {#event-changeScroll} diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/Component.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/Component.mdx new file mode 100644 index 000000000..a4d4c5e3a --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/Component.mdx @@ -0,0 +1,211 @@ +--- +custom_edit_url: null +--- + +```ts +class Component +``` + +
+ +
+ +컴포넌트의 이벤트을 관리할 수 있게 하는 클래스 + +
+
Properties
Methods
+
VERSIONstatic
trigger
once
hasOn
on
off
+
+ +## Properties +### VERSION {#VERSION} + +
+ static +
+ +버전정보 문자열 + +**Type**: string + +Component.VERSION; // ex) 3.0.0 + +## Methods + +### trigger {#trigger} + +
+ +
+ +커스텀 이벤트를 발생시킨다 + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스| +|params|Array<any> \| $ts:...|||커스텀 이벤트가 발생할 때 전달할 데이터| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ +
+ +이벤트가 한번만 실행된다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ +
+ +컴포넌트에 이벤트가 등록됐는지 확인한다. + +**Returns**: boolean +- 이벤트 등록 여부 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||등록 여부를 확인할 이벤트의 이름| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ +
+ +컴포넌트에 이벤트를 등록한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ +
+ +컴포넌트에 등록된 이벤트를 해제한다.
`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.
`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||해제할 이벤트의 이름| +|handlerToDetach|function \| $ts:...|✔️||해제할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/FrameInfiniteGrid.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/FrameInfiniteGrid.mdx new file mode 100644 index 000000000..71ed0aae2 --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/FrameInfiniteGrid.mdx @@ -0,0 +1,732 @@ +--- +custom_edit_url: null +--- + +```ts +class FrameInfiniteGrid +``` + +
+ +
+ +'Frame'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. FrameInfiniteGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템이 가득 차도록 배치하는 Grid다. + +
+
Methods
Events
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
+ +## constructor +```ts +new FrameInfiniteGrid(container, options) +``` + +
+ +
+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|container|HTMLElement \| string|||모듈을 적용할 기준 엘리먼트| +|options|[FrameInfiniteGridOptions](FrameInfiniteGridOptions)|||FrameGrid 모듈의 옵션 객체| + +## Methods + +### renderItems {#renderItems} + +
+ inherited +
+ +grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|options|RenderOptions|✔️|{}|렌더링을 하기 위한 옵션.| + +```ts +import { MasonryInfiniteGrid } from "@egjs/infinitegrid"; +const grid = new MasonryInfiniteGrid(); + +grid.on("renderComplete", e => { + console.log(e); +}); +grid.renderItems(); +``` + +### getWrapperElement {#getWrapperElement} + +
+ inherited +
+ +컨테이너 엘리먼트를 반환한다. + +### getScrollContainerElement {#getScrollContainerElement} + +
+ inherited +
+ +스크롤 영역에 해당하는 컨테이너 엘리먼트를 반환한다. + +### getContainerElement {#getContainerElement} + +
+ inherited +
+ +아이템 엘리먼트들을 담긴 컨테이너 엘리먼트를 반환한다. + +### syncItems {#syncItems} + +
+ inherited +
+ +items가 바뀐 경우 동기화를 하고 렌더링을 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|[InfiniteGridItemInfo](InfiniteGridItemInfo)[]|||렌더링을 하기 위한 옵션.| + +### setCursors {#setCursors} + +
+ inherited +
+ +현재 보이는 그룹들을 바꾼다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|startCursor|number|||보이는 그룹의 첫번째 index.| +|endCursor|number|||보이는 그룹의 마지막 index.| +|useFirstRender|boolean|✔️||첫 렌더링이 이미 되어있는지 여부.| + +### getStartCursor {#getStartCursor} + +
+ inherited +
+ +보이는 그룹들의 첫번째 index를 반환한다. + +**Returns**: number + +### getEndCursor {#getEndCursor} + +
+ inherited +
+ +보이는 그룹들의 마지막 index를 반환한다. + +**Returns**: number + +### append {#append} + +
+ inherited +
+ +아이템들을 grid 아래(오른쪽)에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```js +ig.append(`
test1
test2
`); +ig.append([`
test1
`, `
test2
`]); +ig.append([HTMLElement1, HTMLElement2]); +``` + +### prepend {#prepend} + +
+ inherited +
+ +아이템들을 grid 위(왼쪽)에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.prepend(`
test1
test2
`); +ig.prepend([`
test1
`, `
test2
`]); +ig.prepend([HTMLElement1, HTMLElement2]); +``` + +### insert {#insert} + +
+ inherited +
+ +아이템들을 특정 index에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||추가하기 위한 index| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.insert(2, `
test1
test2
`); +ig.insert(3, [`
test1
`, `
test2
`]); +ig.insert(4, [HTMLElement1, HTMLElement2]); +``` + +### insertByGroupIndex {#insertByGroupIndex} + +
+ inherited +
+ +group의 index 기준으로 item들을 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|groupIndex|number|||추가하기 위한 group의 index| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.insertByGroupIndex(2, `
test1
test2
`); +ig.insertByGroupIndex(3, [`
test1
`, `
test2
`]); +ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); +``` + +### getStatus {#getStatus} + +
+ inherited +
+ +아이템의 위치 정보 등 모듈의 현재 상태 정보를 반환한다. 이 메서드가 반환한 정보를 저장해 두었다가 setStatus() 메서드로 복원할 수 있다 + +**Returns**: [InfiniteGridStatus](InfiniteGridStatus) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|STATUS_TYPE|✔️|| STATUS_TYPE.NOT_REMOVE = 모든 아이템들의 정보를 가져온다. STATUS_TYPE.REMOVE_INVISIBLE_ITEMS = 보이는 아이템들의 정보만 가져온다. STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS = 안보이는 아이템들을 압축한다. placeholder로 대체가 가능하다. STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS = 안보이는 그룹을 압축한다.| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### setPlaceholder {#setPlaceholder} + +
+ inherited +
+ +status 복구 또는 아이템 추가 대기를 위한 placeholder를 설정할 수 있다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||placeholder의 status| + +### setLoading {#setLoading} + +
+ inherited +
+ +status 복구 또는 아이템 추가 대기를 위한 placeholder를 설정할 수 있다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||placeholder의 status| + +### appendPlaceholders {#appendPlaceholders} + +
+ inherited +
+ +placeholder들을 마지막에 추가한다. + +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||placeholder에 해당하는 아이템들. 숫자면 갯수만큼 복제를 한다.| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +### prependPlaceholders {#prependPlaceholders} + +
+ inherited +
+ +placeholder들을 처음에 추가한다. + +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||placeholder에 해당하는 아이템들. 숫자면 갯수만큼 복제를 한다.| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +### removePlaceholders {#removePlaceholders} + +
+ inherited +
+ +placeholder들을 삭제한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|"start" \| "end" \| {groupKey: string \| number}|||groupkey에 해당하는 placeholder들을 삭제한다. "start" 또는 "end" 일 때 해당 방향의 모든 placeholder들을 삭제한다.| + +### setStatus {#setStatus} + +
+ inherited +
+ +getStatus() 메서드가 저장한 정보로 InfiniteGrid 모듈의 상태를 설정한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|status|[InfiniteGridStatus](InfiniteGridStatus)|||InfiniteGrid 모듈의 status 객체.| +|useFirstRender|boolean|✔️||첫 렌더링이 이미 되어있는지 여부.| + +### removeGroupByIndex {#removeGroupByIndex} + +
+ inherited +
+ +index에 해당하는 그룹을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeGroupByKey {#removeGroupByKey} + +
+ inherited +
+ +key에 해당하는 그룹을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|number \| string|||| + +### removeByIndex {#removeByIndex} + +
+ inherited +
+ +index에 해당하는 아이템을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeByKey {#removeByKey} + +
+ inherited +
+ +key에 해당하는 아이템을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|string \| number|||| + +### updateItems {#updateItems} + +
+ inherited +
+ +아이템들의 사이즈를 업데이트하고 렌더링을 한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridItem[]|✔️||업데이트할 아이템들.| +|options|RenderOptions|✔️|{}|렌더링을 하기 위한 옵션.| + +### getItems {#getItems} + +
+ inherited +
+ +InfiniteGrid의 모든 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### getVisibleItems {#getVisibleItems} + +
+ inherited +
+ +InfiniteGrid의 보이는 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### getRenderingItems {#getRenderingItems} + +
+ inherited +
+ +InfiniteGrid의 렌더링 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +### getGroups {#getGroups} + +
+ inherited +
+ +InfiniteGrid의 모든 그룹들을 반환한다. + +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 그룹들을 포함할지 여부.| + +### getVisibleGroups {#getVisibleGroups} + +
+ inherited +
+ +InfiniteGrid의 보이는 그룹들을 반환한다. + +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 그룹들을 포함할지 여부.| + +### wait {#wait} + +
+ inherited +
+ +데이터를 요청하기 위해 대기 상태로 설정한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|direction|"start" \| "end"|✔️|DIRECTION.END|데이터를 추가하기 위한 방향.| + +### ready {#ready} + +
+ inherited +
+ +데이터 요청이 끝났다면 준비 상태로 설정한다. + +### isWait {#isWait} + +
+ inherited +
+ +데이터를 요청하기 위해 대기 상태로 설정되어 있는지 여부를 반환한다. + +### destroy {#destroy} + +
+ inherited +
+ +인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다. + +**Returns**: void + +### trigger {#trigger} + +
+ inherited +
+ +커스텀 이벤트를 발생시킨다 + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스| +|params|Array<any> \| $ts:...|||커스텀 이벤트가 발생할 때 전달할 데이터| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +이벤트가 한번만 실행된다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +컴포넌트에 이벤트가 등록됐는지 확인한다. + +**Returns**: boolean +- 이벤트 등록 여부 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||등록 여부를 확인할 이벤트의 이름| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +컴포넌트에 이벤트를 등록한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +컴포넌트에 등록된 이벤트를 해제한다.
`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.
`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||해제할 이벤트의 이름| +|handlerToDetach|function \| $ts:...|✔️||해제할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + +## Events +### changeScroll {#event-changeScroll} + +
+ inherited +
+ +스크롤하면 발생하는 이벤트이다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnChangeScroll|||이벤트에 전달되는 데이터 객체| + +### requestAppend {#event-requestAppend} + +
+ inherited +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestAppend|||이벤트에 전달되는 데이터 객체| + +### requestPrepend {#event-requestPrepend} + +
+ inherited +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestPrepend|||이벤트에 전달되는 데이터 객체| + +### contentError {#event-contentError} + +
+ inherited +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnContentError|||이벤트에 전달되는 데이터 객체| + +### renderComplete {#event-renderComplete} + +
+ inherited +
+ +InfiniteGrid가 렌더링이 완료됐을 때 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRenderComplete|||이벤트에 전달되는 데이터 객체| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/FrameInfiniteGridOptions.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/FrameInfiniteGridOptions.mdx new file mode 100644 index 000000000..0b5741784 --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/FrameInfiniteGridOptions.mdx @@ -0,0 +1,66 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:| +|horizontal|boolean|false|스크롤 이동 방향. (true: 가로방향, false: 세로방향) horizontal이 false 면 inlinePos는 left, inlineSize는 width, contentPos는 top, contentSize는 height다. horizontal이 true면 inlinePos는 top, inlineSize는 height, contentPos는 left, contentSize는 width이다.| +|percentage|Array<"position" \| "size"> \| boolean|false|item의 css size와 position를 %로 설정할지 여부.| +|isEqualSize|boolean|false|카드 엘리먼트의 크기가 동일한지 여부. 배치될 카드 엘리먼트의 크기가 모두 동일할 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|isConstantSize|boolean|false|모든 카드 엘리먼트의 크기가 불변일 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|gap|number|5|아이템들 사이의 공간.| +|attributePrefix|string|"data-grid-"|엘리먼트의 데이타 속성에 사용할 접두사.| +|resizeDebounce|number|100|리사이즈 이벤트에 설정할 디바운스 시간.(단위: ms)| +|maxResizeDebounce|number|0|리사이즈 이벤트를 디바운스할 수 있는 최대 시간. (0은 미설정이다)| +|autoResize|boolean|true|window의 resize 이벤트 이후 자동으로 resize()메소드를 호출할지의 여부.| +|useFit|boolean|true|렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다.| +|useTransform|boolean|false|left, top css 속성 쓰는 대신 transform 속성을 사용할지 여부.| +|renderOnPropertyChange|boolean|true|property의 변화를 통해 자동으로 render를 할지 여부.| +|preserveUIOnDestroy|boolean|false|destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.| +|defaultDirection|"start" \| "end"|"end"|render옵션에서 direction을 미설정시의 기본 방향값.| +|outlineLength|number|0|outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.| +|outlineSize|number|0| outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다. | +|useRoundedSize|boolean|true|사이즈를 반올림된 사이즈(offsetWidth, offsetHeight)로 가져올지 여부. container에 transform이 적용되어 있다면 true로 설정해라. false면 getBoundingClientRect를 통해 사이즈를 가져온다.| +|useResizeObserver|boolean|false|autoResize 옵션 사용시 container의 사이즈 변화 감지를 위해 ResizeObserver 이벤트를 사용할지 여부.| +|observeChildren|boolean|false|useResizeObserver옵션을 사용한다면 children의 사이즈 변화 감지 여부.| +|externalItemRenderer|ItemRenderer \| null||외부에서 직접 ItemRenderer를 설정할 수 있다.| +|externalContainerManager|ContainerManager \| null||외부에서 직접 ContainerManager를 설정할 수 있다.| +|frame|number[][]|[]|Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. (default: [])| +|useFrameFill|boolean|true| 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다.| +|rectSize|number \| {inlineSize: number, contentSize: number}|0|1x1 직사각형 크기. 0이면 frame의 column의 개수에 의해 결정된다.| +|horizontal|boolean|false|스크롤 이동 방향. (true: 가로방향, false: 세로방향) horizontal이 false 면 inlinePos는 left, inlineSize는 width, contentPos는 top, contentSize는 height다. horizontal이 true면 inlinePos는 top, inlineSize는 height, contentPos는 left, contentSize는 width이다.| +|percentage|Array<"position" \| "size"> \| boolean|false|item의 css size와 position를 %로 설정할지 여부.| +|isEqualSize|boolean|false|카드 엘리먼트의 크기가 동일한지 여부. 배치될 카드 엘리먼트의 크기가 모두 동일할 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|isConstantSize|boolean|false|모든 카드 엘리먼트의 크기가 불변일 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|gap|number|5|아이템들 사이의 공간.| +|attributePrefix|string|"data-grid-"|엘리먼트의 데이타 속성에 사용할 접두사.| +|resizeDebounce|number|100|리사이즈 이벤트에 설정할 디바운스 시간.(단위: ms)| +|maxResizeDebounce|number|0|리사이즈 이벤트를 디바운스할 수 있는 최대 시간. (0은 미설정이다)| +|autoResize|boolean|true|window의 resize 이벤트 이후 자동으로 resize()메소드를 호출할지의 여부.| +|useFit|boolean|true|렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다.| +|useTransform|boolean|false|left, top css 속성 쓰는 대신 transform 속성을 사용할지 여부.| +|renderOnPropertyChange|boolean|true|property의 변화를 통해 자동으로 render를 할지 여부.| +|preserveUIOnDestroy|boolean|false|destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.| +|defaultDirection|"start" \| "end"|"end"|render옵션에서 direction을 미설정시의 기본 방향값.| +|outlineLength|number|0|outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.| +|outlineSize|number|0| outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다. | +|useRoundedSize|boolean|true|사이즈를 반올림된 사이즈(offsetWidth, offsetHeight)로 가져올지 여부. container에 transform이 적용되어 있다면 true로 설정해라. false면 getBoundingClientRect를 통해 사이즈를 가져온다.| +|useResizeObserver|boolean|false|autoResize 옵션 사용시 container의 사이즈 변화 감지를 위해 ResizeObserver 이벤트를 사용할지 여부.| +|observeChildren|boolean|false|useResizeObserver옵션을 사용한다면 children의 사이즈 변화 감지 여부.| +|externalItemRenderer|ItemRenderer \| null||외부에서 직접 ItemRenderer를 설정할 수 있다.| +|externalContainerManager|ContainerManager \| null||외부에서 직접 ContainerManager를 설정할 수 있다.| +|container|boolean \| HTMLElement \| string \| Ref<HTMLElement>|false|container를 적용할 대상. false면 자기 자신, true면 container를 생성. string 또는 HTMLElement는 직접 대상을 지정.
| +|containerTag|string|"div"|container를 생성한다면 container의 tag를 정할 수 있다.
| +|threshold|number|100|다음 아이템 그룹을 추가하기 위한 스크롤 영역의 크기.
| +|useRecycle|boolean|true|보이는 영역의 DOM만 보여줄지 여부.
| +|scrollContainer|HTMLElement \| string \| Ref<HTMLElement> \| null||scrollContainer를 직접 정할 수 있다. 이 경우 container는 wrapper 자기 자신이 된다.
| +|gridConstructor|GridFunction||Infinite 기능을 적용할 Grid 클래스.
| +|appliedItemChecker|(item: InfiniteGridItem, grid: Grid) => boolean||렌더링 되지 않는 아이템를 Grid에 포함시킬지 체크하는 함수.
| +|renderer|Renderer \| null||DOM을 렌더하는 클래스.
| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/Grid.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/Grid.mdx new file mode 100644 index 000000000..51a6eb11f --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/Grid.mdx @@ -0,0 +1,583 @@ +--- +custom_edit_url: null +--- + +```ts +class Grid +``` + +
+ +
+ +
+
Properties
Methods
Events
+
gap
defaultDirection
useFit
preserveUIOnDestroy
outlineLength
outlineSize
applyGrid
getContainerElement
getItems
getChildren
setItems
getContainerInlineSize
getOutlines
setOutlines
syncElements
updateItems
renderItems
getStatus
setStatus
getComputedOutlineSize
getComputedOutlineLength
destroy
trigger
once
hasOn
on
off
contentError
renderComplete
+
+ +## constructor +```ts +new Grid(containerElement, options) +``` + +
+ +
+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|containerElement|HTMLElement \| string|||모듈을 적용할 기준 엘리먼트| +|options|Partial<Options>|✔️|{}|Grid 모듈의 옵션 객체| + +## Properties + +### gap {#gap} + +
+ +
+ +아이템들 사이의 공간. + +**Type**: $ts:Grid.GridOptions["gap"] + +**Default**: 0 + +```js +import { MasonryGrid } from "@egjs/grid"; + +const grid = new MasonryGrid(container, { + gap: 0, +}); + +grid.gap = 5; +``` + +### defaultDirection {#defaultDirection} + +
+ +
+ +render옵션에서 direction을 미설정시의 기본 방향값. + +**Type**: $ts:Grid.GridOptions["defaultDirection"] + +**Default**: "end" + +```js +import { MasonryGrid } from "@egjs/grid"; + +const grid = new MasonryGrid(container, { + defaultDirection: "end", +}); + +grid.defaultDirection = "start"; +``` + +### useFit {#useFit} + +
+ +
+ +렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다. (default: true) + +**Type**: $ts:Grid.GridOptions["useFit"] + +**Default**: true + +```js +import { MasonryGrid } from "@egjs/grid"; + +const grid = new MasonryGrid(container, { + useFit: true, +}); + +grid.useFit = false; +``` + +### preserveUIOnDestroy {#preserveUIOnDestroy} + +
+ +
+ +destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부. + +**Type**: $ts:Grid.GridOptions["preserveUIOnDestroy"] + +**Default**: false + +```js +import { MasonryGrid } from "@egjs/grid"; + +const grid = new MasonryGrid(container, { + preserveUIOnDestroy: false, +}); + +grid.preserveUIOnDestroy = true; +``` + +### outlineLength {#outlineLength} + +
+ +
+ +outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다. + +**Type**: $ts:Grid.GridOptions["outlineLength"] + +**Default**: 0 + +```js +import { MasonryGrid } from "@egjs/grid"; + +const grid = new MasonryGrid(container, { + outlineLength: 0, + outlineSize: 0, +}); + +grid.outlineLength = 3; +``` + +### outlineSize {#outlineSize} + +
+ +
+ +outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다. + +**Type**: $ts:Grid.GridOptions["outlineSize"] + +**Default**: 0 + +```js +import { MasonryGrid } from "@egjs/grid"; + +const grid = new MasonryGrid(container, { + outlineLength: 0, + outlineSize: 0, +}); + +grid.outlineSize = 300; +``` + +## Methods + +### applyGrid {#applyGrid} + +
+ +
+ +Grid에 맞게 아이템들의 CSS rect를 적용하고 outline을 계산한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|direcion|"start" \| "end"|||Grid를 적용할 방향. ("end": 시작에서 끝 방향, "start": 끝에서 시작 방향)| +|outline|Array<number>|||Grid를 적용할 시작 outline.| + +### getContainerElement {#getContainerElement} + +
+ +
+ +컨테이너 엘리먼트를 반환한다. + +**Returns**: HTMLElement + +### getItems {#getItems} + +
+ +
+ +아이템들을 반환한다. + +**Returns**: GridItem[] + +### getChildren {#getChildren} + +
+ +
+ +컨테이너 엘리먼트의 children을 반환한다. + +**Returns**: HTMLElement[] + +### setItems {#setItems} + +
+ +
+ +아이템들을 설정한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|GridItem[]|||설정할 아이템들| + +### getContainerInlineSize {#getContainerInlineSize} + +
+ +
+ +container의 inline 사이즈를 가져온다. (horizontal이 false면 "width", 아니면 "height") + +**Returns**: number + +### getOutlines {#getOutlines} + +
+ +
+ +Grid의 처음과 끝의 outline을 반환한다. + +**Returns**: GridOutlines + +### setOutlines {#setOutlines} + +
+ +
+ +아웃라인을 설정한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|outlines|GridOutlines|||설정할 아웃라인.| + +### syncElements {#syncElements} + +
+ +
+ +elements가 바뀐 경우 동기화를 하고 렌더링을 한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|options|RenderOptions|✔️|{}|렌더링을 하기 위한 옵션.| + +### updateItems {#updateItems} + +
+ +
+ +아이템들의 사이즈를 업데이트하고 렌더링을 한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|GridItem[]|✔️|this.items|업데이트할 아이템들.| +|options|RenderOptions|✔️|{}|렌더링을 하기 위한 옵션.| + +### renderItems {#renderItems} + +
+ +
+ +grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|options|RenderOptions|✔️|{}|렌더링을 하기 위한 옵션.| + +```js +import { MasonryGrid } from "@egjs/grid"; +const grid = new MasonryGrid(); + +grid.on("renderComplete", e => { + console.log(e); +}); +grid.renderItems(); +``` + +### getStatus {#getStatus} + +
+ +
+ +아이템의 위치, 사이즈 등 현재 상태를 반환한다. 반환한 상태는 setStatus() 메서드로 복원할 수 있다. + +**Returns**: GridStatus + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|minimize|boolean|✔️||item의 status를 최소화할지 여부. (default: false)| + +### setStatus {#setStatus} + +
+ +
+ +getStatus() 메서드에 대한 호출을 통해 반환된 상태로 Grid 모듈의 상태를 설정한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|status|GridStatus|||| + +### getComputedOutlineSize {#getComputedOutlineSize} + +
+ +
+ +outline에 해당하는 inline 사이즈를 구한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|GridItem[]|✔️|this.items|outline 사이즈를 구하기 위한 아이템들.| + +### getComputedOutlineLength {#getComputedOutlineLength} + +
+ +
+ +outline에 해당하는 length를 가져온다. + +**Returns**: number + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|GridItem[]|✔️|this.items|outline length를 구하기 위한 아이템들.| + +### destroy {#destroy} + +
+ +
+ +인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|Options|DestroyOptions|✔️|{}|destory()를 위한 옵션| + +### trigger {#trigger} + +
+ inherited +
+ +커스텀 이벤트를 발생시킨다 + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스| +|params|Array<any> \| $ts:...|||커스텀 이벤트가 발생할 때 전달할 데이터| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +이벤트가 한번만 실행된다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +컴포넌트에 이벤트가 등록됐는지 확인한다. + +**Returns**: boolean +- 이벤트 등록 여부 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||등록 여부를 확인할 이벤트의 이름| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +컴포넌트에 이벤트를 등록한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +컴포넌트에 등록된 이벤트를 해제한다.
`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.
`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||해제할 이벤트의 이름| +|handlerToDetach|function \| $ts:...|✔️||해제할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + +## Events +### contentError {#event-contentError} + +
+ +
+ +콘텐츠 로드에 에러가 날 때 발생하는 이벤트. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|[Grid.OnContentError](Grid:OnContentError)|||이벤트에 전달되는 데이터 객체| + +```js +grid.on("contentError", e => { + e.update(); +}); +``` + +### renderComplete {#event-renderComplete} + +
+ +
+ +Grid가 렌더링이 완료됐을 때 발생하는 이벤트이다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|[Grid.OnRenderComplete](Grid:OnRenderComplete)|||이벤트에 전달되는 데이터 객체| + +```js +grid.on("renderComplete", e => { + console.log(e.mounted, e.updated, e.useResize); +}); +``` + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InfiniteGrid.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InfiniteGrid.mdx new file mode 100644 index 000000000..bf87e55bc --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InfiniteGrid.mdx @@ -0,0 +1,763 @@ +--- +custom_edit_url: null +--- + +```ts +class InfiniteGrid extends Component +``` + +
+ +
+ +콘텐츠가 있는 아이템을 레이아웃 타입에 따라 무한으로 배치하는 모듈. 다양한 크기의 아이템을 다양한 레이아웃으로 배치할 수 있다. 아이템의 개수가 계속 늘어나도 모듈이 처리하는 DOM의 개수를 일정하게 유지해 최적의 성능을 보장한다 + +
+
Methods
Events
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
+ +## constructor +```ts +new InfiniteGrid(wrapper, options) +``` + +
+ +
+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|wrapper|HTMLElement \| string|||모듈을 적용할 기준 엘리먼트| +|options|Options|||eg.InfiniteGrid 모듈의 옵션 객체| + +```html + + +``` + +## Methods + +### renderItems {#renderItems} + +
+ +
+ +grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|options|RenderOptions|✔️|{}|렌더링을 하기 위한 옵션.| + +```ts +import { MasonryInfiniteGrid } from "@egjs/infinitegrid"; +const grid = new MasonryInfiniteGrid(); + +grid.on("renderComplete", e => { + console.log(e); +}); +grid.renderItems(); +``` + +### getWrapperElement {#getWrapperElement} + +
+ +
+ +컨테이너 엘리먼트를 반환한다. + +### getScrollContainerElement {#getScrollContainerElement} + +
+ +
+ +스크롤 영역에 해당하는 컨테이너 엘리먼트를 반환한다. + +### getContainerElement {#getContainerElement} + +
+ +
+ +아이템 엘리먼트들을 담긴 컨테이너 엘리먼트를 반환한다. + +### syncItems {#syncItems} + +
+ +
+ +items가 바뀐 경우 동기화를 하고 렌더링을 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|[InfiniteGridItemInfo](InfiniteGridItemInfo)[]|||렌더링을 하기 위한 옵션.| + +### setCursors {#setCursors} + +
+ +
+ +현재 보이는 그룹들을 바꾼다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|startCursor|number|||보이는 그룹의 첫번째 index.| +|endCursor|number|||보이는 그룹의 마지막 index.| +|useFirstRender|boolean|✔️||첫 렌더링이 이미 되어있는지 여부.| + +### getStartCursor {#getStartCursor} + +
+ +
+ +보이는 그룹들의 첫번째 index를 반환한다. + +**Returns**: number + +### getEndCursor {#getEndCursor} + +
+ +
+ +보이는 그룹들의 마지막 index를 반환한다. + +**Returns**: number + +### append {#append} + +
+ +
+ +아이템들을 grid 아래(오른쪽)에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```js +ig.append(`
test1
test2
`); +ig.append([`
test1
`, `
test2
`]); +ig.append([HTMLElement1, HTMLElement2]); +``` + +### prepend {#prepend} + +
+ +
+ +아이템들을 grid 위(왼쪽)에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.prepend(`
test1
test2
`); +ig.prepend([`
test1
`, `
test2
`]); +ig.prepend([HTMLElement1, HTMLElement2]); +``` + +### insert {#insert} + +
+ +
+ +아이템들을 특정 index에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||추가하기 위한 index| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.insert(2, `
test1
test2
`); +ig.insert(3, [`
test1
`, `
test2
`]); +ig.insert(4, [HTMLElement1, HTMLElement2]); +``` + +### insertByGroupIndex {#insertByGroupIndex} + +
+ +
+ +group의 index 기준으로 item들을 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|groupIndex|number|||추가하기 위한 group의 index| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.insertByGroupIndex(2, `
test1
test2
`); +ig.insertByGroupIndex(3, [`
test1
`, `
test2
`]); +ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); +``` + +### getStatus {#getStatus} + +
+ +
+ +아이템의 위치 정보 등 모듈의 현재 상태 정보를 반환한다. 이 메서드가 반환한 정보를 저장해 두었다가 setStatus() 메서드로 복원할 수 있다 + +**Returns**: [InfiniteGridStatus](InfiniteGridStatus) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|STATUS_TYPE|✔️|| STATUS_TYPE.NOT_REMOVE = 모든 아이템들의 정보를 가져온다. STATUS_TYPE.REMOVE_INVISIBLE_ITEMS = 보이는 아이템들의 정보만 가져온다. STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS = 안보이는 아이템들을 압축한다. placeholder로 대체가 가능하다. STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS = 안보이는 그룹을 압축한다.| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### setPlaceholder {#setPlaceholder} + +
+ +
+ +status 복구 또는 아이템 추가 대기를 위한 placeholder를 설정할 수 있다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||placeholder의 status| + +### setLoading {#setLoading} + +
+ +
+ +status 복구 또는 아이템 추가 대기를 위한 placeholder를 설정할 수 있다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||placeholder의 status| + +### appendPlaceholders {#appendPlaceholders} + +
+ +
+ +placeholder들을 마지막에 추가한다. + +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||placeholder에 해당하는 아이템들. 숫자면 갯수만큼 복제를 한다.| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +### prependPlaceholders {#prependPlaceholders} + +
+ +
+ +placeholder들을 처음에 추가한다. + +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||placeholder에 해당하는 아이템들. 숫자면 갯수만큼 복제를 한다.| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +### removePlaceholders {#removePlaceholders} + +
+ +
+ +placeholder들을 삭제한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|"start" \| "end" \| {groupKey: string \| number}|||groupkey에 해당하는 placeholder들을 삭제한다. "start" 또는 "end" 일 때 해당 방향의 모든 placeholder들을 삭제한다.| + +### setStatus {#setStatus} + +
+ +
+ +getStatus() 메서드가 저장한 정보로 InfiniteGrid 모듈의 상태를 설정한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|status|[InfiniteGridStatus](InfiniteGridStatus)|||InfiniteGrid 모듈의 status 객체.| +|useFirstRender|boolean|✔️||첫 렌더링이 이미 되어있는지 여부.| + +### removeGroupByIndex {#removeGroupByIndex} + +
+ +
+ +index에 해당하는 그룹을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeGroupByKey {#removeGroupByKey} + +
+ +
+ +key에 해당하는 그룹을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|number \| string|||| + +### removeByIndex {#removeByIndex} + +
+ +
+ +index에 해당하는 아이템을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeByKey {#removeByKey} + +
+ +
+ +key에 해당하는 아이템을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|string \| number|||| + +### updateItems {#updateItems} + +
+ +
+ +아이템들의 사이즈를 업데이트하고 렌더링을 한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridItem[]|✔️||업데이트할 아이템들.| +|options|RenderOptions|✔️|{}|렌더링을 하기 위한 옵션.| + +### getItems {#getItems} + +
+ +
+ +InfiniteGrid의 모든 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### getVisibleItems {#getVisibleItems} + +
+ +
+ +InfiniteGrid의 보이는 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### getRenderingItems {#getRenderingItems} + +
+ +
+ +InfiniteGrid의 렌더링 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +### getGroups {#getGroups} + +
+ +
+ +InfiniteGrid의 모든 그룹들을 반환한다. + +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 그룹들을 포함할지 여부.| + +### getVisibleGroups {#getVisibleGroups} + +
+ +
+ +InfiniteGrid의 보이는 그룹들을 반환한다. + +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 그룹들을 포함할지 여부.| + +### wait {#wait} + +
+ +
+ +데이터를 요청하기 위해 대기 상태로 설정한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|direction|"start" \| "end"|✔️|DIRECTION.END|데이터를 추가하기 위한 방향.| + +### ready {#ready} + +
+ +
+ +데이터 요청이 끝났다면 준비 상태로 설정한다. + +### isWait {#isWait} + +
+ +
+ +데이터를 요청하기 위해 대기 상태로 설정되어 있는지 여부를 반환한다. + +### destroy {#destroy} + +
+ +
+ +인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다. + +**Returns**: void + +### trigger {#trigger} + +
+ inherited +
+ +커스텀 이벤트를 발생시킨다 + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스| +|params|Array<any> \| $ts:...|||커스텀 이벤트가 발생할 때 전달할 데이터| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +이벤트가 한번만 실행된다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +컴포넌트에 이벤트가 등록됐는지 확인한다. + +**Returns**: boolean +- 이벤트 등록 여부 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||등록 여부를 확인할 이벤트의 이름| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +컴포넌트에 이벤트를 등록한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +컴포넌트에 등록된 이벤트를 해제한다.
`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.
`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||해제할 이벤트의 이름| +|handlerToDetach|function \| $ts:...|✔️||해제할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + +## Events +### changeScroll {#event-changeScroll} + +
+ +
+ +스크롤하면 발생하는 이벤트이다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnChangeScroll|||이벤트에 전달되는 데이터 객체| + +### requestAppend {#event-requestAppend} + +
+ +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestAppend|||이벤트에 전달되는 데이터 객체| + +### requestPrepend {#event-requestPrepend} + +
+ +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestPrepend|||이벤트에 전달되는 데이터 객체| + +### contentError {#event-contentError} + +
+ +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnContentError|||이벤트에 전달되는 데이터 객체| + +### renderComplete {#event-renderComplete} + +
+ +
+ +InfiniteGrid가 렌더링이 완료됐을 때 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRenderComplete|||이벤트에 전달되는 데이터 객체| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InfiniteGridItemInfo.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InfiniteGridItemInfo.mdx new file mode 100644 index 000000000..82c858594 --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InfiniteGridItemInfo.mdx @@ -0,0 +1,21 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|type|ITEM_TYPE|| +|groupKey|string \| number|| +|inserted|boolean|| +|key|string \| number|| +|element|HTMLElement \| null|| +|html|string|| +|data|Record<string, any>|| +|attributes|Record<string, any>|| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InfiniteGridOptions.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InfiniteGridOptions.mdx new file mode 100644 index 000000000..716650aa9 --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InfiniteGridOptions.mdx @@ -0,0 +1,42 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:| +|horizontal|boolean|false|스크롤 이동 방향. (true: 가로방향, false: 세로방향) horizontal이 false 면 inlinePos는 left, inlineSize는 width, contentPos는 top, contentSize는 height다. horizontal이 true면 inlinePos는 top, inlineSize는 height, contentPos는 left, contentSize는 width이다.| +|percentage|Array<"position" \| "size"> \| boolean|false|item의 css size와 position를 %로 설정할지 여부.| +|isEqualSize|boolean|false|카드 엘리먼트의 크기가 동일한지 여부. 배치될 카드 엘리먼트의 크기가 모두 동일할 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|isConstantSize|boolean|false|모든 카드 엘리먼트의 크기가 불변일 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|gap|number|5|아이템들 사이의 공간.| +|attributePrefix|string|"data-grid-"|엘리먼트의 데이타 속성에 사용할 접두사.| +|resizeDebounce|number|100|리사이즈 이벤트에 설정할 디바운스 시간.(단위: ms)| +|maxResizeDebounce|number|0|리사이즈 이벤트를 디바운스할 수 있는 최대 시간. (0은 미설정이다)| +|autoResize|boolean|true|window의 resize 이벤트 이후 자동으로 resize()메소드를 호출할지의 여부.| +|useFit|boolean|true|렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다.| +|useTransform|boolean|false|left, top css 속성 쓰는 대신 transform 속성을 사용할지 여부.| +|renderOnPropertyChange|boolean|true|property의 변화를 통해 자동으로 render를 할지 여부.| +|preserveUIOnDestroy|boolean|false|destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.| +|defaultDirection|"start" \| "end"|"end"|render옵션에서 direction을 미설정시의 기본 방향값.| +|outlineLength|number|0|outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.| +|outlineSize|number|0| outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다. | +|useRoundedSize|boolean|true|사이즈를 반올림된 사이즈(offsetWidth, offsetHeight)로 가져올지 여부. container에 transform이 적용되어 있다면 true로 설정해라. false면 getBoundingClientRect를 통해 사이즈를 가져온다.| +|useResizeObserver|boolean|false|autoResize 옵션 사용시 container의 사이즈 변화 감지를 위해 ResizeObserver 이벤트를 사용할지 여부.| +|observeChildren|boolean|false|useResizeObserver옵션을 사용한다면 children의 사이즈 변화 감지 여부.| +|externalItemRenderer|ItemRenderer \| null||외부에서 직접 ItemRenderer를 설정할 수 있다.| +|externalContainerManager|ContainerManager \| null||외부에서 직접 ContainerManager를 설정할 수 있다.| +|container|boolean \| HTMLElement \| string \| Ref<HTMLElement>|false|container를 적용할 대상. false면 자기 자신, true면 container를 생성. string 또는 HTMLElement는 직접 대상을 지정.
| +|containerTag|string|"div"|container를 생성한다면 container의 tag를 정할 수 있다.
| +|threshold|number|100|다음 아이템 그룹을 추가하기 위한 스크롤 영역의 크기.
| +|useRecycle|boolean|true|보이는 영역의 DOM만 보여줄지 여부.
| +|scrollContainer|HTMLElement \| string \| Ref<HTMLElement> \| null||scrollContainer를 직접 정할 수 있다. 이 경우 container는 wrapper 자기 자신이 된다.
| +|gridConstructor|GridFunction||Infinite 기능을 적용할 Grid 클래스.
| +|appliedItemChecker|(item: InfiniteGridItem, grid: Grid) => boolean||렌더링 되지 않는 아이템를 Grid에 포함시킬지 체크하는 함수.
| +|renderer|Renderer \| null||DOM을 렌더하는 클래스.
| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InfiniteGridStatus.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InfiniteGridStatus.mdx new file mode 100644 index 000000000..d72132f97 --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InfiniteGridStatus.mdx @@ -0,0 +1,17 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|itemRenderer|ItemRendererStatus|| +|containerManager|ContainerManagerStatus|| +|groupManager|GroupManagerStatus|| +|scrollManager|ScrollManagerStatus|| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InsertedPlaceholdersResult.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InsertedPlaceholdersResult.mdx new file mode 100644 index 000000000..95315fca4 --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/InsertedPlaceholdersResult.mdx @@ -0,0 +1,16 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|group|InfiniteGridGroup|placholder에 해당하는 그룹| +|items|InfiniteGridItem[]|placholder에 해당하는 아이템들| +|remove|() => void|추가한 placeholder들을 삭제한다.| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/JustifiedInfiniteGrid.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/JustifiedInfiniteGrid.mdx new file mode 100644 index 000000000..434399c69 --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/JustifiedInfiniteGrid.mdx @@ -0,0 +1,732 @@ +--- +custom_edit_url: null +--- + +```ts +class JustifiedInfiniteGrid +``` + +
+ +
+ +'justified'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. JustifiedInfiniteGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템가 가득 차도록 배치하는 Grid다.
아이템 엘리먼트에 'data-grid-inline-offset' 또는 'data-grid-content-offset'를 설정하면 offset 값을 제외하고 비율을 유지한다.
비율을 유지하고 싶은 엘리먼트에 'data-grid-maintained-target'을 설정한다면 해당 엘리먼트의 비율을 유지하면서 아이템이 렌더링이 된다. + +
+
Methods
Events
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
+ +## constructor +```ts +new JustifiedInfiniteGrid(container, options) +``` + +
+ +
+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|container|HTMLElement \| string|||모듈을 적용할 기준 엘리먼트| +|options|[JustifiedInfiniteGridOptions](JustifiedInfiniteGridOptions)|||JustifiedInfiniteGrid 모듈의 옵션 객체| + +## Methods + +### renderItems {#renderItems} + +
+ inherited +
+ +grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|options|RenderOptions|✔️|{}|렌더링을 하기 위한 옵션.| + +```ts +import { MasonryInfiniteGrid } from "@egjs/infinitegrid"; +const grid = new MasonryInfiniteGrid(); + +grid.on("renderComplete", e => { + console.log(e); +}); +grid.renderItems(); +``` + +### getWrapperElement {#getWrapperElement} + +
+ inherited +
+ +컨테이너 엘리먼트를 반환한다. + +### getScrollContainerElement {#getScrollContainerElement} + +
+ inherited +
+ +스크롤 영역에 해당하는 컨테이너 엘리먼트를 반환한다. + +### getContainerElement {#getContainerElement} + +
+ inherited +
+ +아이템 엘리먼트들을 담긴 컨테이너 엘리먼트를 반환한다. + +### syncItems {#syncItems} + +
+ inherited +
+ +items가 바뀐 경우 동기화를 하고 렌더링을 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|[InfiniteGridItemInfo](InfiniteGridItemInfo)[]|||렌더링을 하기 위한 옵션.| + +### setCursors {#setCursors} + +
+ inherited +
+ +현재 보이는 그룹들을 바꾼다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|startCursor|number|||보이는 그룹의 첫번째 index.| +|endCursor|number|||보이는 그룹의 마지막 index.| +|useFirstRender|boolean|✔️||첫 렌더링이 이미 되어있는지 여부.| + +### getStartCursor {#getStartCursor} + +
+ inherited +
+ +보이는 그룹들의 첫번째 index를 반환한다. + +**Returns**: number + +### getEndCursor {#getEndCursor} + +
+ inherited +
+ +보이는 그룹들의 마지막 index를 반환한다. + +**Returns**: number + +### append {#append} + +
+ inherited +
+ +아이템들을 grid 아래(오른쪽)에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```js +ig.append(`
test1
test2
`); +ig.append([`
test1
`, `
test2
`]); +ig.append([HTMLElement1, HTMLElement2]); +``` + +### prepend {#prepend} + +
+ inherited +
+ +아이템들을 grid 위(왼쪽)에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.prepend(`
test1
test2
`); +ig.prepend([`
test1
`, `
test2
`]); +ig.prepend([HTMLElement1, HTMLElement2]); +``` + +### insert {#insert} + +
+ inherited +
+ +아이템들을 특정 index에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||추가하기 위한 index| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.insert(2, `
test1
test2
`); +ig.insert(3, [`
test1
`, `
test2
`]); +ig.insert(4, [HTMLElement1, HTMLElement2]); +``` + +### insertByGroupIndex {#insertByGroupIndex} + +
+ inherited +
+ +group의 index 기준으로 item들을 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|groupIndex|number|||추가하기 위한 group의 index| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.insertByGroupIndex(2, `
test1
test2
`); +ig.insertByGroupIndex(3, [`
test1
`, `
test2
`]); +ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); +``` + +### getStatus {#getStatus} + +
+ inherited +
+ +아이템의 위치 정보 등 모듈의 현재 상태 정보를 반환한다. 이 메서드가 반환한 정보를 저장해 두었다가 setStatus() 메서드로 복원할 수 있다 + +**Returns**: [InfiniteGridStatus](InfiniteGridStatus) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|STATUS_TYPE|✔️|| STATUS_TYPE.NOT_REMOVE = 모든 아이템들의 정보를 가져온다. STATUS_TYPE.REMOVE_INVISIBLE_ITEMS = 보이는 아이템들의 정보만 가져온다. STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS = 안보이는 아이템들을 압축한다. placeholder로 대체가 가능하다. STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS = 안보이는 그룹을 압축한다.| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### setPlaceholder {#setPlaceholder} + +
+ inherited +
+ +status 복구 또는 아이템 추가 대기를 위한 placeholder를 설정할 수 있다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||placeholder의 status| + +### setLoading {#setLoading} + +
+ inherited +
+ +status 복구 또는 아이템 추가 대기를 위한 placeholder를 설정할 수 있다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||placeholder의 status| + +### appendPlaceholders {#appendPlaceholders} + +
+ inherited +
+ +placeholder들을 마지막에 추가한다. + +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||placeholder에 해당하는 아이템들. 숫자면 갯수만큼 복제를 한다.| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +### prependPlaceholders {#prependPlaceholders} + +
+ inherited +
+ +placeholder들을 처음에 추가한다. + +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||placeholder에 해당하는 아이템들. 숫자면 갯수만큼 복제를 한다.| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +### removePlaceholders {#removePlaceholders} + +
+ inherited +
+ +placeholder들을 삭제한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|"start" \| "end" \| {groupKey: string \| number}|||groupkey에 해당하는 placeholder들을 삭제한다. "start" 또는 "end" 일 때 해당 방향의 모든 placeholder들을 삭제한다.| + +### setStatus {#setStatus} + +
+ inherited +
+ +getStatus() 메서드가 저장한 정보로 InfiniteGrid 모듈의 상태를 설정한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|status|[InfiniteGridStatus](InfiniteGridStatus)|||InfiniteGrid 모듈의 status 객체.| +|useFirstRender|boolean|✔️||첫 렌더링이 이미 되어있는지 여부.| + +### removeGroupByIndex {#removeGroupByIndex} + +
+ inherited +
+ +index에 해당하는 그룹을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeGroupByKey {#removeGroupByKey} + +
+ inherited +
+ +key에 해당하는 그룹을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|number \| string|||| + +### removeByIndex {#removeByIndex} + +
+ inherited +
+ +index에 해당하는 아이템을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeByKey {#removeByKey} + +
+ inherited +
+ +key에 해당하는 아이템을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|string \| number|||| + +### updateItems {#updateItems} + +
+ inherited +
+ +아이템들의 사이즈를 업데이트하고 렌더링을 한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridItem[]|✔️||업데이트할 아이템들.| +|options|RenderOptions|✔️|{}|렌더링을 하기 위한 옵션.| + +### getItems {#getItems} + +
+ inherited +
+ +InfiniteGrid의 모든 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### getVisibleItems {#getVisibleItems} + +
+ inherited +
+ +InfiniteGrid의 보이는 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### getRenderingItems {#getRenderingItems} + +
+ inherited +
+ +InfiniteGrid의 렌더링 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +### getGroups {#getGroups} + +
+ inherited +
+ +InfiniteGrid의 모든 그룹들을 반환한다. + +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 그룹들을 포함할지 여부.| + +### getVisibleGroups {#getVisibleGroups} + +
+ inherited +
+ +InfiniteGrid의 보이는 그룹들을 반환한다. + +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 그룹들을 포함할지 여부.| + +### wait {#wait} + +
+ inherited +
+ +데이터를 요청하기 위해 대기 상태로 설정한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|direction|"start" \| "end"|✔️|DIRECTION.END|데이터를 추가하기 위한 방향.| + +### ready {#ready} + +
+ inherited +
+ +데이터 요청이 끝났다면 준비 상태로 설정한다. + +### isWait {#isWait} + +
+ inherited +
+ +데이터를 요청하기 위해 대기 상태로 설정되어 있는지 여부를 반환한다. + +### destroy {#destroy} + +
+ inherited +
+ +인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다. + +**Returns**: void + +### trigger {#trigger} + +
+ inherited +
+ +커스텀 이벤트를 발생시킨다 + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스| +|params|Array<any> \| $ts:...|||커스텀 이벤트가 발생할 때 전달할 데이터| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +이벤트가 한번만 실행된다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +컴포넌트에 이벤트가 등록됐는지 확인한다. + +**Returns**: boolean +- 이벤트 등록 여부 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||등록 여부를 확인할 이벤트의 이름| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +컴포넌트에 이벤트를 등록한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +컴포넌트에 등록된 이벤트를 해제한다.
`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.
`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||해제할 이벤트의 이름| +|handlerToDetach|function \| $ts:...|✔️||해제할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + +## Events +### changeScroll {#event-changeScroll} + +
+ inherited +
+ +스크롤하면 발생하는 이벤트이다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnChangeScroll|||이벤트에 전달되는 데이터 객체| + +### requestAppend {#event-requestAppend} + +
+ inherited +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestAppend|||이벤트에 전달되는 데이터 객체| + +### requestPrepend {#event-requestPrepend} + +
+ inherited +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestPrepend|||이벤트에 전달되는 데이터 객체| + +### contentError {#event-contentError} + +
+ inherited +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnContentError|||이벤트에 전달되는 데이터 객체| + +### renderComplete {#event-renderComplete} + +
+ inherited +
+ +InfiniteGrid가 렌더링이 완료됐을 때 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRenderComplete|||이벤트에 전달되는 데이터 객체| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/JustifiedInfiniteGridOptions.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/JustifiedInfiniteGridOptions.mdx new file mode 100644 index 000000000..a7199999e --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/JustifiedInfiniteGridOptions.mdx @@ -0,0 +1,68 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:| +|horizontal|boolean|false|스크롤 이동 방향. (true: 가로방향, false: 세로방향) horizontal이 false 면 inlinePos는 left, inlineSize는 width, contentPos는 top, contentSize는 height다. horizontal이 true면 inlinePos는 top, inlineSize는 height, contentPos는 left, contentSize는 width이다.| +|percentage|Array<"position" \| "size"> \| boolean|false|item의 css size와 position를 %로 설정할지 여부.| +|isEqualSize|boolean|false|카드 엘리먼트의 크기가 동일한지 여부. 배치될 카드 엘리먼트의 크기가 모두 동일할 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|isConstantSize|boolean|false|모든 카드 엘리먼트의 크기가 불변일 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|gap|number|5|아이템들 사이의 공간.| +|attributePrefix|string|"data-grid-"|엘리먼트의 데이타 속성에 사용할 접두사.| +|resizeDebounce|number|100|리사이즈 이벤트에 설정할 디바운스 시간.(단위: ms)| +|maxResizeDebounce|number|0|리사이즈 이벤트를 디바운스할 수 있는 최대 시간. (0은 미설정이다)| +|autoResize|boolean|true|window의 resize 이벤트 이후 자동으로 resize()메소드를 호출할지의 여부.| +|useFit|boolean|true|렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다.| +|useTransform|boolean|false|left, top css 속성 쓰는 대신 transform 속성을 사용할지 여부.| +|renderOnPropertyChange|boolean|true|property의 변화를 통해 자동으로 render를 할지 여부.| +|preserveUIOnDestroy|boolean|false|destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.| +|defaultDirection|"start" \| "end"|"end"|render옵션에서 direction을 미설정시의 기본 방향값.| +|outlineLength|number|0|outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.| +|outlineSize|number|0| outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다. | +|useRoundedSize|boolean|true|사이즈를 반올림된 사이즈(offsetWidth, offsetHeight)로 가져올지 여부. container에 transform이 적용되어 있다면 true로 설정해라. false면 getBoundingClientRect를 통해 사이즈를 가져온다.| +|useResizeObserver|boolean|false|autoResize 옵션 사용시 container의 사이즈 변화 감지를 위해 ResizeObserver 이벤트를 사용할지 여부.| +|observeChildren|boolean|false|useResizeObserver옵션을 사용한다면 children의 사이즈 변화 감지 여부.| +|externalItemRenderer|ItemRenderer \| null||외부에서 직접 ItemRenderer를 설정할 수 있다.| +|externalContainerManager|ContainerManager \| null||외부에서 직접 ContainerManager를 설정할 수 있다.| +|columnRange|number \| number[]|[1, 8]| 한 줄에 들어가는 아이템의 최소, 최대 개수.| +|rowRange|number \| number[]|0| 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다.| +|sizeRange|number \| number[]|[0, Infinity]|아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다.| +|displayedRow|number|-1|컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다.| +|isCroppedSize|boolean|false|row사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다.| +|horizontal|boolean|false|스크롤 이동 방향. (true: 가로방향, false: 세로방향) horizontal이 false 면 inlinePos는 left, inlineSize는 width, contentPos는 top, contentSize는 height다. horizontal이 true면 inlinePos는 top, inlineSize는 height, contentPos는 left, contentSize는 width이다.| +|percentage|Array<"position" \| "size"> \| boolean|false|item의 css size와 position를 %로 설정할지 여부.| +|isEqualSize|boolean|false|카드 엘리먼트의 크기가 동일한지 여부. 배치될 카드 엘리먼트의 크기가 모두 동일할 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|isConstantSize|boolean|false|모든 카드 엘리먼트의 크기가 불변일 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|gap|number|5|아이템들 사이의 공간.| +|attributePrefix|string|"data-grid-"|엘리먼트의 데이타 속성에 사용할 접두사.| +|resizeDebounce|number|100|리사이즈 이벤트에 설정할 디바운스 시간.(단위: ms)| +|maxResizeDebounce|number|0|리사이즈 이벤트를 디바운스할 수 있는 최대 시간. (0은 미설정이다)| +|autoResize|boolean|true|window의 resize 이벤트 이후 자동으로 resize()메소드를 호출할지의 여부.| +|useFit|boolean|true|렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다.| +|useTransform|boolean|false|left, top css 속성 쓰는 대신 transform 속성을 사용할지 여부.| +|renderOnPropertyChange|boolean|true|property의 변화를 통해 자동으로 render를 할지 여부.| +|preserveUIOnDestroy|boolean|false|destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.| +|defaultDirection|"start" \| "end"|"end"|render옵션에서 direction을 미설정시의 기본 방향값.| +|outlineLength|number|0|outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.| +|outlineSize|number|0| outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다. | +|useRoundedSize|boolean|true|사이즈를 반올림된 사이즈(offsetWidth, offsetHeight)로 가져올지 여부. container에 transform이 적용되어 있다면 true로 설정해라. false면 getBoundingClientRect를 통해 사이즈를 가져온다.| +|useResizeObserver|boolean|false|autoResize 옵션 사용시 container의 사이즈 변화 감지를 위해 ResizeObserver 이벤트를 사용할지 여부.| +|observeChildren|boolean|false|useResizeObserver옵션을 사용한다면 children의 사이즈 변화 감지 여부.| +|externalItemRenderer|ItemRenderer \| null||외부에서 직접 ItemRenderer를 설정할 수 있다.| +|externalContainerManager|ContainerManager \| null||외부에서 직접 ContainerManager를 설정할 수 있다.| +|container|boolean \| HTMLElement \| string \| Ref<HTMLElement>|false|container를 적용할 대상. false면 자기 자신, true면 container를 생성. string 또는 HTMLElement는 직접 대상을 지정.
| +|containerTag|string|"div"|container를 생성한다면 container의 tag를 정할 수 있다.
| +|threshold|number|100|다음 아이템 그룹을 추가하기 위한 스크롤 영역의 크기.
| +|useRecycle|boolean|true|보이는 영역의 DOM만 보여줄지 여부.
| +|scrollContainer|HTMLElement \| string \| Ref<HTMLElement> \| null||scrollContainer를 직접 정할 수 있다. 이 경우 container는 wrapper 자기 자신이 된다.
| +|gridConstructor|GridFunction||Infinite 기능을 적용할 Grid 클래스.
| +|appliedItemChecker|(item: InfiniteGridItem, grid: Grid) => boolean||렌더링 되지 않는 아이템를 Grid에 포함시킬지 체크하는 함수.
| +|renderer|Renderer \| null||DOM을 렌더하는 클래스.
| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/MasonryInfiniteGrid.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/MasonryInfiniteGrid.mdx new file mode 100644 index 000000000..5d32abb5d --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/MasonryInfiniteGrid.mdx @@ -0,0 +1,732 @@ +--- +custom_edit_url: null +--- + +```ts +class MasonryInfiniteGrid +``` + +
+ +
+ +MasonryInfiniteGrid는 벽돌을 쌓아 올린 모양처럼 동일한 너비를 가진 아이템을 쌓는 레이아웃이다. 모든 이미지의 너비를 동일한 크기로 조정하고, 가장 높이가 낮은 열을 찾아 새로운 이미지를 삽입한다. 따라서 배치된 아이템 사이에 빈 공간이 생기지는 않지만 배치된 레이아웃의 아래쪽은 울퉁불퉁해진다. + +
+
Methods
Events
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
+ +## constructor +```ts +new MasonryInfiniteGrid(container, options) +``` + +
+ +
+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|container|HTMLElement \| string|||모듈을 적용할 기준 엘리먼트| +|options|[MasonryInfiniteGridOptions](MasonryInfiniteGridOptions)|||MasonryInfiniteGrid 모듈의 옵션 객체| + +## Methods + +### renderItems {#renderItems} + +
+ inherited +
+ +grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|options|RenderOptions|✔️|{}|렌더링을 하기 위한 옵션.| + +```ts +import { MasonryInfiniteGrid } from "@egjs/infinitegrid"; +const grid = new MasonryInfiniteGrid(); + +grid.on("renderComplete", e => { + console.log(e); +}); +grid.renderItems(); +``` + +### getWrapperElement {#getWrapperElement} + +
+ inherited +
+ +컨테이너 엘리먼트를 반환한다. + +### getScrollContainerElement {#getScrollContainerElement} + +
+ inherited +
+ +스크롤 영역에 해당하는 컨테이너 엘리먼트를 반환한다. + +### getContainerElement {#getContainerElement} + +
+ inherited +
+ +아이템 엘리먼트들을 담긴 컨테이너 엘리먼트를 반환한다. + +### syncItems {#syncItems} + +
+ inherited +
+ +items가 바뀐 경우 동기화를 하고 렌더링을 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|[InfiniteGridItemInfo](InfiniteGridItemInfo)[]|||렌더링을 하기 위한 옵션.| + +### setCursors {#setCursors} + +
+ inherited +
+ +현재 보이는 그룹들을 바꾼다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|startCursor|number|||보이는 그룹의 첫번째 index.| +|endCursor|number|||보이는 그룹의 마지막 index.| +|useFirstRender|boolean|✔️||첫 렌더링이 이미 되어있는지 여부.| + +### getStartCursor {#getStartCursor} + +
+ inherited +
+ +보이는 그룹들의 첫번째 index를 반환한다. + +**Returns**: number + +### getEndCursor {#getEndCursor} + +
+ inherited +
+ +보이는 그룹들의 마지막 index를 반환한다. + +**Returns**: number + +### append {#append} + +
+ inherited +
+ +아이템들을 grid 아래(오른쪽)에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```js +ig.append(`
test1
test2
`); +ig.append([`
test1
`, `
test2
`]); +ig.append([HTMLElement1, HTMLElement2]); +``` + +### prepend {#prepend} + +
+ inherited +
+ +아이템들을 grid 위(왼쪽)에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.prepend(`
test1
test2
`); +ig.prepend([`
test1
`, `
test2
`]); +ig.prepend([HTMLElement1, HTMLElement2]); +``` + +### insert {#insert} + +
+ inherited +
+ +아이템들을 특정 index에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||추가하기 위한 index| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.insert(2, `
test1
test2
`); +ig.insert(3, [`
test1
`, `
test2
`]); +ig.insert(4, [HTMLElement1, HTMLElement2]); +``` + +### insertByGroupIndex {#insertByGroupIndex} + +
+ inherited +
+ +group의 index 기준으로 item들을 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|groupIndex|number|||추가하기 위한 group의 index| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.insertByGroupIndex(2, `
test1
test2
`); +ig.insertByGroupIndex(3, [`
test1
`, `
test2
`]); +ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); +``` + +### getStatus {#getStatus} + +
+ inherited +
+ +아이템의 위치 정보 등 모듈의 현재 상태 정보를 반환한다. 이 메서드가 반환한 정보를 저장해 두었다가 setStatus() 메서드로 복원할 수 있다 + +**Returns**: [InfiniteGridStatus](InfiniteGridStatus) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|STATUS_TYPE|✔️|| STATUS_TYPE.NOT_REMOVE = 모든 아이템들의 정보를 가져온다. STATUS_TYPE.REMOVE_INVISIBLE_ITEMS = 보이는 아이템들의 정보만 가져온다. STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS = 안보이는 아이템들을 압축한다. placeholder로 대체가 가능하다. STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS = 안보이는 그룹을 압축한다.| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### setPlaceholder {#setPlaceholder} + +
+ inherited +
+ +status 복구 또는 아이템 추가 대기를 위한 placeholder를 설정할 수 있다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||placeholder의 status| + +### setLoading {#setLoading} + +
+ inherited +
+ +status 복구 또는 아이템 추가 대기를 위한 placeholder를 설정할 수 있다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||placeholder의 status| + +### appendPlaceholders {#appendPlaceholders} + +
+ inherited +
+ +placeholder들을 마지막에 추가한다. + +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||placeholder에 해당하는 아이템들. 숫자면 갯수만큼 복제를 한다.| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +### prependPlaceholders {#prependPlaceholders} + +
+ inherited +
+ +placeholder들을 처음에 추가한다. + +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||placeholder에 해당하는 아이템들. 숫자면 갯수만큼 복제를 한다.| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +### removePlaceholders {#removePlaceholders} + +
+ inherited +
+ +placeholder들을 삭제한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|"start" \| "end" \| {groupKey: string \| number}|||groupkey에 해당하는 placeholder들을 삭제한다. "start" 또는 "end" 일 때 해당 방향의 모든 placeholder들을 삭제한다.| + +### setStatus {#setStatus} + +
+ inherited +
+ +getStatus() 메서드가 저장한 정보로 InfiniteGrid 모듈의 상태를 설정한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|status|[InfiniteGridStatus](InfiniteGridStatus)|||InfiniteGrid 모듈의 status 객체.| +|useFirstRender|boolean|✔️||첫 렌더링이 이미 되어있는지 여부.| + +### removeGroupByIndex {#removeGroupByIndex} + +
+ inherited +
+ +index에 해당하는 그룹을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeGroupByKey {#removeGroupByKey} + +
+ inherited +
+ +key에 해당하는 그룹을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|number \| string|||| + +### removeByIndex {#removeByIndex} + +
+ inherited +
+ +index에 해당하는 아이템을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeByKey {#removeByKey} + +
+ inherited +
+ +key에 해당하는 아이템을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|string \| number|||| + +### updateItems {#updateItems} + +
+ inherited +
+ +아이템들의 사이즈를 업데이트하고 렌더링을 한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridItem[]|✔️||업데이트할 아이템들.| +|options|RenderOptions|✔️|{}|렌더링을 하기 위한 옵션.| + +### getItems {#getItems} + +
+ inherited +
+ +InfiniteGrid의 모든 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### getVisibleItems {#getVisibleItems} + +
+ inherited +
+ +InfiniteGrid의 보이는 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### getRenderingItems {#getRenderingItems} + +
+ inherited +
+ +InfiniteGrid의 렌더링 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +### getGroups {#getGroups} + +
+ inherited +
+ +InfiniteGrid의 모든 그룹들을 반환한다. + +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 그룹들을 포함할지 여부.| + +### getVisibleGroups {#getVisibleGroups} + +
+ inherited +
+ +InfiniteGrid의 보이는 그룹들을 반환한다. + +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 그룹들을 포함할지 여부.| + +### wait {#wait} + +
+ inherited +
+ +데이터를 요청하기 위해 대기 상태로 설정한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|direction|"start" \| "end"|✔️|DIRECTION.END|데이터를 추가하기 위한 방향.| + +### ready {#ready} + +
+ inherited +
+ +데이터 요청이 끝났다면 준비 상태로 설정한다. + +### isWait {#isWait} + +
+ inherited +
+ +데이터를 요청하기 위해 대기 상태로 설정되어 있는지 여부를 반환한다. + +### destroy {#destroy} + +
+ inherited +
+ +인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다. + +**Returns**: void + +### trigger {#trigger} + +
+ inherited +
+ +커스텀 이벤트를 발생시킨다 + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스| +|params|Array<any> \| $ts:...|||커스텀 이벤트가 발생할 때 전달할 데이터| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +이벤트가 한번만 실행된다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +컴포넌트에 이벤트가 등록됐는지 확인한다. + +**Returns**: boolean +- 이벤트 등록 여부 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||등록 여부를 확인할 이벤트의 이름| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +컴포넌트에 이벤트를 등록한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +컴포넌트에 등록된 이벤트를 해제한다.
`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.
`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||해제할 이벤트의 이름| +|handlerToDetach|function \| $ts:...|✔️||해제할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + +## Events +### changeScroll {#event-changeScroll} + +
+ inherited +
+ +스크롤하면 발생하는 이벤트이다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnChangeScroll|||이벤트에 전달되는 데이터 객체| + +### requestAppend {#event-requestAppend} + +
+ inherited +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestAppend|||이벤트에 전달되는 데이터 객체| + +### requestPrepend {#event-requestPrepend} + +
+ inherited +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestPrepend|||이벤트에 전달되는 데이터 객체| + +### contentError {#event-contentError} + +
+ inherited +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnContentError|||이벤트에 전달되는 데이터 객체| + +### renderComplete {#event-renderComplete} + +
+ inherited +
+ +InfiniteGrid가 렌더링이 완료됐을 때 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRenderComplete|||이벤트에 전달되는 데이터 객체| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/MasonryInfiniteGridOptions.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/MasonryInfiniteGridOptions.mdx new file mode 100644 index 000000000..1f9a60bfa --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/MasonryInfiniteGridOptions.mdx @@ -0,0 +1,70 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:| +|horizontal|boolean|false|스크롤 이동 방향. (true: 가로방향, false: 세로방향) horizontal이 false 면 inlinePos는 left, inlineSize는 width, contentPos는 top, contentSize는 height다. horizontal이 true면 inlinePos는 top, inlineSize는 height, contentPos는 left, contentSize는 width이다.| +|percentage|Array<"position" \| "size"> \| boolean|false|item의 css size와 position를 %로 설정할지 여부.| +|isEqualSize|boolean|false|카드 엘리먼트의 크기가 동일한지 여부. 배치될 카드 엘리먼트의 크기가 모두 동일할 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|isConstantSize|boolean|false|모든 카드 엘리먼트의 크기가 불변일 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|gap|number|5|아이템들 사이의 공간.| +|attributePrefix|string|"data-grid-"|엘리먼트의 데이타 속성에 사용할 접두사.| +|resizeDebounce|number|100|리사이즈 이벤트에 설정할 디바운스 시간.(단위: ms)| +|maxResizeDebounce|number|0|리사이즈 이벤트를 디바운스할 수 있는 최대 시간. (0은 미설정이다)| +|autoResize|boolean|true|window의 resize 이벤트 이후 자동으로 resize()메소드를 호출할지의 여부.| +|useFit|boolean|true|렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다.| +|useTransform|boolean|false|left, top css 속성 쓰는 대신 transform 속성을 사용할지 여부.| +|renderOnPropertyChange|boolean|true|property의 변화를 통해 자동으로 render를 할지 여부.| +|preserveUIOnDestroy|boolean|false|destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.| +|defaultDirection|"start" \| "end"|"end"|render옵션에서 direction을 미설정시의 기본 방향값.| +|outlineLength|number|0|outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.| +|outlineSize|number|0| outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다. | +|useRoundedSize|boolean|true|사이즈를 반올림된 사이즈(offsetWidth, offsetHeight)로 가져올지 여부. container에 transform이 적용되어 있다면 true로 설정해라. false면 getBoundingClientRect를 통해 사이즈를 가져온다.| +|useResizeObserver|boolean|false|autoResize 옵션 사용시 container의 사이즈 변화 감지를 위해 ResizeObserver 이벤트를 사용할지 여부.| +|observeChildren|boolean|false|useResizeObserver옵션을 사용한다면 children의 사이즈 변화 감지 여부.| +|externalItemRenderer|ItemRenderer \| null||외부에서 직접 ItemRenderer를 설정할 수 있다.| +|externalContainerManager|ContainerManager \| null||외부에서 직접 ContainerManager를 설정할 수 있다.| +|column|number|0|열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. outlineLength 대신 사용할 수 있다.| +|columnSize|number|0|열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. outlineSize 대신 사용할 수 있다.| +|columnSizeRatio|number|0|열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다.| +|align|GridAlign|"justify"|아이템들의 위치의 정렬. stretch를 사용하고 싶다면 column, columnSize 또는 maxStretchColumnSize 옵션을 설정해라. ("start", "center", "end", "justify", "stretch")| +|contentAlign|MasonryGridVerticalAlign|"masonry"|아이템들의 Content 방향의 정렬. "masonry"는 masonry 형태로 정렬이 된다. 그 외는 inline-block의 vertical-align과 유사하게 content 방향 정렬로 적용이 된다.칼럼(data-grid-column )을 여러개 설정하면 화면이 이상하게 보일 수 있다. | +|columnCalculationThreshold|number|1|칼럼 개수를 계산하기 위한 차이 임계값. offset 사이즈는 반올림으로 게산하기 때문에 정확하지 않을 수 있다.| +|maxStretchColumnSize|number|Infinity|stretch를 사용한 경우 최대로 늘릴 수 있는 column의 사이즈를 설정하여 column을 자동 계산할 수 있다.| +|horizontal|boolean|false|스크롤 이동 방향. (true: 가로방향, false: 세로방향) horizontal이 false 면 inlinePos는 left, inlineSize는 width, contentPos는 top, contentSize는 height다. horizontal이 true면 inlinePos는 top, inlineSize는 height, contentPos는 left, contentSize는 width이다.| +|percentage|Array<"position" \| "size"> \| boolean|false|item의 css size와 position를 %로 설정할지 여부.| +|isEqualSize|boolean|false|카드 엘리먼트의 크기가 동일한지 여부. 배치될 카드 엘리먼트의 크기가 모두 동일할 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|isConstantSize|boolean|false|모든 카드 엘리먼트의 크기가 불변일 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|gap|number|5|아이템들 사이의 공간.| +|attributePrefix|string|"data-grid-"|엘리먼트의 데이타 속성에 사용할 접두사.| +|resizeDebounce|number|100|리사이즈 이벤트에 설정할 디바운스 시간.(단위: ms)| +|maxResizeDebounce|number|0|리사이즈 이벤트를 디바운스할 수 있는 최대 시간. (0은 미설정이다)| +|autoResize|boolean|true|window의 resize 이벤트 이후 자동으로 resize()메소드를 호출할지의 여부.| +|useFit|boolean|true|렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다.| +|useTransform|boolean|false|left, top css 속성 쓰는 대신 transform 속성을 사용할지 여부.| +|renderOnPropertyChange|boolean|true|property의 변화를 통해 자동으로 render를 할지 여부.| +|preserveUIOnDestroy|boolean|false|destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.| +|defaultDirection|"start" \| "end"|"end"|render옵션에서 direction을 미설정시의 기본 방향값.| +|outlineLength|number|0|outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.| +|outlineSize|number|0| outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다. | +|useRoundedSize|boolean|true|사이즈를 반올림된 사이즈(offsetWidth, offsetHeight)로 가져올지 여부. container에 transform이 적용되어 있다면 true로 설정해라. false면 getBoundingClientRect를 통해 사이즈를 가져온다.| +|useResizeObserver|boolean|false|autoResize 옵션 사용시 container의 사이즈 변화 감지를 위해 ResizeObserver 이벤트를 사용할지 여부.| +|observeChildren|boolean|false|useResizeObserver옵션을 사용한다면 children의 사이즈 변화 감지 여부.| +|externalItemRenderer|ItemRenderer \| null||외부에서 직접 ItemRenderer를 설정할 수 있다.| +|externalContainerManager|ContainerManager \| null||외부에서 직접 ContainerManager를 설정할 수 있다.| +|container|boolean \| HTMLElement \| string \| Ref<HTMLElement>|false|container를 적용할 대상. false면 자기 자신, true면 container를 생성. string 또는 HTMLElement는 직접 대상을 지정.
| +|containerTag|string|"div"|container를 생성한다면 container의 tag를 정할 수 있다.
| +|threshold|number|100|다음 아이템 그룹을 추가하기 위한 스크롤 영역의 크기.
| +|useRecycle|boolean|true|보이는 영역의 DOM만 보여줄지 여부.
| +|scrollContainer|HTMLElement \| string \| Ref<HTMLElement> \| null||scrollContainer를 직접 정할 수 있다. 이 경우 container는 wrapper 자기 자신이 된다.
| +|gridConstructor|GridFunction||Infinite 기능을 적용할 Grid 클래스.
| +|appliedItemChecker|(item: InfiniteGridItem, grid: Grid) => boolean||렌더링 되지 않는 아이템를 Grid에 포함시킬지 체크하는 함수.
| +|renderer|Renderer \| null||DOM을 렌더하는 클래스.
| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnChangeScroll.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnChangeScroll.mdx new file mode 100644 index 000000000..c7d67a6b4 --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnChangeScroll.mdx @@ -0,0 +1,17 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|currentTarget|[InfiniteGrid](InfiniteGrid)|이 이벤트를 트리거한 InfiniteGrid의 인스턴스| +|direction|"start" \| "end"|스크롤 방향.| +|scrollPos|number|스크롤 포지션.| +|relativeScrollPos|number|컨테이너 기준의 스크롤 포지션.| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnContentError.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnContentError.mdx new file mode 100644 index 000000000..690554dbc --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnContentError.mdx @@ -0,0 +1,19 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|currentTarget|[InfiniteGrid](InfiniteGrid)|이 이벤트를 트리거한 InfiniteGrid의 인스턴스| +|element|HTMLElement|아이템의 엘리먼트.| +|target|HTMLElement|에러난 발생한 콘텐츠 엘리먼트.| +|item|InfiniteGridItem|에러난 콘텐츠를 가지고 있는 아이템| +|update|() => void|에러를 해결했고 재검사하고 싶으면 update()를 호출해라. 만약 엘리먼트를 삭제한 경우 syncElements() 메서드를 호출해라.| +|remove|() => void|에러에 해당하는 아이템을 제거하고 싶으면 remove()를 호출해라.| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnRenderComplete.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnRenderComplete.mdx new file mode 100644 index 000000000..ac24359d1 --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnRenderComplete.mdx @@ -0,0 +1,22 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|currentTarget|[InfiniteGrid](InfiniteGrid)|이 이벤트를 트리거한 InfiniteGrid의 인스턴스| +|mounted|InfiniteGridItem[]|처음 렌더링한 아이템들.| +|updated|InfiniteGridItem[]|사이즈 업데이트한 아이템들.| +|direction|"start" \| "end"|InfiniteGrid가 렌더링된 방향.| +|isResize|boolean|resize 이벤트 또는 useResize 옵션을 사용하여 렌더링를 했는지 여부.| +|startCursor|number|렌더링이 완료된 첫번째 그룹의 키.| +|endCursor|number|렌더링이 완료된 마지막 그룹의 키.| +|items|InfiniteGridItem[]|렌더링이 완료된 아이템들.| +|groups|InfiniteGridGroup[]|렌더링이 완료된 그룹들.| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnRequestAppend.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnRequestAppend.mdx new file mode 100644 index 000000000..0e9ec63f1 --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnRequestAppend.mdx @@ -0,0 +1,20 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|currentTarget|[InfiniteGrid](InfiniteGrid)|이 이벤트를 트리거한 InfiniteGrid의 인스턴스| +|groupKey|string \| number \| undefined|마지막 그룹의 키.| +|nextGroupKey|string \| number \| undefined|Virtual Item(placeholder)들을 대체해야 할 다음 그룹의 키.| +|nextGroupKeys|Array<string \| number>|Virtual Item(placeholder)들을 대체해야 할 다음 그룹키 배열.| +|isVirtual|boolean|Virtual Item(placeholder)들에 해당하는 가상의 그룹을 요청하는지 여부| +|wait|() => void|데이터를 요청하기 위해 대기 상태로 설정한다.| +|ready|() => void|데이터 요청이 끝났다면 준비 상태로 설정한다.| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnRequestPrepend.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnRequestPrepend.mdx new file mode 100644 index 000000000..138f3e15b --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/OnRequestPrepend.mdx @@ -0,0 +1,20 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|currentTarget|[InfiniteGrid](InfiniteGrid)|이 이벤트를 트리거한 InfiniteGrid의 인스턴스| +|groupKey|string \| number \| undefined|첫번째 그룹의 키.| +|nextGroupKey|string \| number \| undefined|Virtual Item(placeholder)들을 대체해야 할 다음 그룹의 키.| +|nextGroupKeys|Array<string \| number>|Virtual Item(placeholder)들을 대체해야 할 다음 그룹키 배열.| +|isVirtual|boolean|Virtual Item(placeholder)들에 해당하는 가상의 그룹을 요청하는지 여부| +|wait|() => void|데이터를 요청하기 위해 대기 상태로 설정한다.| +|ready|() => void|데이터 요청이 끝났다면 준비 상태로 설정한다.| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/PackingInfiniteGrid.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/PackingInfiniteGrid.mdx new file mode 100644 index 000000000..45df0e42f --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/PackingInfiniteGrid.mdx @@ -0,0 +1,732 @@ +--- +custom_edit_url: null +--- + +```ts +class PackingInfiniteGrid +``` + +
+ +
+ +PackingInfiniteGrid는 아이템의 본래 크기에 따른 비중을 해치지 않으면서 중요한 카드는 더 크게 보여 주는 레이아웃이다.
행과 열이 구분돼 아이템을 정돈되게 배치하는 대신 가로세로 일정 공간 내에서 동적으로 아이템을 배치한다.
`sizeWeight`가 `ratioWeight`보다 높으면 아이템들의 size가 최대한 보존이 된다.
반대로 `ratioWeight`가 `sizeWeight`보다 높으면 아이템들의 비율이 최대한 보존이 된다. + +
+
Methods
Events
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
+ +## constructor +```ts +new PackingInfiniteGrid(container, options) +``` + +
+ +
+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|container|HTMLElement \| string|||모듈을 적용할 기준 엘리먼트| +|options|[PackingInfiniteGridOptions](PackingInfiniteGridOptions)|||PackingInfiniteGrid 모듈의 옵션 객체| + +## Methods + +### renderItems {#renderItems} + +
+ inherited +
+ +grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|options|RenderOptions|✔️|{}|렌더링을 하기 위한 옵션.| + +```ts +import { MasonryInfiniteGrid } from "@egjs/infinitegrid"; +const grid = new MasonryInfiniteGrid(); + +grid.on("renderComplete", e => { + console.log(e); +}); +grid.renderItems(); +``` + +### getWrapperElement {#getWrapperElement} + +
+ inherited +
+ +컨테이너 엘리먼트를 반환한다. + +### getScrollContainerElement {#getScrollContainerElement} + +
+ inherited +
+ +스크롤 영역에 해당하는 컨테이너 엘리먼트를 반환한다. + +### getContainerElement {#getContainerElement} + +
+ inherited +
+ +아이템 엘리먼트들을 담긴 컨테이너 엘리먼트를 반환한다. + +### syncItems {#syncItems} + +
+ inherited +
+ +items가 바뀐 경우 동기화를 하고 렌더링을 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|[InfiniteGridItemInfo](InfiniteGridItemInfo)[]|||렌더링을 하기 위한 옵션.| + +### setCursors {#setCursors} + +
+ inherited +
+ +현재 보이는 그룹들을 바꾼다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|startCursor|number|||보이는 그룹의 첫번째 index.| +|endCursor|number|||보이는 그룹의 마지막 index.| +|useFirstRender|boolean|✔️||첫 렌더링이 이미 되어있는지 여부.| + +### getStartCursor {#getStartCursor} + +
+ inherited +
+ +보이는 그룹들의 첫번째 index를 반환한다. + +**Returns**: number + +### getEndCursor {#getEndCursor} + +
+ inherited +
+ +보이는 그룹들의 마지막 index를 반환한다. + +**Returns**: number + +### append {#append} + +
+ inherited +
+ +아이템들을 grid 아래(오른쪽)에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```js +ig.append(`
test1
test2
`); +ig.append([`
test1
`, `
test2
`]); +ig.append([HTMLElement1, HTMLElement2]); +``` + +### prepend {#prepend} + +
+ inherited +
+ +아이템들을 grid 위(왼쪽)에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.prepend(`
test1
test2
`); +ig.prepend([`
test1
`, `
test2
`]); +ig.prepend([HTMLElement1, HTMLElement2]); +``` + +### insert {#insert} + +
+ inherited +
+ +아이템들을 특정 index에 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||추가하기 위한 index| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.insert(2, `
test1
test2
`); +ig.insert(3, [`
test1
`, `
test2
`]); +ig.insert(4, [HTMLElement1, HTMLElement2]); +``` + +### insertByGroupIndex {#insertByGroupIndex} + +
+ inherited +
+ +group의 index 기준으로 item들을 추가한다. + +**Returns**: this +- 모듈 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|groupIndex|number|||추가하기 위한 group의 index| +|items|InfiniteGridInsertedItems|||추가할 아이템들| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +```ts +ig.insertByGroupIndex(2, `
test1
test2
`); +ig.insertByGroupIndex(3, [`
test1
`, `
test2
`]); +ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); +``` + +### getStatus {#getStatus} + +
+ inherited +
+ +아이템의 위치 정보 등 모듈의 현재 상태 정보를 반환한다. 이 메서드가 반환한 정보를 저장해 두었다가 setStatus() 메서드로 복원할 수 있다 + +**Returns**: [InfiniteGridStatus](InfiniteGridStatus) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|STATUS_TYPE|✔️|| STATUS_TYPE.NOT_REMOVE = 모든 아이템들의 정보를 가져온다. STATUS_TYPE.REMOVE_INVISIBLE_ITEMS = 보이는 아이템들의 정보만 가져온다. STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS = 안보이는 아이템들을 압축한다. placeholder로 대체가 가능하다. STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS = 안보이는 그룹을 압축한다.| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### setPlaceholder {#setPlaceholder} + +
+ inherited +
+ +status 복구 또는 아이템 추가 대기를 위한 placeholder를 설정할 수 있다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||placeholder의 status| + +### setLoading {#setLoading} + +
+ inherited +
+ +status 복구 또는 아이템 추가 대기를 위한 placeholder를 설정할 수 있다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||placeholder의 status| + +### appendPlaceholders {#appendPlaceholders} + +
+ inherited +
+ +placeholder들을 마지막에 추가한다. + +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||placeholder에 해당하는 아이템들. 숫자면 갯수만큼 복제를 한다.| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +### prependPlaceholders {#prependPlaceholders} + +
+ inherited +
+ +placeholder들을 처음에 추가한다. + +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||placeholder에 해당하는 아이템들. 숫자면 갯수만큼 복제를 한다.| +|groupKey|string \| number|✔️||추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.| + +### removePlaceholders {#removePlaceholders} + +
+ inherited +
+ +placeholder들을 삭제한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|"start" \| "end" \| {groupKey: string \| number}|||groupkey에 해당하는 placeholder들을 삭제한다. "start" 또는 "end" 일 때 해당 방향의 모든 placeholder들을 삭제한다.| + +### setStatus {#setStatus} + +
+ inherited +
+ +getStatus() 메서드가 저장한 정보로 InfiniteGrid 모듈의 상태를 설정한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|status|[InfiniteGridStatus](InfiniteGridStatus)|||InfiniteGrid 모듈의 status 객체.| +|useFirstRender|boolean|✔️||첫 렌더링이 이미 되어있는지 여부.| + +### removeGroupByIndex {#removeGroupByIndex} + +
+ inherited +
+ +index에 해당하는 그룹을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeGroupByKey {#removeGroupByKey} + +
+ inherited +
+ +key에 해당하는 그룹을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|number \| string|||| + +### removeByIndex {#removeByIndex} + +
+ inherited +
+ +index에 해당하는 아이템을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeByKey {#removeByKey} + +
+ inherited +
+ +key에 해당하는 아이템을 제거 한다. + +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|string \| number|||| + +### updateItems {#updateItems} + +
+ inherited +
+ +아이템들의 사이즈를 업데이트하고 렌더링을 한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridItem[]|✔️||업데이트할 아이템들.| +|options|RenderOptions|✔️|{}|렌더링을 하기 위한 옵션.| + +### getItems {#getItems} + +
+ inherited +
+ +InfiniteGrid의 모든 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### getVisibleItems {#getVisibleItems} + +
+ inherited +
+ +InfiniteGrid의 보이는 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 아이템들을 포함할지 여부.| + +### getRenderingItems {#getRenderingItems} + +
+ inherited +
+ +InfiniteGrid의 렌더링 아이템들을 반환한다. + +**Returns**: InfiniteGridItem[] + +### getGroups {#getGroups} + +
+ inherited +
+ +InfiniteGrid의 모든 그룹들을 반환한다. + +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 그룹들을 포함할지 여부.| + +### getVisibleGroups {#getVisibleGroups} + +
+ inherited +
+ +InfiniteGrid의 보이는 그룹들을 반환한다. + +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||placeholder에 해당하는 그룹들을 포함할지 여부.| + +### wait {#wait} + +
+ inherited +
+ +데이터를 요청하기 위해 대기 상태로 설정한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|direction|"start" \| "end"|✔️|DIRECTION.END|데이터를 추가하기 위한 방향.| + +### ready {#ready} + +
+ inherited +
+ +데이터 요청이 끝났다면 준비 상태로 설정한다. + +### isWait {#isWait} + +
+ inherited +
+ +데이터를 요청하기 위해 대기 상태로 설정되어 있는지 여부를 반환한다. + +### destroy {#destroy} + +
+ inherited +
+ +인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다. + +**Returns**: void + +### trigger {#trigger} + +
+ inherited +
+ +커스텀 이벤트를 발생시킨다 + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스| +|params|Array<any> \| $ts:...|||커스텀 이벤트가 발생할 때 전달할 데이터| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +이벤트가 한번만 실행된다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +컴포넌트에 이벤트가 등록됐는지 확인한다. + +**Returns**: boolean +- 이벤트 등록 여부 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||등록 여부를 확인할 이벤트의 이름| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +컴포넌트에 이벤트를 등록한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트| +|handlerToAttach|function \| $ts:...|✔️||등록할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +컴포넌트에 등록된 이벤트를 해제한다.
`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.
`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다. + +**Returns**: this +- 컴포넌트 자신의 인스턴스 + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||해제할 이벤트의 이름| +|handlerToDetach|function \| $ts:...|✔️||해제할 이벤트의 핸들러 함수| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + +## Events +### changeScroll {#event-changeScroll} + +
+ inherited +
+ +스크롤하면 발생하는 이벤트이다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnChangeScroll|||이벤트에 전달되는 데이터 객체| + +### requestAppend {#event-requestAppend} + +
+ inherited +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestAppend|||이벤트에 전달되는 데이터 객체| + +### requestPrepend {#event-requestPrepend} + +
+ inherited +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestPrepend|||이벤트에 전달되는 데이터 객체| + +### contentError {#event-contentError} + +
+ inherited +
+ +스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnContentError|||이벤트에 전달되는 데이터 객체| + +### renderComplete {#event-renderComplete} + +
+ inherited +
+ +InfiniteGrid가 렌더링이 완료됐을 때 이벤트가 발생한다. + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRenderComplete|||이벤트에 전달되는 데이터 객체| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/PackingInfiniteGridOptions.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/PackingInfiniteGridOptions.mdx new file mode 100644 index 000000000..98c08dc4e --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/PackingInfiniteGridOptions.mdx @@ -0,0 +1,67 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:| +|horizontal|boolean|false|스크롤 이동 방향. (true: 가로방향, false: 세로방향) horizontal이 false 면 inlinePos는 left, inlineSize는 width, contentPos는 top, contentSize는 height다. horizontal이 true면 inlinePos는 top, inlineSize는 height, contentPos는 left, contentSize는 width이다.| +|percentage|Array<"position" \| "size"> \| boolean|false|item의 css size와 position를 %로 설정할지 여부.| +|isEqualSize|boolean|false|카드 엘리먼트의 크기가 동일한지 여부. 배치될 카드 엘리먼트의 크기가 모두 동일할 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|isConstantSize|boolean|false|모든 카드 엘리먼트의 크기가 불변일 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|gap|number|5|아이템들 사이의 공간.| +|attributePrefix|string|"data-grid-"|엘리먼트의 데이타 속성에 사용할 접두사.| +|resizeDebounce|number|100|리사이즈 이벤트에 설정할 디바운스 시간.(단위: ms)| +|maxResizeDebounce|number|0|리사이즈 이벤트를 디바운스할 수 있는 최대 시간. (0은 미설정이다)| +|autoResize|boolean|true|window의 resize 이벤트 이후 자동으로 resize()메소드를 호출할지의 여부.| +|useFit|boolean|true|렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다.| +|useTransform|boolean|false|left, top css 속성 쓰는 대신 transform 속성을 사용할지 여부.| +|renderOnPropertyChange|boolean|true|property의 변화를 통해 자동으로 render를 할지 여부.| +|preserveUIOnDestroy|boolean|false|destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.| +|defaultDirection|"start" \| "end"|"end"|render옵션에서 direction을 미설정시의 기본 방향값.| +|outlineLength|number|0|outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.| +|outlineSize|number|0| outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다. | +|useRoundedSize|boolean|true|사이즈를 반올림된 사이즈(offsetWidth, offsetHeight)로 가져올지 여부. container에 transform이 적용되어 있다면 true로 설정해라. false면 getBoundingClientRect를 통해 사이즈를 가져온다.| +|useResizeObserver|boolean|false|autoResize 옵션 사용시 container의 사이즈 변화 감지를 위해 ResizeObserver 이벤트를 사용할지 여부.| +|observeChildren|boolean|false|useResizeObserver옵션을 사용한다면 children의 사이즈 변화 감지 여부.| +|externalItemRenderer|ItemRenderer \| null||외부에서 직접 ItemRenderer를 설정할 수 있다.| +|externalContainerManager|ContainerManager \| null||외부에서 직접 ContainerManager를 설정할 수 있다.| +|aspectRatio|number|1|아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize).| +|sizeWeight|number|1|아이템들을 배치하는데 사이즈 가중치.| +|ratioWeight|number|1|아이템들을 배치하는데 비율을 유지하는 가중치.| +|weightPriority|"size" \| "ratio" \| "custom"|"custom"| 아이템의 가중치를 결정하는 우선수치. "size" = (sizeWieght: 100, ratioWeight: 1), "ratio" = (sizeWeight: 1, ratioWeight; 100), "custom" = (set sizeWeight, ratioWeight). 아이템의 가중치 = ratio(inlineSize / contentSize)의 변화량 * ratioWeight + size(inlineSize * contentSize)의 변화량 * sizeWeight.| +|horizontal|boolean|false|스크롤 이동 방향. (true: 가로방향, false: 세로방향) horizontal이 false 면 inlinePos는 left, inlineSize는 width, contentPos는 top, contentSize는 height다. horizontal이 true면 inlinePos는 top, inlineSize는 height, contentPos는 left, contentSize는 width이다.| +|percentage|Array<"position" \| "size"> \| boolean|false|item의 css size와 position를 %로 설정할지 여부.| +|isEqualSize|boolean|false|카드 엘리먼트의 크기가 동일한지 여부. 배치될 카드 엘리먼트의 크기가 모두 동일할 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|isConstantSize|boolean|false|모든 카드 엘리먼트의 크기가 불변일 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.| +|gap|number|5|아이템들 사이의 공간.| +|attributePrefix|string|"data-grid-"|엘리먼트의 데이타 속성에 사용할 접두사.| +|resizeDebounce|number|100|리사이즈 이벤트에 설정할 디바운스 시간.(단위: ms)| +|maxResizeDebounce|number|0|리사이즈 이벤트를 디바운스할 수 있는 최대 시간. (0은 미설정이다)| +|autoResize|boolean|true|window의 resize 이벤트 이후 자동으로 resize()메소드를 호출할지의 여부.| +|useFit|boolean|true|렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다.| +|useTransform|boolean|false|left, top css 속성 쓰는 대신 transform 속성을 사용할지 여부.| +|renderOnPropertyChange|boolean|true|property의 변화를 통해 자동으로 render를 할지 여부.| +|preserveUIOnDestroy|boolean|false|destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.| +|defaultDirection|"start" \| "end"|"end"|render옵션에서 direction을 미설정시의 기본 방향값.| +|outlineLength|number|0|outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.| +|outlineSize|number|0| outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다. | +|useRoundedSize|boolean|true|사이즈를 반올림된 사이즈(offsetWidth, offsetHeight)로 가져올지 여부. container에 transform이 적용되어 있다면 true로 설정해라. false면 getBoundingClientRect를 통해 사이즈를 가져온다.| +|useResizeObserver|boolean|false|autoResize 옵션 사용시 container의 사이즈 변화 감지를 위해 ResizeObserver 이벤트를 사용할지 여부.| +|observeChildren|boolean|false|useResizeObserver옵션을 사용한다면 children의 사이즈 변화 감지 여부.| +|externalItemRenderer|ItemRenderer \| null||외부에서 직접 ItemRenderer를 설정할 수 있다.| +|externalContainerManager|ContainerManager \| null||외부에서 직접 ContainerManager를 설정할 수 있다.| +|container|boolean \| HTMLElement \| string \| Ref<HTMLElement>|false|container를 적용할 대상. false면 자기 자신, true면 container를 생성. string 또는 HTMLElement는 직접 대상을 지정.
| +|containerTag|string|"div"|container를 생성한다면 container의 tag를 정할 수 있다.
| +|threshold|number|100|다음 아이템 그룹을 추가하기 위한 스크롤 영역의 크기.
| +|useRecycle|boolean|true|보이는 영역의 DOM만 보여줄지 여부.
| +|scrollContainer|HTMLElement \| string \| Ref<HTMLElement> \| null||scrollContainer를 직접 정할 수 있다. 이 경우 container는 wrapper 자기 자신이 된다.
| +|gridConstructor|GridFunction||Infinite 기능을 적용할 Grid 클래스.
| +|appliedItemChecker|(item: InfiniteGridItem, grid: Grid) => boolean||렌더링 되지 않는 아이템를 Grid에 포함시킬지 체크하는 함수.
| +|renderer|Renderer \| null||DOM을 렌더하는 클래스.
| + diff --git a/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/withInfiniteGridMethods.mdx b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/withInfiniteGridMethods.mdx new file mode 100644 index 000000000..38af66bec --- /dev/null +++ b/packages/docs/i18n/ko/docusaurus-plugin-content-docs/version-4.11.1/api/withInfiniteGridMethods.mdx @@ -0,0 +1,23 @@ +--- +custom_edit_url: null +--- + +```ts +const withInfiniteGridMethods +``` + +
+ +
+ +프레임워크에서 InfiniteGrid의 메소드를 사용할 수 있게 하는 데코레이터. + +```js +import { withInfiniteGridMethods } from "@egjs/infinitegrid"; + +class Grid extends React.Component> { + @withInfiniteGridMethods + private grid: NativeGrid; +} +``` + diff --git a/packages/docs/sidebars-api.js b/packages/docs/sidebars-api.js index 386ce7fe9..44d698d77 100644 --- a/packages/docs/sidebars-api.js +++ b/packages/docs/sidebars-api.js @@ -9,7 +9,8 @@ module.exports = { "api/JustifiedInfiniteGrid", "api/MasonryInfiniteGrid", "api/PackingInfiniteGrid", - "api/Grid" + "api/Grid", + "api/Component" ] }, { diff --git a/packages/docs/versioned_docs/version-4.11.1/api/Component.mdx b/packages/docs/versioned_docs/version-4.11.1/api/Component.mdx new file mode 100644 index 000000000..95e389b60 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/Component.mdx @@ -0,0 +1,211 @@ +--- +custom_edit_url: null +--- + +```ts +class Component +``` + +
+ +
+ +

A class used to manage events in a component

+ +
+
Properties
Methods
+
VERSIONstatic
trigger
once
hasOn
on
off
+
+ +## Properties +### VERSION {#VERSION} + +
+ static +
+ +

Version info string

+ +**Type**: string + +Component.VERSION; // ex) 3.0.0 + +## Methods + +### trigger {#trigger} + +
+ +
+ +

Trigger a custom event.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||

The name of the custom event to be triggered or an instance of the ComponentEvent

| +|params|Array<any> \| $ts:...|||

Event data to be sent when triggering a custom event

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ +
+ +

Executed event just one time.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ +
+ +

Checks whether an event has been attached to a component.

+ +**Returns**: boolean +-

Indicates whether the event is attached.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||

The name of the event to be attached

| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ +
+ +

Attaches an event to a component.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ +
+ +

Detaches an event from the component.
If the eventName is not given this will detach all event handlers attached.
If the handlerToDetach is not given, this will detach all event handlers for eventName.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||

The name of the event to be detached

| +|handlerToDetach|function \| $ts:...|✔️||

The handler function of the event to be detached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/FrameInfiniteGrid.mdx b/packages/docs/versioned_docs/version-4.11.1/api/FrameInfiniteGrid.mdx new file mode 100644 index 000000000..b0daa71cd --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/FrameInfiniteGrid.mdx @@ -0,0 +1,732 @@ +--- +custom_edit_url: null +--- + +```ts +class FrameInfiniteGrid +``` + +
+ +
+ +

'Frame' is a printing term with the meaning that 'it fits in one row wide'. FrameInfiniteGrid is a grid that the item is filled up on the basis of a line given a size.

+ +
+
Methods
Events
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
+ +## constructor +```ts +new FrameInfiniteGrid(container, options) +``` + +
+ +
+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|container|HTMLElement \| string|||

A base element for a module

| +|options|[FrameInfiniteGridOptions](FrameInfiniteGridOptions)|||

The option object of the FrameInfiniteGrid module

| + +## Methods + +### renderItems {#renderItems} + +
+ inherited +
+ +

Rearrange items to fit the grid and render them. When rearrange is complete, the renderComplete event is fired.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|options|RenderOptions|✔️|{}|

Options for rendering.

| + +```ts +import { MasonryInfiniteGrid } from "@egjs/infinitegrid"; +const grid = new MasonryInfiniteGrid(); + +grid.on("renderComplete", e => { + console.log(e); +}); +grid.renderItems(); +``` + +### getWrapperElement {#getWrapperElement} + +
+ inherited +
+ +

Returns the wrapper element specified by the user.

+ +### getScrollContainerElement {#getScrollContainerElement} + +
+ inherited +
+ +

Returns the container element corresponding to the scroll area.

+ +### getContainerElement {#getContainerElement} + +
+ inherited +
+ +

Returns the container element containing item elements.

+ +### syncItems {#syncItems} + +
+ inherited +
+ +

When items change, it synchronizes and renders items.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|[InfiniteGridItemInfo](InfiniteGridItemInfo)[]|||

Options for rendering.

| + +### setCursors {#setCursors} + +
+ inherited +
+ +

Change the currently visible groups.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|startCursor|number|||

first index of visible groups.

| +|endCursor|number|||

last index of visible groups.

| +|useFirstRender|boolean|✔️||

Whether the first rendering has already been done.

| + +### getStartCursor {#getStartCursor} + +
+ inherited +
+ +

Returns the first index of visible groups.

+ +**Returns**: number + +### getEndCursor {#getEndCursor} + +
+ inherited +
+ +

Returns the last index of visible groups.

+ +**Returns**: number + +### append {#append} + +
+ inherited +
+ +

Add items at the bottom(right) of the grid.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```js +ig.append(`
test1
test2
`); +ig.append([`
test1
`, `
test2
`]); +ig.append([HTMLElement1, HTMLElement2]); +``` + +### prepend {#prepend} + +
+ inherited +
+ +

Add items at the top(left) of the grid.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.prepend(`
test1
test2
`); +ig.prepend([`
test1
`, `
test2
`]); +ig.prepend([HTMLElement1, HTMLElement2]); +``` + +### insert {#insert} + +
+ inherited +
+ +

Add items to a specific index.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||

index to add

| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.insert(2, `
test1
test2
`); +ig.insert(3, [`
test1
`, `
test2
`]); +ig.insert(4, [HTMLElement1, HTMLElement2]); +``` + +### insertByGroupIndex {#insertByGroupIndex} + +
+ inherited +
+ +

Add items based on group index.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|groupIndex|number|||

group index to add

| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.insertByGroupIndex(2, `
test1
test2
`); +ig.insertByGroupIndex(3, [`
test1
`, `
test2
`]); +ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); +``` + +### getStatus {#getStatus} + +
+ inherited +
+ +

Returns the current state of a module such as location information. You can use the setStatus() method to restore the information returned through a call to this method.

+ +**Returns**: [InfiniteGridStatus](InfiniteGridStatus) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|STATUS_TYPE|✔️||

STATUS_TYPE.NOT_REMOVE = Get all information about items. STATUS_TYPE.REMOVE_INVISIBLE_ITEMS = Get information on visible items only. STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS = Compress invisible items. You can replace it with a placeholder. STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS = Compress invisible groups.

| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### setPlaceholder {#setPlaceholder} + +
+ inherited +
+ +

You can set placeholders to restore status or wait for items to be added.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||

The placeholder status.

| + +### setLoading {#setLoading} + +
+ inherited +
+ +

You can set placeholders to restore status or wait for items to be added.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||

The placeholder status.

| + +### appendPlaceholders {#appendPlaceholders} + +
+ inherited +
+ +

Add the placeholder at the end.

+ +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||

Items that correspond to placeholders. If it is a number, it duplicates the number of copies.

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +### prependPlaceholders {#prependPlaceholders} + +
+ inherited +
+ +

Add the placeholder at the start.

+ +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||

Items that correspond to placeholders. If it is a number, it duplicates the number of copies.

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +### removePlaceholders {#removePlaceholders} + +
+ inherited +
+ +

Remove placeholders

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|"start" \| "end" \| {groupKey: string \| number}|||

Remove the placeholders corresponding to the groupkey. When "start" or "end", remove all placeholders in that direction.

| + +### setStatus {#setStatus} + +
+ inherited +
+ +

Sets the status of the InfiniteGrid module with the information returned through a call to the getStatus() method.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|status|[InfiniteGridStatus](InfiniteGridStatus)|||

status object of the InfiniteGrid module.

| +|useFirstRender|boolean|✔️||

Whether the first rendering has already been done.

| + +### removeGroupByIndex {#removeGroupByIndex} + +
+ inherited +
+ +

Removes the group corresponding to index.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeGroupByKey {#removeGroupByKey} + +
+ inherited +
+ +

Removes the group corresponding to key.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|number \| string|||| + +### removeByIndex {#removeByIndex} + +
+ inherited +
+ +

Removes the item corresponding to index.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeByKey {#removeByKey} + +
+ inherited +
+ +

Removes the item corresponding to key.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|string \| number|||| + +### updateItems {#updateItems} + +
+ inherited +
+ +

Update the size of the items and render them.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridItem[]|✔️||

Items to be updated.

| +|options|RenderOptions|✔️|{}|

Options for rendering.

| + +### getItems {#getItems} + +
+ inherited +
+ +

Return all items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### getVisibleItems {#getVisibleItems} + +
+ inherited +
+ +

Return visible items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### getRenderingItems {#getRenderingItems} + +
+ inherited +
+ +

Return rendering items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +### getGroups {#getGroups} + +
+ inherited +
+ +

Return all groups of InfiniteGrid.

+ +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include groups corresponding to placeholders.

| + +### getVisibleGroups {#getVisibleGroups} + +
+ inherited +
+ +

Return visible groups of InfiniteGrid.

+ +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include groups corresponding to placeholders.

| + +### wait {#wait} + +
+ inherited +
+ +

Set to wait to request data.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|direction|"start" \| "end"|✔️|DIRECTION.END|

direction in which data will be added.

| + +### ready {#ready} + +
+ inherited +
+ +

When the data request is complete, it is set to ready state.

+ +### isWait {#isWait} + +
+ inherited +
+ +

Returns whether it is set to wait to request data.

+ +### destroy {#destroy} + +
+ inherited +
+ +

Releases the instnace and events and returns the CSS of the container and elements.

+ +**Returns**: void + +### trigger {#trigger} + +
+ inherited +
+ +

Trigger a custom event.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||

The name of the custom event to be triggered or an instance of the ComponentEvent

| +|params|Array<any> \| $ts:...|||

Event data to be sent when triggering a custom event

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +

Executed event just one time.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +

Checks whether an event has been attached to a component.

+ +**Returns**: boolean +-

Indicates whether the event is attached.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||

The name of the event to be attached

| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +

Attaches an event to a component.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +

Detaches an event from the component.
If the eventName is not given this will detach all event handlers attached.
If the handlerToDetach is not given, this will detach all event handlers for eventName.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||

The name of the event to be detached

| +|handlerToDetach|function \| $ts:...|✔️||

The handler function of the event to be detached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + +## Events +### changeScroll {#event-changeScroll} + +
+ inherited +
+ +

This event is fired when scrolling.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnChangeScroll|||

The object of data to be sent to an event

| + +### requestAppend {#event-requestAppend} + +
+ inherited +
+ +

The event is fired when scrolling reaches the end or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestAppend|||

The object of data to be sent to an event

| + +### requestPrepend {#event-requestPrepend} + +
+ inherited +
+ +

The event is fired when scrolling reaches the start or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestPrepend|||

The object of data to be sent to an event

| + +### contentError {#event-contentError} + +
+ inherited +
+ +

The event is fired when scrolling reaches the start or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnContentError|||

The object of data to be sent to an event

| + +### renderComplete {#event-renderComplete} + +
+ inherited +
+ +

This event is fired when the InfiniteGrid has completed rendering.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRenderComplete|||

The object of data to be sent to an event

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/FrameInfiniteGridOptions.mdx b/packages/docs/versioned_docs/version-4.11.1/api/FrameInfiniteGridOptions.mdx new file mode 100644 index 000000000..deb73d805 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/FrameInfiniteGridOptions.mdx @@ -0,0 +1,66 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:| +|horizontal|boolean|false|

Direction of the scroll movement. (true: horizontal, false: vertical) If horizontal is false, inlinePos is left, inlineSize is width, contentPos is top, and contentSize is height. If horizontal is true, inlinePos is top, inlineSize is height, contentPos is left, and contentSize is width.

| +|percentage|Array<"position" \| "size"> \| boolean|false|

Whether to set the css size and position of the item to %.

| +|isEqualSize|boolean|false|

Indicates whether sizes of all card elements are equal to one another. If sizes of card elements to be arranged are all equal and this option is set to "true", the performance of layout arrangement can be improved.

| +|isConstantSize|boolean|false|

Indicates whether sizes of all card elements does not change, the performance of layout arrangement can be improved.

| +|gap|number|5|

Gap used to create space around items.

| +|attributePrefix|string|"data-grid-"|

The prefix to use element's data attribute.

| +|resizeDebounce|number|100|

Debounce time to set in the resize event. (unit: ms)

| +|maxResizeDebounce|number|0|

Maximum time to debounce the resize event. (0 is not set)

| +|autoResize|boolean|true|

Whether the resize method should be called automatically after a window resize event.

| +|useFit|boolean|true|

Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0.

| +|useTransform|boolean|false|

Whether to use transform property instead of using left and top css properties.

| +|renderOnPropertyChange|boolean|true|

Whether to automatically render through property change.

| +|preserveUIOnDestroy|boolean|false|

Whether to preserve the UI of the existing container or item when destroying.

| +|defaultDirection|"start" \| "end"|"end"|

The default direction value when direction is not set in the render option.

| +|outlineLength|number|0|

The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid.

| +|outlineSize|number|0|

The size of the outline. If the outline size is 0, it is calculated according to the grid type.

| +|useRoundedSize|boolean|true|

Whether to get the size as rounded size(offsetWidth, offsetHeight). Set to true if transform is applied to the container. If false, get the size through getBoundingClientRect.

| +|useResizeObserver|boolean|false|

Whether to use ResizeObserver event to detect container size change when autoResize option is used.

| +|observeChildren|boolean|false|

Whether to detect size change of children if useResizeObserver option is used.

| +|externalItemRenderer|ItemRenderer \| null||

You can set the ItemRenderer directly externally.

| +|externalContainerManager|ContainerManager \| null||

You can set the ContainerManager directly externally.

| +|frame|number[][]|[]|

The shape of the grid. You can set the shape and order of items with a 2d array ([contentPos][inlinePos]). You can place items as many times as you fill the array with numbers, and zeros and spaces are empty spaces. The order of the items is arranged in ascending order of the numeric values that fill the array.

| +|useFrameFill|boolean|true|

Make sure that the frame can be attached after the previous frame.

| +|rectSize|number \| {inlineSize: number, contentSize: number}|0|

1x1 rect size. If it is 0, it is determined by the number of columns in the frame.

| +|horizontal|boolean|false|

Direction of the scroll movement. (true: horizontal, false: vertical) If horizontal is false, inlinePos is left, inlineSize is width, contentPos is top, and contentSize is height. If horizontal is true, inlinePos is top, inlineSize is height, contentPos is left, and contentSize is width.

| +|percentage|Array<"position" \| "size"> \| boolean|false|

Whether to set the css size and position of the item to %.

| +|isEqualSize|boolean|false|

Indicates whether sizes of all card elements are equal to one another. If sizes of card elements to be arranged are all equal and this option is set to "true", the performance of layout arrangement can be improved.

| +|isConstantSize|boolean|false|

Indicates whether sizes of all card elements does not change, the performance of layout arrangement can be improved.

| +|gap|number|5|

Gap used to create space around items.

| +|attributePrefix|string|"data-grid-"|

The prefix to use element's data attribute.

| +|resizeDebounce|number|100|

Debounce time to set in the resize event. (unit: ms)

| +|maxResizeDebounce|number|0|

Maximum time to debounce the resize event. (0 is not set)

| +|autoResize|boolean|true|

Whether the resize method should be called automatically after a window resize event.

| +|useFit|boolean|true|

Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0.

| +|useTransform|boolean|false|

Whether to use transform property instead of using left and top css properties.

| +|renderOnPropertyChange|boolean|true|

Whether to automatically render through property change.

| +|preserveUIOnDestroy|boolean|false|

Whether to preserve the UI of the existing container or item when destroying.

| +|defaultDirection|"start" \| "end"|"end"|

The default direction value when direction is not set in the render option.

| +|outlineLength|number|0|

The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid.

| +|outlineSize|number|0|

The size of the outline. If the outline size is 0, it is calculated according to the grid type.

| +|useRoundedSize|boolean|true|

Whether to get the size as rounded size(offsetWidth, offsetHeight). Set to true if transform is applied to the container. If false, get the size through getBoundingClientRect.

| +|useResizeObserver|boolean|false|

Whether to use ResizeObserver event to detect container size change when autoResize option is used.

| +|observeChildren|boolean|false|

Whether to detect size change of children if useResizeObserver option is used.

| +|externalItemRenderer|ItemRenderer \| null||

You can set the ItemRenderer directly externally.

| +|externalContainerManager|ContainerManager \| null||

You can set the ContainerManager directly externally.

| +|container|boolean \| HTMLElement \| string \| Ref<HTMLElement>|false|

The target to which the container is applied. If false, create itself, if true, create container. A string or HTMLElement specifies the target directly.

| +|containerTag|string|"div"|

If you create a container, you can set the container's tag.

| +|threshold|number|100|

The size of the scrollable area for adding the next group of items.

| +|useRecycle|boolean|true|

Whether to show only the DOM of the visible area.

| +|scrollContainer|HTMLElement \| string \| Ref<HTMLElement> \| null||

You can set the scrollContainer directly. In this case, the container becomes the wrapper itself.

| +|gridConstructor|GridFunction||

Grid class to apply Infinite function.

| +|appliedItemChecker|(item: InfiniteGridItem, grid: Grid) => boolean||

A function that checks whether non-rendering items are included in the Grid.

| +|renderer|Renderer \| null||

class that renders the DOM.

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/Grid.mdx b/packages/docs/versioned_docs/version-4.11.1/api/Grid.mdx new file mode 100644 index 000000000..b1fc572ae --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/Grid.mdx @@ -0,0 +1,583 @@ +--- +custom_edit_url: null +--- + +```ts +class Grid +``` + +
+ +
+ +
+
Properties
Methods
Events
+
gap
defaultDirection
useFit
preserveUIOnDestroy
outlineLength
outlineSize
applyGrid
getContainerElement
getItems
getChildren
setItems
getContainerInlineSize
getOutlines
setOutlines
syncElements
updateItems
renderItems
getStatus
setStatus
getComputedOutlineSize
getComputedOutlineLength
destroy
trigger
once
hasOn
on
off
contentError
renderComplete
+
+ +## constructor +```ts +new Grid(containerElement, options) +``` + +
+ +
+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|containerElement|HTMLElement \| string|||

A base element for a module

| +|options|Partial<Options>|✔️|{}|

The option object of the Grid module

| + +## Properties + +### gap {#gap} + +
+ +
+ +

Gap used to create space around items.

+ +**Type**: $ts:Grid.GridOptions["gap"] + +**Default**: 0 + +```js +import { MasonryGrid } from "@egjs/grid"; + +const grid = new MasonryGrid(container, { + gap: 0, +}); + +grid.gap = 5; +``` + +### defaultDirection {#defaultDirection} + +
+ +
+ +

The default direction value when direction is not set in the render option.

+ +**Type**: $ts:Grid.GridOptions["defaultDirection"] + +**Default**: "end" + +```js +import { MasonryGrid } from "@egjs/grid"; + +const grid = new MasonryGrid(container, { + defaultDirection: "end", +}); + +grid.defaultDirection = "start"; +``` + +### useFit {#useFit} + +
+ +
+ +

Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0. (default: true)

+ +**Type**: $ts:Grid.GridOptions["useFit"] + +**Default**: true + +```js +import { MasonryGrid } from "@egjs/grid"; + +const grid = new MasonryGrid(container, { + useFit: true, +}); + +grid.useFit = false; +``` + +### preserveUIOnDestroy {#preserveUIOnDestroy} + +
+ +
+ +

Whether to preserve the UI of the existing container or item when destroying.

+ +**Type**: $ts:Grid.GridOptions["preserveUIOnDestroy"] + +**Default**: false + +```js +import { MasonryGrid } from "@egjs/grid"; + +const grid = new MasonryGrid(container, { + preserveUIOnDestroy: false, +}); + +grid.preserveUIOnDestroy = true; +``` + +### outlineLength {#outlineLength} + +
+ +
+ +

The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid.

+ +**Type**: $ts:Grid.GridOptions["outlineLength"] + +**Default**: 0 + +```js +import { MasonryGrid } from "@egjs/grid"; + +const grid = new MasonryGrid(container, { + outlineLength: 0, + outlineSize: 0, +}); + +grid.outlineLength = 3; +``` + +### outlineSize {#outlineSize} + +
+ +
+ +

The size of the outline. If the outline size is 0, it is calculated according to the grid type.

+ +**Type**: $ts:Grid.GridOptions["outlineSize"] + +**Default**: 0 + +```js +import { MasonryGrid } from "@egjs/grid"; + +const grid = new MasonryGrid(container, { + outlineLength: 0, + outlineSize: 0, +}); + +grid.outlineSize = 300; +``` + +## Methods + +### applyGrid {#applyGrid} + +
+ +
+ +

Apply the CSS rect of items to fit the Grid and calculate the outline.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|direcion|"start" \| "end"|||

The direction to apply the Grid. ("end": start to end, "start": end to start)

| +|outline|Array<number>|||

The start outline to apply the Grid.

| + +### getContainerElement {#getContainerElement} + +
+ +
+ +

Return Container Element.

+ +**Returns**: HTMLElement + +### getItems {#getItems} + +
+ +
+ +

Return items.

+ +**Returns**: GridItem[] + +### getChildren {#getChildren} + +
+ +
+ +

Returns the children of the container element.

+ +**Returns**: HTMLElement[] + +### setItems {#setItems} + +
+ +
+ +

Set items.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|GridItem[]|||

The items to set.

| + +### getContainerInlineSize {#getContainerInlineSize} + +
+ +
+ +

Gets the container's inline size. ("width" if horizontal is false, otherwise "height")

+ +**Returns**: number + +### getOutlines {#getOutlines} + +
+ +
+ +

Returns the outlines of the start and end of the Grid.

+ +**Returns**: GridOutlines + +### setOutlines {#setOutlines} + +
+ +
+ +

Set outlines.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|outlines|GridOutlines|||

The outlines to set.

| + +### syncElements {#syncElements} + +
+ +
+ +

When elements change, it synchronizes and renders items.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|options|RenderOptions|✔️|{}|

Options for rendering.

| + +### updateItems {#updateItems} + +
+ +
+ +

Update the size of the items and render them.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|GridItem[]|✔️|this.items|

Items to be updated.

| +|options|RenderOptions|✔️|{}|

Options for rendering.

| + +### renderItems {#renderItems} + +
+ +
+ +

Rearrange items to fit the grid and render them. When rearrange is complete, the renderComplete event is fired.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|options|RenderOptions|✔️|{}|

Options for rendering.

| + +```js +import { MasonryGrid } from "@egjs/grid"; +const grid = new MasonryGrid(); + +grid.on("renderComplete", e => { + console.log(e); +}); +grid.renderItems(); +``` + +### getStatus {#getStatus} + +
+ +
+ +

Returns current status such as item's position, size. The returned status can be restored with the setStatus() method.

+ +**Returns**: GridStatus + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|minimize|boolean|✔️||

Whether to minimize the status of the item. (default: false)

| + +### setStatus {#setStatus} + +
+ +
+ +

Set status of the Grid module with the status returned through a call to the getStatus() method.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|status|GridStatus|||| + +### getComputedOutlineSize {#getComputedOutlineSize} + +
+ +
+ +

Get the inline size corresponding to outline.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|GridItem[]|✔️|this.items|

Items to get outline size.

| + +### getComputedOutlineLength {#getComputedOutlineLength} + +
+ +
+ +

Get the length corresponding to outline.

+ +**Returns**: number + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|GridItem[]|✔️|this.items|

Items to get outline length.

| + +### destroy {#destroy} + +
+ +
+ +

Releases the instnace and events and returns the CSS of the container and elements.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|Options|DestroyOptions|✔️|{}|

for destroy.

| + +### trigger {#trigger} + +
+ inherited +
+ +

Trigger a custom event.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||

The name of the custom event to be triggered or an instance of the ComponentEvent

| +|params|Array<any> \| $ts:...|||

Event data to be sent when triggering a custom event

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +

Executed event just one time.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +

Checks whether an event has been attached to a component.

+ +**Returns**: boolean +-

Indicates whether the event is attached.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||

The name of the event to be attached

| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +

Attaches an event to a component.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +

Detaches an event from the component.
If the eventName is not given this will detach all event handlers attached.
If the handlerToDetach is not given, this will detach all event handlers for eventName.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||

The name of the event to be detached

| +|handlerToDetach|function \| $ts:...|✔️||

The handler function of the event to be detached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + +## Events +### contentError {#event-contentError} + +
+ +
+ +

This event is fired when an error occurs in the content.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|[Grid.OnContentError](Grid:OnContentError)|||

The object of data to be sent to an event

| + +```js +grid.on("contentError", e => { + e.update(); +}); +``` + +### renderComplete {#event-renderComplete} + +
+ +
+ +

This event is fired when the Grid has completed rendering.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|[Grid.OnRenderComplete](Grid:OnRenderComplete)|||

The object of data to be sent to an event

| + +```js +grid.on("renderComplete", e => { + console.log(e.mounted, e.updated, e.useResize); +}); +``` + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/InfiniteGrid.mdx b/packages/docs/versioned_docs/version-4.11.1/api/InfiniteGrid.mdx new file mode 100644 index 000000000..82e5ec995 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/InfiniteGrid.mdx @@ -0,0 +1,763 @@ +--- +custom_edit_url: null +--- + +```ts +class InfiniteGrid extends Component +``` + +
+ +
+ +

A module used to arrange items including content infinitely according to layout type. With this module, you can implement various layouts composed of different items whose sizes vary. It guarantees performance by maintaining the number of DOMs the module is handling under any circumstance

+ +
+
Methods
Events
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
+ +## constructor +```ts +new InfiniteGrid(wrapper, options) +``` + +
+ +
+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|wrapper|HTMLElement \| string|||

A base element for a module

| +|options|Options|||

The option object of the InfiniteGrid module

| + +```html + + +``` + +## Methods + +### renderItems {#renderItems} + +
+ +
+ +

Rearrange items to fit the grid and render them. When rearrange is complete, the renderComplete event is fired.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|options|RenderOptions|✔️|{}|

Options for rendering.

| + +```ts +import { MasonryInfiniteGrid } from "@egjs/infinitegrid"; +const grid = new MasonryInfiniteGrid(); + +grid.on("renderComplete", e => { + console.log(e); +}); +grid.renderItems(); +``` + +### getWrapperElement {#getWrapperElement} + +
+ +
+ +

Returns the wrapper element specified by the user.

+ +### getScrollContainerElement {#getScrollContainerElement} + +
+ +
+ +

Returns the container element corresponding to the scroll area.

+ +### getContainerElement {#getContainerElement} + +
+ +
+ +

Returns the container element containing item elements.

+ +### syncItems {#syncItems} + +
+ +
+ +

When items change, it synchronizes and renders items.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|[InfiniteGridItemInfo](InfiniteGridItemInfo)[]|||

Options for rendering.

| + +### setCursors {#setCursors} + +
+ +
+ +

Change the currently visible groups.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|startCursor|number|||

first index of visible groups.

| +|endCursor|number|||

last index of visible groups.

| +|useFirstRender|boolean|✔️||

Whether the first rendering has already been done.

| + +### getStartCursor {#getStartCursor} + +
+ +
+ +

Returns the first index of visible groups.

+ +**Returns**: number + +### getEndCursor {#getEndCursor} + +
+ +
+ +

Returns the last index of visible groups.

+ +**Returns**: number + +### append {#append} + +
+ +
+ +

Add items at the bottom(right) of the grid.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```js +ig.append(`
test1
test2
`); +ig.append([`
test1
`, `
test2
`]); +ig.append([HTMLElement1, HTMLElement2]); +``` + +### prepend {#prepend} + +
+ +
+ +

Add items at the top(left) of the grid.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.prepend(`
test1
test2
`); +ig.prepend([`
test1
`, `
test2
`]); +ig.prepend([HTMLElement1, HTMLElement2]); +``` + +### insert {#insert} + +
+ +
+ +

Add items to a specific index.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||

index to add

| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.insert(2, `
test1
test2
`); +ig.insert(3, [`
test1
`, `
test2
`]); +ig.insert(4, [HTMLElement1, HTMLElement2]); +``` + +### insertByGroupIndex {#insertByGroupIndex} + +
+ +
+ +

Add items based on group index.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|groupIndex|number|||

group index to add

| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.insertByGroupIndex(2, `
test1
test2
`); +ig.insertByGroupIndex(3, [`
test1
`, `
test2
`]); +ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); +``` + +### getStatus {#getStatus} + +
+ +
+ +

Returns the current state of a module such as location information. You can use the setStatus() method to restore the information returned through a call to this method.

+ +**Returns**: [InfiniteGridStatus](InfiniteGridStatus) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|STATUS_TYPE|✔️||

STATUS_TYPE.NOT_REMOVE = Get all information about items. STATUS_TYPE.REMOVE_INVISIBLE_ITEMS = Get information on visible items only. STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS = Compress invisible items. You can replace it with a placeholder. STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS = Compress invisible groups.

| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### setPlaceholder {#setPlaceholder} + +
+ +
+ +

You can set placeholders to restore status or wait for items to be added.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||

The placeholder status.

| + +### setLoading {#setLoading} + +
+ +
+ +

You can set placeholders to restore status or wait for items to be added.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||

The placeholder status.

| + +### appendPlaceholders {#appendPlaceholders} + +
+ +
+ +

Add the placeholder at the end.

+ +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||

Items that correspond to placeholders. If it is a number, it duplicates the number of copies.

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +### prependPlaceholders {#prependPlaceholders} + +
+ +
+ +

Add the placeholder at the start.

+ +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||

Items that correspond to placeholders. If it is a number, it duplicates the number of copies.

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +### removePlaceholders {#removePlaceholders} + +
+ +
+ +

Remove placeholders

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|"start" \| "end" \| {groupKey: string \| number}|||

Remove the placeholders corresponding to the groupkey. When "start" or "end", remove all placeholders in that direction.

| + +### setStatus {#setStatus} + +
+ +
+ +

Sets the status of the InfiniteGrid module with the information returned through a call to the getStatus() method.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|status|[InfiniteGridStatus](InfiniteGridStatus)|||

status object of the InfiniteGrid module.

| +|useFirstRender|boolean|✔️||

Whether the first rendering has already been done.

| + +### removeGroupByIndex {#removeGroupByIndex} + +
+ +
+ +

Removes the group corresponding to index.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeGroupByKey {#removeGroupByKey} + +
+ +
+ +

Removes the group corresponding to key.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|number \| string|||| + +### removeByIndex {#removeByIndex} + +
+ +
+ +

Removes the item corresponding to index.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeByKey {#removeByKey} + +
+ +
+ +

Removes the item corresponding to key.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|string \| number|||| + +### updateItems {#updateItems} + +
+ +
+ +

Update the size of the items and render them.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridItem[]|✔️||

Items to be updated.

| +|options|RenderOptions|✔️|{}|

Options for rendering.

| + +### getItems {#getItems} + +
+ +
+ +

Return all items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### getVisibleItems {#getVisibleItems} + +
+ +
+ +

Return visible items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### getRenderingItems {#getRenderingItems} + +
+ +
+ +

Return rendering items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +### getGroups {#getGroups} + +
+ +
+ +

Return all groups of InfiniteGrid.

+ +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include groups corresponding to placeholders.

| + +### getVisibleGroups {#getVisibleGroups} + +
+ +
+ +

Return visible groups of InfiniteGrid.

+ +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include groups corresponding to placeholders.

| + +### wait {#wait} + +
+ +
+ +

Set to wait to request data.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|direction|"start" \| "end"|✔️|DIRECTION.END|

direction in which data will be added.

| + +### ready {#ready} + +
+ +
+ +

When the data request is complete, it is set to ready state.

+ +### isWait {#isWait} + +
+ +
+ +

Returns whether it is set to wait to request data.

+ +### destroy {#destroy} + +
+ +
+ +

Releases the instnace and events and returns the CSS of the container and elements.

+ +**Returns**: void + +### trigger {#trigger} + +
+ inherited +
+ +

Trigger a custom event.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||

The name of the custom event to be triggered or an instance of the ComponentEvent

| +|params|Array<any> \| $ts:...|||

Event data to be sent when triggering a custom event

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +

Executed event just one time.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +

Checks whether an event has been attached to a component.

+ +**Returns**: boolean +-

Indicates whether the event is attached.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||

The name of the event to be attached

| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +

Attaches an event to a component.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +

Detaches an event from the component.
If the eventName is not given this will detach all event handlers attached.
If the handlerToDetach is not given, this will detach all event handlers for eventName.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||

The name of the event to be detached

| +|handlerToDetach|function \| $ts:...|✔️||

The handler function of the event to be detached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + +## Events +### changeScroll {#event-changeScroll} + +
+ +
+ +

This event is fired when scrolling.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnChangeScroll|||

The object of data to be sent to an event

| + +### requestAppend {#event-requestAppend} + +
+ +
+ +

The event is fired when scrolling reaches the end or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestAppend|||

The object of data to be sent to an event

| + +### requestPrepend {#event-requestPrepend} + +
+ +
+ +

The event is fired when scrolling reaches the start or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestPrepend|||

The object of data to be sent to an event

| + +### contentError {#event-contentError} + +
+ +
+ +

The event is fired when scrolling reaches the start or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnContentError|||

The object of data to be sent to an event

| + +### renderComplete {#event-renderComplete} + +
+ +
+ +

This event is fired when the InfiniteGrid has completed rendering.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRenderComplete|||

The object of data to be sent to an event

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/InfiniteGridItemInfo.mdx b/packages/docs/versioned_docs/version-4.11.1/api/InfiniteGridItemInfo.mdx new file mode 100644 index 000000000..82c858594 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/InfiniteGridItemInfo.mdx @@ -0,0 +1,21 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|type|ITEM_TYPE|| +|groupKey|string \| number|| +|inserted|boolean|| +|key|string \| number|| +|element|HTMLElement \| null|| +|html|string|| +|data|Record<string, any>|| +|attributes|Record<string, any>|| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/InfiniteGridOptions.mdx b/packages/docs/versioned_docs/version-4.11.1/api/InfiniteGridOptions.mdx new file mode 100644 index 000000000..4769f7be9 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/InfiniteGridOptions.mdx @@ -0,0 +1,42 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:| +|horizontal|boolean|false|

Direction of the scroll movement. (true: horizontal, false: vertical) If horizontal is false, inlinePos is left, inlineSize is width, contentPos is top, and contentSize is height. If horizontal is true, inlinePos is top, inlineSize is height, contentPos is left, and contentSize is width.

| +|percentage|Array<"position" \| "size"> \| boolean|false|

Whether to set the css size and position of the item to %.

| +|isEqualSize|boolean|false|

Indicates whether sizes of all card elements are equal to one another. If sizes of card elements to be arranged are all equal and this option is set to "true", the performance of layout arrangement can be improved.

| +|isConstantSize|boolean|false|

Indicates whether sizes of all card elements does not change, the performance of layout arrangement can be improved.

| +|gap|number|5|

Gap used to create space around items.

| +|attributePrefix|string|"data-grid-"|

The prefix to use element's data attribute.

| +|resizeDebounce|number|100|

Debounce time to set in the resize event. (unit: ms)

| +|maxResizeDebounce|number|0|

Maximum time to debounce the resize event. (0 is not set)

| +|autoResize|boolean|true|

Whether the resize method should be called automatically after a window resize event.

| +|useFit|boolean|true|

Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0.

| +|useTransform|boolean|false|

Whether to use transform property instead of using left and top css properties.

| +|renderOnPropertyChange|boolean|true|

Whether to automatically render through property change.

| +|preserveUIOnDestroy|boolean|false|

Whether to preserve the UI of the existing container or item when destroying.

| +|defaultDirection|"start" \| "end"|"end"|

The default direction value when direction is not set in the render option.

| +|outlineLength|number|0|

The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid.

| +|outlineSize|number|0|

The size of the outline. If the outline size is 0, it is calculated according to the grid type.

| +|useRoundedSize|boolean|true|

Whether to get the size as rounded size(offsetWidth, offsetHeight). Set to true if transform is applied to the container. If false, get the size through getBoundingClientRect.

| +|useResizeObserver|boolean|false|

Whether to use ResizeObserver event to detect container size change when autoResize option is used.

| +|observeChildren|boolean|false|

Whether to detect size change of children if useResizeObserver option is used.

| +|externalItemRenderer|ItemRenderer \| null||

You can set the ItemRenderer directly externally.

| +|externalContainerManager|ContainerManager \| null||

You can set the ContainerManager directly externally.

| +|container|boolean \| HTMLElement \| string \| Ref<HTMLElement>|false|

The target to which the container is applied. If false, create itself, if true, create container. A string or HTMLElement specifies the target directly.

| +|containerTag|string|"div"|

If you create a container, you can set the container's tag.

| +|threshold|number|100|

The size of the scrollable area for adding the next group of items.

| +|useRecycle|boolean|true|

Whether to show only the DOM of the visible area.

| +|scrollContainer|HTMLElement \| string \| Ref<HTMLElement> \| null||

You can set the scrollContainer directly. In this case, the container becomes the wrapper itself.

| +|gridConstructor|GridFunction||

Grid class to apply Infinite function.

| +|appliedItemChecker|(item: InfiniteGridItem, grid: Grid) => boolean||

A function that checks whether non-rendering items are included in the Grid.

| +|renderer|Renderer \| null||

class that renders the DOM.

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/InfiniteGridStatus.mdx b/packages/docs/versioned_docs/version-4.11.1/api/InfiniteGridStatus.mdx new file mode 100644 index 000000000..d72132f97 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/InfiniteGridStatus.mdx @@ -0,0 +1,17 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|itemRenderer|ItemRendererStatus|| +|containerManager|ContainerManagerStatus|| +|groupManager|GroupManagerStatus|| +|scrollManager|ScrollManagerStatus|| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/InsertedPlaceholdersResult.mdx b/packages/docs/versioned_docs/version-4.11.1/api/InsertedPlaceholdersResult.mdx new file mode 100644 index 000000000..b4a01fb4b --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/InsertedPlaceholdersResult.mdx @@ -0,0 +1,16 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|group|InfiniteGridGroup|

Groups corresponding to placeholders

| +|items|InfiniteGridItem[]|

Items corresponding to placeholders

| +|remove|() => void|

Remove the inserted placeholders.

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/JustifiedInfiniteGrid.mdx b/packages/docs/versioned_docs/version-4.11.1/api/JustifiedInfiniteGrid.mdx new file mode 100644 index 000000000..6854e91ab --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/JustifiedInfiniteGrid.mdx @@ -0,0 +1,732 @@ +--- +custom_edit_url: null +--- + +```ts +class JustifiedInfiniteGrid +``` + +
+ +
+ +

'justified' is a printing term with the meaning that 'it fits in one row wide'. JustifiedInfiniteGrid is a grid that the item is filled up on the basis of a line given a size.
If 'data-grid-inline-offset' or 'data-grid-content-offset' are set for item element, the ratio is maintained except for the offset value.
If 'data-grid-maintained-target' is set for an element whose ratio is to be maintained, the item is rendered while maintaining the ratio of the element.

+ +
+
Methods
Events
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
+ +## constructor +```ts +new JustifiedInfiniteGrid(container, options) +``` + +
+ +
+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|container|HTMLElement \| string|||

A base element for a module

| +|options|[JustifiedInfiniteGridOptions](JustifiedInfiniteGridOptions)|||

The option object of the JustifiedInfiniteGrid module

| + +## Methods + +### renderItems {#renderItems} + +
+ inherited +
+ +

Rearrange items to fit the grid and render them. When rearrange is complete, the renderComplete event is fired.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|options|RenderOptions|✔️|{}|

Options for rendering.

| + +```ts +import { MasonryInfiniteGrid } from "@egjs/infinitegrid"; +const grid = new MasonryInfiniteGrid(); + +grid.on("renderComplete", e => { + console.log(e); +}); +grid.renderItems(); +``` + +### getWrapperElement {#getWrapperElement} + +
+ inherited +
+ +

Returns the wrapper element specified by the user.

+ +### getScrollContainerElement {#getScrollContainerElement} + +
+ inherited +
+ +

Returns the container element corresponding to the scroll area.

+ +### getContainerElement {#getContainerElement} + +
+ inherited +
+ +

Returns the container element containing item elements.

+ +### syncItems {#syncItems} + +
+ inherited +
+ +

When items change, it synchronizes and renders items.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|[InfiniteGridItemInfo](InfiniteGridItemInfo)[]|||

Options for rendering.

| + +### setCursors {#setCursors} + +
+ inherited +
+ +

Change the currently visible groups.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|startCursor|number|||

first index of visible groups.

| +|endCursor|number|||

last index of visible groups.

| +|useFirstRender|boolean|✔️||

Whether the first rendering has already been done.

| + +### getStartCursor {#getStartCursor} + +
+ inherited +
+ +

Returns the first index of visible groups.

+ +**Returns**: number + +### getEndCursor {#getEndCursor} + +
+ inherited +
+ +

Returns the last index of visible groups.

+ +**Returns**: number + +### append {#append} + +
+ inherited +
+ +

Add items at the bottom(right) of the grid.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```js +ig.append(`
test1
test2
`); +ig.append([`
test1
`, `
test2
`]); +ig.append([HTMLElement1, HTMLElement2]); +``` + +### prepend {#prepend} + +
+ inherited +
+ +

Add items at the top(left) of the grid.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.prepend(`
test1
test2
`); +ig.prepend([`
test1
`, `
test2
`]); +ig.prepend([HTMLElement1, HTMLElement2]); +``` + +### insert {#insert} + +
+ inherited +
+ +

Add items to a specific index.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||

index to add

| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.insert(2, `
test1
test2
`); +ig.insert(3, [`
test1
`, `
test2
`]); +ig.insert(4, [HTMLElement1, HTMLElement2]); +``` + +### insertByGroupIndex {#insertByGroupIndex} + +
+ inherited +
+ +

Add items based on group index.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|groupIndex|number|||

group index to add

| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.insertByGroupIndex(2, `
test1
test2
`); +ig.insertByGroupIndex(3, [`
test1
`, `
test2
`]); +ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); +``` + +### getStatus {#getStatus} + +
+ inherited +
+ +

Returns the current state of a module such as location information. You can use the setStatus() method to restore the information returned through a call to this method.

+ +**Returns**: [InfiniteGridStatus](InfiniteGridStatus) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|STATUS_TYPE|✔️||

STATUS_TYPE.NOT_REMOVE = Get all information about items. STATUS_TYPE.REMOVE_INVISIBLE_ITEMS = Get information on visible items only. STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS = Compress invisible items. You can replace it with a placeholder. STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS = Compress invisible groups.

| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### setPlaceholder {#setPlaceholder} + +
+ inherited +
+ +

You can set placeholders to restore status or wait for items to be added.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||

The placeholder status.

| + +### setLoading {#setLoading} + +
+ inherited +
+ +

You can set placeholders to restore status or wait for items to be added.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||

The placeholder status.

| + +### appendPlaceholders {#appendPlaceholders} + +
+ inherited +
+ +

Add the placeholder at the end.

+ +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||

Items that correspond to placeholders. If it is a number, it duplicates the number of copies.

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +### prependPlaceholders {#prependPlaceholders} + +
+ inherited +
+ +

Add the placeholder at the start.

+ +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||

Items that correspond to placeholders. If it is a number, it duplicates the number of copies.

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +### removePlaceholders {#removePlaceholders} + +
+ inherited +
+ +

Remove placeholders

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|"start" \| "end" \| {groupKey: string \| number}|||

Remove the placeholders corresponding to the groupkey. When "start" or "end", remove all placeholders in that direction.

| + +### setStatus {#setStatus} + +
+ inherited +
+ +

Sets the status of the InfiniteGrid module with the information returned through a call to the getStatus() method.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|status|[InfiniteGridStatus](InfiniteGridStatus)|||

status object of the InfiniteGrid module.

| +|useFirstRender|boolean|✔️||

Whether the first rendering has already been done.

| + +### removeGroupByIndex {#removeGroupByIndex} + +
+ inherited +
+ +

Removes the group corresponding to index.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeGroupByKey {#removeGroupByKey} + +
+ inherited +
+ +

Removes the group corresponding to key.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|number \| string|||| + +### removeByIndex {#removeByIndex} + +
+ inherited +
+ +

Removes the item corresponding to index.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeByKey {#removeByKey} + +
+ inherited +
+ +

Removes the item corresponding to key.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|string \| number|||| + +### updateItems {#updateItems} + +
+ inherited +
+ +

Update the size of the items and render them.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridItem[]|✔️||

Items to be updated.

| +|options|RenderOptions|✔️|{}|

Options for rendering.

| + +### getItems {#getItems} + +
+ inherited +
+ +

Return all items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### getVisibleItems {#getVisibleItems} + +
+ inherited +
+ +

Return visible items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### getRenderingItems {#getRenderingItems} + +
+ inherited +
+ +

Return rendering items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +### getGroups {#getGroups} + +
+ inherited +
+ +

Return all groups of InfiniteGrid.

+ +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include groups corresponding to placeholders.

| + +### getVisibleGroups {#getVisibleGroups} + +
+ inherited +
+ +

Return visible groups of InfiniteGrid.

+ +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include groups corresponding to placeholders.

| + +### wait {#wait} + +
+ inherited +
+ +

Set to wait to request data.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|direction|"start" \| "end"|✔️|DIRECTION.END|

direction in which data will be added.

| + +### ready {#ready} + +
+ inherited +
+ +

When the data request is complete, it is set to ready state.

+ +### isWait {#isWait} + +
+ inherited +
+ +

Returns whether it is set to wait to request data.

+ +### destroy {#destroy} + +
+ inherited +
+ +

Releases the instnace and events and returns the CSS of the container and elements.

+ +**Returns**: void + +### trigger {#trigger} + +
+ inherited +
+ +

Trigger a custom event.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||

The name of the custom event to be triggered or an instance of the ComponentEvent

| +|params|Array<any> \| $ts:...|||

Event data to be sent when triggering a custom event

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +

Executed event just one time.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +

Checks whether an event has been attached to a component.

+ +**Returns**: boolean +-

Indicates whether the event is attached.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||

The name of the event to be attached

| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +

Attaches an event to a component.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +

Detaches an event from the component.
If the eventName is not given this will detach all event handlers attached.
If the handlerToDetach is not given, this will detach all event handlers for eventName.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||

The name of the event to be detached

| +|handlerToDetach|function \| $ts:...|✔️||

The handler function of the event to be detached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + +## Events +### changeScroll {#event-changeScroll} + +
+ inherited +
+ +

This event is fired when scrolling.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnChangeScroll|||

The object of data to be sent to an event

| + +### requestAppend {#event-requestAppend} + +
+ inherited +
+ +

The event is fired when scrolling reaches the end or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestAppend|||

The object of data to be sent to an event

| + +### requestPrepend {#event-requestPrepend} + +
+ inherited +
+ +

The event is fired when scrolling reaches the start or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestPrepend|||

The object of data to be sent to an event

| + +### contentError {#event-contentError} + +
+ inherited +
+ +

The event is fired when scrolling reaches the start or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnContentError|||

The object of data to be sent to an event

| + +### renderComplete {#event-renderComplete} + +
+ inherited +
+ +

This event is fired when the InfiniteGrid has completed rendering.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRenderComplete|||

The object of data to be sent to an event

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/JustifiedInfiniteGridOptions.mdx b/packages/docs/versioned_docs/version-4.11.1/api/JustifiedInfiniteGridOptions.mdx new file mode 100644 index 000000000..9a2fd7d6d --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/JustifiedInfiniteGridOptions.mdx @@ -0,0 +1,68 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:| +|horizontal|boolean|false|

Direction of the scroll movement. (true: horizontal, false: vertical) If horizontal is false, inlinePos is left, inlineSize is width, contentPos is top, and contentSize is height. If horizontal is true, inlinePos is top, inlineSize is height, contentPos is left, and contentSize is width.

| +|percentage|Array<"position" \| "size"> \| boolean|false|

Whether to set the css size and position of the item to %.

| +|isEqualSize|boolean|false|

Indicates whether sizes of all card elements are equal to one another. If sizes of card elements to be arranged are all equal and this option is set to "true", the performance of layout arrangement can be improved.

| +|isConstantSize|boolean|false|

Indicates whether sizes of all card elements does not change, the performance of layout arrangement can be improved.

| +|gap|number|5|

Gap used to create space around items.

| +|attributePrefix|string|"data-grid-"|

The prefix to use element's data attribute.

| +|resizeDebounce|number|100|

Debounce time to set in the resize event. (unit: ms)

| +|maxResizeDebounce|number|0|

Maximum time to debounce the resize event. (0 is not set)

| +|autoResize|boolean|true|

Whether the resize method should be called automatically after a window resize event.

| +|useFit|boolean|true|

Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0.

| +|useTransform|boolean|false|

Whether to use transform property instead of using left and top css properties.

| +|renderOnPropertyChange|boolean|true|

Whether to automatically render through property change.

| +|preserveUIOnDestroy|boolean|false|

Whether to preserve the UI of the existing container or item when destroying.

| +|defaultDirection|"start" \| "end"|"end"|

The default direction value when direction is not set in the render option.

| +|outlineLength|number|0|

The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid.

| +|outlineSize|number|0|

The size of the outline. If the outline size is 0, it is calculated according to the grid type.

| +|useRoundedSize|boolean|true|

Whether to get the size as rounded size(offsetWidth, offsetHeight). Set to true if transform is applied to the container. If false, get the size through getBoundingClientRect.

| +|useResizeObserver|boolean|false|

Whether to use ResizeObserver event to detect container size change when autoResize option is used.

| +|observeChildren|boolean|false|

Whether to detect size change of children if useResizeObserver option is used.

| +|externalItemRenderer|ItemRenderer \| null||

You can set the ItemRenderer directly externally.

| +|externalContainerManager|ContainerManager \| null||

You can set the ContainerManager directly externally.

| +|columnRange|number \| number[]|[1, 8]|

The minimum and maximum number of items per line.

| +|rowRange|number \| number[]|0|

The minimum and maximum number of rows in a group, 0 is not set.

| +|sizeRange|number \| number[]|[0, Infinity]|

The minimum and maximum size by which the item is adjusted. If it is not calculated, it may deviate from the minimum and maximum sizes.

| +|displayedRow|number|-1|

Maximum number of rows to be counted for container size. You can hide it on the screen by setting overflow: hidden. -1 is not set.

| +|isCroppedSize|boolean|false|

Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken.

| +|horizontal|boolean|false|

Direction of the scroll movement. (true: horizontal, false: vertical) If horizontal is false, inlinePos is left, inlineSize is width, contentPos is top, and contentSize is height. If horizontal is true, inlinePos is top, inlineSize is height, contentPos is left, and contentSize is width.

| +|percentage|Array<"position" \| "size"> \| boolean|false|

Whether to set the css size and position of the item to %.

| +|isEqualSize|boolean|false|

Indicates whether sizes of all card elements are equal to one another. If sizes of card elements to be arranged are all equal and this option is set to "true", the performance of layout arrangement can be improved.

| +|isConstantSize|boolean|false|

Indicates whether sizes of all card elements does not change, the performance of layout arrangement can be improved.

| +|gap|number|5|

Gap used to create space around items.

| +|attributePrefix|string|"data-grid-"|

The prefix to use element's data attribute.

| +|resizeDebounce|number|100|

Debounce time to set in the resize event. (unit: ms)

| +|maxResizeDebounce|number|0|

Maximum time to debounce the resize event. (0 is not set)

| +|autoResize|boolean|true|

Whether the resize method should be called automatically after a window resize event.

| +|useFit|boolean|true|

Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0.

| +|useTransform|boolean|false|

Whether to use transform property instead of using left and top css properties.

| +|renderOnPropertyChange|boolean|true|

Whether to automatically render through property change.

| +|preserveUIOnDestroy|boolean|false|

Whether to preserve the UI of the existing container or item when destroying.

| +|defaultDirection|"start" \| "end"|"end"|

The default direction value when direction is not set in the render option.

| +|outlineLength|number|0|

The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid.

| +|outlineSize|number|0|

The size of the outline. If the outline size is 0, it is calculated according to the grid type.

| +|useRoundedSize|boolean|true|

Whether to get the size as rounded size(offsetWidth, offsetHeight). Set to true if transform is applied to the container. If false, get the size through getBoundingClientRect.

| +|useResizeObserver|boolean|false|

Whether to use ResizeObserver event to detect container size change when autoResize option is used.

| +|observeChildren|boolean|false|

Whether to detect size change of children if useResizeObserver option is used.

| +|externalItemRenderer|ItemRenderer \| null||

You can set the ItemRenderer directly externally.

| +|externalContainerManager|ContainerManager \| null||

You can set the ContainerManager directly externally.

| +|container|boolean \| HTMLElement \| string \| Ref<HTMLElement>|false|

The target to which the container is applied. If false, create itself, if true, create container. A string or HTMLElement specifies the target directly.

| +|containerTag|string|"div"|

If you create a container, you can set the container's tag.

| +|threshold|number|100|

The size of the scrollable area for adding the next group of items.

| +|useRecycle|boolean|true|

Whether to show only the DOM of the visible area.

| +|scrollContainer|HTMLElement \| string \| Ref<HTMLElement> \| null||

You can set the scrollContainer directly. In this case, the container becomes the wrapper itself.

| +|gridConstructor|GridFunction||

Grid class to apply Infinite function.

| +|appliedItemChecker|(item: InfiniteGridItem, grid: Grid) => boolean||

A function that checks whether non-rendering items are included in the Grid.

| +|renderer|Renderer \| null||

class that renders the DOM.

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/MasonryInfiniteGrid.mdx b/packages/docs/versioned_docs/version-4.11.1/api/MasonryInfiniteGrid.mdx new file mode 100644 index 000000000..f85c5d337 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/MasonryInfiniteGrid.mdx @@ -0,0 +1,732 @@ +--- +custom_edit_url: null +--- + +```ts +class MasonryInfiniteGrid +``` + +
+ +
+ +

MasonryInfiniteGrid is a grid that stacks items with the same width as a stack of bricks. Adjust the width of all images to the same size, find the lowest height column, and insert a new item.

+ +
+
Methods
Events
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
+ +## constructor +```ts +new MasonryInfiniteGrid(container, options) +``` + +
+ +
+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|container|HTMLElement \| string|||

A base element for a module

| +|options|[MasonryInfiniteGridOptions](MasonryInfiniteGridOptions)|||

The option object of the MasonryInfiniteGrid module

| + +## Methods + +### renderItems {#renderItems} + +
+ inherited +
+ +

Rearrange items to fit the grid and render them. When rearrange is complete, the renderComplete event is fired.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|options|RenderOptions|✔️|{}|

Options for rendering.

| + +```ts +import { MasonryInfiniteGrid } from "@egjs/infinitegrid"; +const grid = new MasonryInfiniteGrid(); + +grid.on("renderComplete", e => { + console.log(e); +}); +grid.renderItems(); +``` + +### getWrapperElement {#getWrapperElement} + +
+ inherited +
+ +

Returns the wrapper element specified by the user.

+ +### getScrollContainerElement {#getScrollContainerElement} + +
+ inherited +
+ +

Returns the container element corresponding to the scroll area.

+ +### getContainerElement {#getContainerElement} + +
+ inherited +
+ +

Returns the container element containing item elements.

+ +### syncItems {#syncItems} + +
+ inherited +
+ +

When items change, it synchronizes and renders items.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|[InfiniteGridItemInfo](InfiniteGridItemInfo)[]|||

Options for rendering.

| + +### setCursors {#setCursors} + +
+ inherited +
+ +

Change the currently visible groups.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|startCursor|number|||

first index of visible groups.

| +|endCursor|number|||

last index of visible groups.

| +|useFirstRender|boolean|✔️||

Whether the first rendering has already been done.

| + +### getStartCursor {#getStartCursor} + +
+ inherited +
+ +

Returns the first index of visible groups.

+ +**Returns**: number + +### getEndCursor {#getEndCursor} + +
+ inherited +
+ +

Returns the last index of visible groups.

+ +**Returns**: number + +### append {#append} + +
+ inherited +
+ +

Add items at the bottom(right) of the grid.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```js +ig.append(`
test1
test2
`); +ig.append([`
test1
`, `
test2
`]); +ig.append([HTMLElement1, HTMLElement2]); +``` + +### prepend {#prepend} + +
+ inherited +
+ +

Add items at the top(left) of the grid.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.prepend(`
test1
test2
`); +ig.prepend([`
test1
`, `
test2
`]); +ig.prepend([HTMLElement1, HTMLElement2]); +``` + +### insert {#insert} + +
+ inherited +
+ +

Add items to a specific index.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||

index to add

| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.insert(2, `
test1
test2
`); +ig.insert(3, [`
test1
`, `
test2
`]); +ig.insert(4, [HTMLElement1, HTMLElement2]); +``` + +### insertByGroupIndex {#insertByGroupIndex} + +
+ inherited +
+ +

Add items based on group index.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|groupIndex|number|||

group index to add

| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.insertByGroupIndex(2, `
test1
test2
`); +ig.insertByGroupIndex(3, [`
test1
`, `
test2
`]); +ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); +``` + +### getStatus {#getStatus} + +
+ inherited +
+ +

Returns the current state of a module such as location information. You can use the setStatus() method to restore the information returned through a call to this method.

+ +**Returns**: [InfiniteGridStatus](InfiniteGridStatus) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|STATUS_TYPE|✔️||

STATUS_TYPE.NOT_REMOVE = Get all information about items. STATUS_TYPE.REMOVE_INVISIBLE_ITEMS = Get information on visible items only. STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS = Compress invisible items. You can replace it with a placeholder. STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS = Compress invisible groups.

| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### setPlaceholder {#setPlaceholder} + +
+ inherited +
+ +

You can set placeholders to restore status or wait for items to be added.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||

The placeholder status.

| + +### setLoading {#setLoading} + +
+ inherited +
+ +

You can set placeholders to restore status or wait for items to be added.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||

The placeholder status.

| + +### appendPlaceholders {#appendPlaceholders} + +
+ inherited +
+ +

Add the placeholder at the end.

+ +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||

Items that correspond to placeholders. If it is a number, it duplicates the number of copies.

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +### prependPlaceholders {#prependPlaceholders} + +
+ inherited +
+ +

Add the placeholder at the start.

+ +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||

Items that correspond to placeholders. If it is a number, it duplicates the number of copies.

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +### removePlaceholders {#removePlaceholders} + +
+ inherited +
+ +

Remove placeholders

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|"start" \| "end" \| {groupKey: string \| number}|||

Remove the placeholders corresponding to the groupkey. When "start" or "end", remove all placeholders in that direction.

| + +### setStatus {#setStatus} + +
+ inherited +
+ +

Sets the status of the InfiniteGrid module with the information returned through a call to the getStatus() method.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|status|[InfiniteGridStatus](InfiniteGridStatus)|||

status object of the InfiniteGrid module.

| +|useFirstRender|boolean|✔️||

Whether the first rendering has already been done.

| + +### removeGroupByIndex {#removeGroupByIndex} + +
+ inherited +
+ +

Removes the group corresponding to index.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeGroupByKey {#removeGroupByKey} + +
+ inherited +
+ +

Removes the group corresponding to key.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|number \| string|||| + +### removeByIndex {#removeByIndex} + +
+ inherited +
+ +

Removes the item corresponding to index.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeByKey {#removeByKey} + +
+ inherited +
+ +

Removes the item corresponding to key.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|string \| number|||| + +### updateItems {#updateItems} + +
+ inherited +
+ +

Update the size of the items and render them.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridItem[]|✔️||

Items to be updated.

| +|options|RenderOptions|✔️|{}|

Options for rendering.

| + +### getItems {#getItems} + +
+ inherited +
+ +

Return all items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### getVisibleItems {#getVisibleItems} + +
+ inherited +
+ +

Return visible items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### getRenderingItems {#getRenderingItems} + +
+ inherited +
+ +

Return rendering items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +### getGroups {#getGroups} + +
+ inherited +
+ +

Return all groups of InfiniteGrid.

+ +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include groups corresponding to placeholders.

| + +### getVisibleGroups {#getVisibleGroups} + +
+ inherited +
+ +

Return visible groups of InfiniteGrid.

+ +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include groups corresponding to placeholders.

| + +### wait {#wait} + +
+ inherited +
+ +

Set to wait to request data.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|direction|"start" \| "end"|✔️|DIRECTION.END|

direction in which data will be added.

| + +### ready {#ready} + +
+ inherited +
+ +

When the data request is complete, it is set to ready state.

+ +### isWait {#isWait} + +
+ inherited +
+ +

Returns whether it is set to wait to request data.

+ +### destroy {#destroy} + +
+ inherited +
+ +

Releases the instnace and events and returns the CSS of the container and elements.

+ +**Returns**: void + +### trigger {#trigger} + +
+ inherited +
+ +

Trigger a custom event.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||

The name of the custom event to be triggered or an instance of the ComponentEvent

| +|params|Array<any> \| $ts:...|||

Event data to be sent when triggering a custom event

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +

Executed event just one time.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +

Checks whether an event has been attached to a component.

+ +**Returns**: boolean +-

Indicates whether the event is attached.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||

The name of the event to be attached

| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +

Attaches an event to a component.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +

Detaches an event from the component.
If the eventName is not given this will detach all event handlers attached.
If the handlerToDetach is not given, this will detach all event handlers for eventName.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||

The name of the event to be detached

| +|handlerToDetach|function \| $ts:...|✔️||

The handler function of the event to be detached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + +## Events +### changeScroll {#event-changeScroll} + +
+ inherited +
+ +

This event is fired when scrolling.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnChangeScroll|||

The object of data to be sent to an event

| + +### requestAppend {#event-requestAppend} + +
+ inherited +
+ +

The event is fired when scrolling reaches the end or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestAppend|||

The object of data to be sent to an event

| + +### requestPrepend {#event-requestPrepend} + +
+ inherited +
+ +

The event is fired when scrolling reaches the start or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestPrepend|||

The object of data to be sent to an event

| + +### contentError {#event-contentError} + +
+ inherited +
+ +

The event is fired when scrolling reaches the start or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnContentError|||

The object of data to be sent to an event

| + +### renderComplete {#event-renderComplete} + +
+ inherited +
+ +

This event is fired when the InfiniteGrid has completed rendering.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRenderComplete|||

The object of data to be sent to an event

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/MasonryInfiniteGridOptions.mdx b/packages/docs/versioned_docs/version-4.11.1/api/MasonryInfiniteGridOptions.mdx new file mode 100644 index 000000000..ca88395a6 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/MasonryInfiniteGridOptions.mdx @@ -0,0 +1,70 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:| +|horizontal|boolean|false|

Direction of the scroll movement. (true: horizontal, false: vertical) If horizontal is false, inlinePos is left, inlineSize is width, contentPos is top, and contentSize is height. If horizontal is true, inlinePos is top, inlineSize is height, contentPos is left, and contentSize is width.

| +|percentage|Array<"position" \| "size"> \| boolean|false|

Whether to set the css size and position of the item to %.

| +|isEqualSize|boolean|false|

Indicates whether sizes of all card elements are equal to one another. If sizes of card elements to be arranged are all equal and this option is set to "true", the performance of layout arrangement can be improved.

| +|isConstantSize|boolean|false|

Indicates whether sizes of all card elements does not change, the performance of layout arrangement can be improved.

| +|gap|number|5|

Gap used to create space around items.

| +|attributePrefix|string|"data-grid-"|

The prefix to use element's data attribute.

| +|resizeDebounce|number|100|

Debounce time to set in the resize event. (unit: ms)

| +|maxResizeDebounce|number|0|

Maximum time to debounce the resize event. (0 is not set)

| +|autoResize|boolean|true|

Whether the resize method should be called automatically after a window resize event.

| +|useFit|boolean|true|

Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0.

| +|useTransform|boolean|false|

Whether to use transform property instead of using left and top css properties.

| +|renderOnPropertyChange|boolean|true|

Whether to automatically render through property change.

| +|preserveUIOnDestroy|boolean|false|

Whether to preserve the UI of the existing container or item when destroying.

| +|defaultDirection|"start" \| "end"|"end"|

The default direction value when direction is not set in the render option.

| +|outlineLength|number|0|

The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid.

| +|outlineSize|number|0|

The size of the outline. If the outline size is 0, it is calculated according to the grid type.

| +|useRoundedSize|boolean|true|

Whether to get the size as rounded size(offsetWidth, offsetHeight). Set to true if transform is applied to the container. If false, get the size through getBoundingClientRect.

| +|useResizeObserver|boolean|false|

Whether to use ResizeObserver event to detect container size change when autoResize option is used.

| +|observeChildren|boolean|false|

Whether to detect size change of children if useResizeObserver option is used.

| +|externalItemRenderer|ItemRenderer \| null||

You can set the ItemRenderer directly externally.

| +|externalContainerManager|ContainerManager \| null||

You can set the ContainerManager directly externally.

| +|column|number|0|

The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container. Can be used instead of outlineLength.

| +|columnSize|number|0|

The size of the columns. If it is 0, it is calculated as the size of the first item in items. Can be used instead of outlineSize.

| +|columnSizeRatio|number|0|

The size ratio(inlineSize / contentSize) of the columns. 0 is not set.

| +|align|GridAlign|"justify"|

Align of the position of the items. If you want to use stretch, be sure to set column, columnSize or maxStretchColumnSize option. ("start", "center", "end", "justify", "stretch")

| +|contentAlign|MasonryGridVerticalAlign|"masonry"|

Content direction alignment of items. “Masonry” is sorted in the form of masonry. Others are applied as content direction alignment, similar to vertical-align of inline-block.
If you set multiple columns (data-grid-column), the screen may look strange.

| +|columnCalculationThreshold|number|1|

Difference Threshold for Counting Columns. Since offsetSize is calculated by rounding, the number of columns may not be accurate.

| +|maxStretchColumnSize|number|Infinity|

If stretch is used, the column can be automatically calculated by setting the maximum size of the column that can be stretched.

| +|horizontal|boolean|false|

Direction of the scroll movement. (true: horizontal, false: vertical) If horizontal is false, inlinePos is left, inlineSize is width, contentPos is top, and contentSize is height. If horizontal is true, inlinePos is top, inlineSize is height, contentPos is left, and contentSize is width.

| +|percentage|Array<"position" \| "size"> \| boolean|false|

Whether to set the css size and position of the item to %.

| +|isEqualSize|boolean|false|

Indicates whether sizes of all card elements are equal to one another. If sizes of card elements to be arranged are all equal and this option is set to "true", the performance of layout arrangement can be improved.

| +|isConstantSize|boolean|false|

Indicates whether sizes of all card elements does not change, the performance of layout arrangement can be improved.

| +|gap|number|5|

Gap used to create space around items.

| +|attributePrefix|string|"data-grid-"|

The prefix to use element's data attribute.

| +|resizeDebounce|number|100|

Debounce time to set in the resize event. (unit: ms)

| +|maxResizeDebounce|number|0|

Maximum time to debounce the resize event. (0 is not set)

| +|autoResize|boolean|true|

Whether the resize method should be called automatically after a window resize event.

| +|useFit|boolean|true|

Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0.

| +|useTransform|boolean|false|

Whether to use transform property instead of using left and top css properties.

| +|renderOnPropertyChange|boolean|true|

Whether to automatically render through property change.

| +|preserveUIOnDestroy|boolean|false|

Whether to preserve the UI of the existing container or item when destroying.

| +|defaultDirection|"start" \| "end"|"end"|

The default direction value when direction is not set in the render option.

| +|outlineLength|number|0|

The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid.

| +|outlineSize|number|0|

The size of the outline. If the outline size is 0, it is calculated according to the grid type.

| +|useRoundedSize|boolean|true|

Whether to get the size as rounded size(offsetWidth, offsetHeight). Set to true if transform is applied to the container. If false, get the size through getBoundingClientRect.

| +|useResizeObserver|boolean|false|

Whether to use ResizeObserver event to detect container size change when autoResize option is used.

| +|observeChildren|boolean|false|

Whether to detect size change of children if useResizeObserver option is used.

| +|externalItemRenderer|ItemRenderer \| null||

You can set the ItemRenderer directly externally.

| +|externalContainerManager|ContainerManager \| null||

You can set the ContainerManager directly externally.

| +|container|boolean \| HTMLElement \| string \| Ref<HTMLElement>|false|

The target to which the container is applied. If false, create itself, if true, create container. A string or HTMLElement specifies the target directly.

| +|containerTag|string|"div"|

If you create a container, you can set the container's tag.

| +|threshold|number|100|

The size of the scrollable area for adding the next group of items.

| +|useRecycle|boolean|true|

Whether to show only the DOM of the visible area.

| +|scrollContainer|HTMLElement \| string \| Ref<HTMLElement> \| null||

You can set the scrollContainer directly. In this case, the container becomes the wrapper itself.

| +|gridConstructor|GridFunction||

Grid class to apply Infinite function.

| +|appliedItemChecker|(item: InfiniteGridItem, grid: Grid) => boolean||

A function that checks whether non-rendering items are included in the Grid.

| +|renderer|Renderer \| null||

class that renders the DOM.

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/OnChangeScroll.mdx b/packages/docs/versioned_docs/version-4.11.1/api/OnChangeScroll.mdx new file mode 100644 index 000000000..11bc9deb3 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/OnChangeScroll.mdx @@ -0,0 +1,17 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|currentTarget|[InfiniteGrid](InfiniteGrid)|

An InfiniteGrid instance that triggered this event.

| +|direction|"start" \| "end"|

The scroll direction.

| +|scrollPos|number|

The scroll position.

| +|relativeScrollPos|number|

The scroll position relative to container.

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/OnContentError.mdx b/packages/docs/versioned_docs/version-4.11.1/api/OnContentError.mdx new file mode 100644 index 000000000..1a1974cd6 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/OnContentError.mdx @@ -0,0 +1,19 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|currentTarget|[InfiniteGrid](InfiniteGrid)|

An InfiniteGrid instance that triggered this event.

| +|element|HTMLElement|

The item's element.

| +|target|HTMLElement|

The content element with error.

| +|item|InfiniteGridItem|

The item with error content.

| +|update|() => void|

If you have fixed the error and want to recheck it, call update(). If you remove an element, call the syncElements() method.

| +|remove|() => void|

If you want to remove the item corresponding to the error, call remove().

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/OnRenderComplete.mdx b/packages/docs/versioned_docs/version-4.11.1/api/OnRenderComplete.mdx new file mode 100644 index 000000000..60dc9a95b --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/OnRenderComplete.mdx @@ -0,0 +1,22 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|currentTarget|[InfiniteGrid](InfiniteGrid)|

An InfiniteGrid instance that triggered this event.

| +|mounted|InfiniteGridItem[]|

The items rendered for the first time.

| +|updated|InfiniteGridItem[]|

The items updated in size.

| +|direction|"start" \| "end"|

The direction InfiniteGrid was rendered.

| +|isResize|boolean|

Whether rendering was done using the resize event or the useResize option.

| +|startCursor|number|

The key of the first group that has been rendered.

| +|endCursor|number|

The key of the last group that has been rendered.

| +|items|InfiniteGridItem[]|

Items that have been rendered.

| +|groups|InfiniteGridGroup[]|

Groups that have been rendered.

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/OnRequestAppend.mdx b/packages/docs/versioned_docs/version-4.11.1/api/OnRequestAppend.mdx new file mode 100644 index 000000000..0e77174d2 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/OnRequestAppend.mdx @@ -0,0 +1,20 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|currentTarget|[InfiniteGrid](InfiniteGrid)|

An InfiniteGrid instance that triggered this event.

| +|groupKey|string \| number \| undefined|

Last group key.

| +|nextGroupKey|string \| number \| undefined|

The key of the next group that should replace Virtual Item(placeholder)s.

| +|nextGroupKeys|Array<string \| number>|

Array of the following group keys that need to be replaced with Virtual Item(placeholder)s.

| +|isVirtual|boolean|

Whether to request virtual groups corresponding to Virtual Item(placeholder)s.

| +|wait|() => void|

Set to standby to request data.

| +|ready|() => void|

When the data request is complete, it is set to ready state.

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/OnRequestPrepend.mdx b/packages/docs/versioned_docs/version-4.11.1/api/OnRequestPrepend.mdx new file mode 100644 index 000000000..852f9ae45 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/OnRequestPrepend.mdx @@ -0,0 +1,20 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DESCRIPTION| +|:---:|:---:|:---:| +|currentTarget|[InfiniteGrid](InfiniteGrid)|

An InfiniteGrid instance that triggered this event.

| +|groupKey|string \| number \| undefined|

First group key.

| +|nextGroupKey|string \| number \| undefined|

The key of the next group that should replace Virtual Item(placeholder)s.

| +|nextGroupKeys|Array<string \| number>|

Array of the following group keys that need to be replaced with Virtual Item(placeholder)s.

| +|isVirtual|boolean|

Whether to request virtual groups corresponding to Virtual Item(placeholder)s.

| +|wait|() => void|

Set to standby to request data.

| +|ready|() => void|

When the data request is complete, it is set to ready state.

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/PackingInfiniteGrid.mdx b/packages/docs/versioned_docs/version-4.11.1/api/PackingInfiniteGrid.mdx new file mode 100644 index 000000000..5cedfdb3c --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/PackingInfiniteGrid.mdx @@ -0,0 +1,732 @@ +--- +custom_edit_url: null +--- + +```ts +class PackingInfiniteGrid +``` + +
+ +
+ +

The PackingInfiniteGrid is a grid that shows the important items bigger without sacrificing the weight of the items.
Rows and columns are separated so that items are dynamically placed within the horizontal and vertical space rather than arranged in an orderly fashion.
If sizeWeight is higher than ratioWeight, the size of items is preserved as much as possible.
Conversely, if ratioWeight is higher than sizeWeight, the ratio of items is preserved as much as possible.

+ +
+
Methods
Events
+
renderItems
getWrapperElement
getScrollContainerElement
getContainerElement
syncItems
setCursors
getStartCursor
getEndCursor
append
prepend
insert
insertByGroupIndex
getStatus
setPlaceholder
setLoading
appendPlaceholders
prependPlaceholders
removePlaceholders
setStatus
removeGroupByIndex
removeGroupByKey
removeByIndex
removeByKey
updateItems
getItems
getVisibleItems
getRenderingItems
getGroups
getVisibleGroups
wait
ready
isWait
destroy
trigger
once
hasOn
on
off
changeScroll
requestAppend
requestPrepend
contentError
renderComplete
+
+ +## constructor +```ts +new PackingInfiniteGrid(container, options) +``` + +
+ +
+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|container|HTMLElement \| string|||

A base element for a module

| +|options|[PackingInfiniteGridOptions](PackingInfiniteGridOptions)|||

The option object of the PackingInfiniteGrid module

| + +## Methods + +### renderItems {#renderItems} + +
+ inherited +
+ +

Rearrange items to fit the grid and render them. When rearrange is complete, the renderComplete event is fired.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|options|RenderOptions|✔️|{}|

Options for rendering.

| + +```ts +import { MasonryInfiniteGrid } from "@egjs/infinitegrid"; +const grid = new MasonryInfiniteGrid(); + +grid.on("renderComplete", e => { + console.log(e); +}); +grid.renderItems(); +``` + +### getWrapperElement {#getWrapperElement} + +
+ inherited +
+ +

Returns the wrapper element specified by the user.

+ +### getScrollContainerElement {#getScrollContainerElement} + +
+ inherited +
+ +

Returns the container element corresponding to the scroll area.

+ +### getContainerElement {#getContainerElement} + +
+ inherited +
+ +

Returns the container element containing item elements.

+ +### syncItems {#syncItems} + +
+ inherited +
+ +

When items change, it synchronizes and renders items.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|[InfiniteGridItemInfo](InfiniteGridItemInfo)[]|||

Options for rendering.

| + +### setCursors {#setCursors} + +
+ inherited +
+ +

Change the currently visible groups.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|startCursor|number|||

first index of visible groups.

| +|endCursor|number|||

last index of visible groups.

| +|useFirstRender|boolean|✔️||

Whether the first rendering has already been done.

| + +### getStartCursor {#getStartCursor} + +
+ inherited +
+ +

Returns the first index of visible groups.

+ +**Returns**: number + +### getEndCursor {#getEndCursor} + +
+ inherited +
+ +

Returns the last index of visible groups.

+ +**Returns**: number + +### append {#append} + +
+ inherited +
+ +

Add items at the bottom(right) of the grid.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```js +ig.append(`
test1
test2
`); +ig.append([`
test1
`, `
test2
`]); +ig.append([HTMLElement1, HTMLElement2]); +``` + +### prepend {#prepend} + +
+ inherited +
+ +

Add items at the top(left) of the grid.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.prepend(`
test1
test2
`); +ig.prepend([`
test1
`, `
test2
`]); +ig.prepend([HTMLElement1, HTMLElement2]); +``` + +### insert {#insert} + +
+ inherited +
+ +

Add items to a specific index.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||

index to add

| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.insert(2, `
test1
test2
`); +ig.insert(3, [`
test1
`, `
test2
`]); +ig.insert(4, [HTMLElement1, HTMLElement2]); +``` + +### insertByGroupIndex {#insertByGroupIndex} + +
+ inherited +
+ +

Add items based on group index.

+ +**Returns**: this +- + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|groupIndex|number|||

group index to add

| +|items|InfiniteGridInsertedItems|||

items to be added

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +```ts +ig.insertByGroupIndex(2, `
test1
test2
`); +ig.insertByGroupIndex(3, [`
test1
`, `
test2
`]); +ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]); +``` + +### getStatus {#getStatus} + +
+ inherited +
+ +

Returns the current state of a module such as location information. You can use the setStatus() method to restore the information returned through a call to this method.

+ +**Returns**: [InfiniteGridStatus](InfiniteGridStatus) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|STATUS_TYPE|✔️||

STATUS_TYPE.NOT_REMOVE = Get all information about items. STATUS_TYPE.REMOVE_INVISIBLE_ITEMS = Get information on visible items only. STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS = Compress invisible items. You can replace it with a placeholder. STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS = Compress invisible groups.

| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### setPlaceholder {#setPlaceholder} + +
+ inherited +
+ +

You can set placeholders to restore status or wait for items to be added.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||

The placeholder status.

| + +### setLoading {#setLoading} + +
+ inherited +
+ +

You can set placeholders to restore status or wait for items to be added.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|info|Partial<InfiniteGridItemStatus> \| null|||

The placeholder status.

| + +### appendPlaceholders {#appendPlaceholders} + +
+ inherited +
+ +

Add the placeholder at the end.

+ +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||

Items that correspond to placeholders. If it is a number, it duplicates the number of copies.

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +### prependPlaceholders {#prependPlaceholders} + +
+ inherited +
+ +

Add the placeholder at the start.

+ +**Returns**: [InsertedPlaceholdersResult](InsertedPlaceholdersResult) + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|number \| InfiniteGridItemStatus[]|||

Items that correspond to placeholders. If it is a number, it duplicates the number of copies.

| +|groupKey|string \| number|✔️||

The group key to be configured in items. It is automatically generated by default.

| + +### removePlaceholders {#removePlaceholders} + +
+ inherited +
+ +

Remove placeholders

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|type|"start" \| "end" \| {groupKey: string \| number}|||

Remove the placeholders corresponding to the groupkey. When "start" or "end", remove all placeholders in that direction.

| + +### setStatus {#setStatus} + +
+ inherited +
+ +

Sets the status of the InfiniteGrid module with the information returned through a call to the getStatus() method.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|status|[InfiniteGridStatus](InfiniteGridStatus)|||

status object of the InfiniteGrid module.

| +|useFirstRender|boolean|✔️||

Whether the first rendering has already been done.

| + +### removeGroupByIndex {#removeGroupByIndex} + +
+ inherited +
+ +

Removes the group corresponding to index.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeGroupByKey {#removeGroupByKey} + +
+ inherited +
+ +

Removes the group corresponding to key.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|number \| string|||| + +### removeByIndex {#removeByIndex} + +
+ inherited +
+ +

Removes the item corresponding to index.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|index|number|||| + +### removeByKey {#removeByKey} + +
+ inherited +
+ +

Removes the item corresponding to key.

+ +**Returns**: this + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|key|string \| number|||| + +### updateItems {#updateItems} + +
+ inherited +
+ +

Update the size of the items and render them.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|items|InfiniteGridItem[]|✔️||

Items to be updated.

| +|options|RenderOptions|✔️|{}|

Options for rendering.

| + +### getItems {#getItems} + +
+ inherited +
+ +

Return all items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### getVisibleItems {#getVisibleItems} + +
+ inherited +
+ +

Return visible items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include items corresponding to placeholders.

| + +### getRenderingItems {#getRenderingItems} + +
+ inherited +
+ +

Return rendering items of InfiniteGrid.

+ +**Returns**: InfiniteGridItem[] + +### getGroups {#getGroups} + +
+ inherited +
+ +

Return all groups of InfiniteGrid.

+ +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include groups corresponding to placeholders.

| + +### getVisibleGroups {#getVisibleGroups} + +
+ inherited +
+ +

Return visible groups of InfiniteGrid.

+ +**Returns**: InfiniteGridGroup[] + +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|includePlaceholders|boolean|✔️||

Whether to include groups corresponding to placeholders.

| + +### wait {#wait} + +
+ inherited +
+ +

Set to wait to request data.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|direction|"start" \| "end"|✔️|DIRECTION.END|

direction in which data will be added.

| + +### ready {#ready} + +
+ inherited +
+ +

When the data request is complete, it is set to ready state.

+ +### isWait {#isWait} + +
+ inherited +
+ +

Returns whether it is set to wait to request data.

+ +### destroy {#destroy} + +
+ inherited +
+ +

Releases the instnace and events and returns the CSS of the container and elements.

+ +**Returns**: void + +### trigger {#trigger} + +
+ inherited +
+ +

Trigger a custom event.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|event|string \| ComponentEvent|||

The name of the custom event to be triggered or an instance of the ComponentEvent

| +|params|Array<any> \| $ts:...|||

Event data to be sent when triggering a custom event

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + beforeHi: ComponentEvent<{ foo: number; bar: string }>; + hi: { foo: { a: number; b: boolean } }; + someEvent: (foo: number, bar: string) => void; + someOtherEvent: void; // When there's no event argument +}> { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } +} + +const some = new Some(); +some.on("beforeHi", e => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + + typeof e.foo; // number + typeof e.bar; // string +}); +some.on("hi", e => { + typeof e.foo.b; // boolean +}); +// If you want to more know event design. You can see article. +// https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F +``` + +### once {#once} + +
+ inherited +
+ +

Executed event just one time.

+ +**Returns**: this +-

An instance of the component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: ComponentEvent; +}> { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } +} + +var some = new Some(); +some.thing(); +some.trigger(new ComponentEvent("hi")); +// fire alert("hi"); +some.trigger(new ComponentEvent("hi")); +// Nothing happens +``` + +### hasOn {#hasOn} + +
+ inherited +
+ +

Checks whether an event has been attached to a component.

+ +**Returns**: boolean +-

Indicates whether the event is attached.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string|||

The name of the event to be attached

| + +```ts +import Component from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + some() { + this.hasOn("hi");// check hi event. + } +} +``` + +### on {#on} + +
+ inherited +
+ +

Attaches an event to a component.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|||

The name of the event to be attached or an event name - event handler mapped object.

| +|handlerToAttach|function \| $ts:...|✔️||

The handler function of the event to be attached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } +} +``` + +### off {#off} + +
+ inherited +
+ +

Detaches an event from the component.
If the eventName is not given this will detach all event handlers attached.
If the handlerToDetach is not given, this will detach all event handlers for eventName.

+ +**Returns**: this +-

An instance of a component itself

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|eventName|string \| $ts:...|✔️||

The name of the event to be detached

| +|handlerToDetach|function \| $ts:...|✔️||

The handler function of the event to be detached

| + +```ts +import Component, { ComponentEvent } from "@egjs/component"; + +class Some extends Component<{ + hi: void; +}> { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } +} +``` + +## Events +### changeScroll {#event-changeScroll} + +
+ inherited +
+ +

This event is fired when scrolling.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnChangeScroll|||

The object of data to be sent to an event

| + +### requestAppend {#event-requestAppend} + +
+ inherited +
+ +

The event is fired when scrolling reaches the end or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestAppend|||

The object of data to be sent to an event

| + +### requestPrepend {#event-requestPrepend} + +
+ inherited +
+ +

The event is fired when scrolling reaches the start or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRequestPrepend|||

The object of data to be sent to an event

| + +### contentError {#event-contentError} + +
+ inherited +
+ +

The event is fired when scrolling reaches the start or when data for a virtual group is required.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnContentError|||

The object of data to be sent to an event

| + +### renderComplete {#event-renderComplete} + +
+ inherited +
+ +

This event is fired when the InfiniteGrid has completed rendering.

+ +|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:|:---:| +|e|InfiniteGrid.OnRenderComplete|||

The object of data to be sent to an event

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/PackingInfiniteGridOptions.mdx b/packages/docs/versioned_docs/version-4.11.1/api/PackingInfiniteGridOptions.mdx new file mode 100644 index 000000000..4758f4915 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/PackingInfiniteGridOptions.mdx @@ -0,0 +1,67 @@ +--- +custom_edit_url: null +--- + +
+ +
+ +**Type**: TSInterface + +|PROPERTY|TYPE|DEFAULT|DESCRIPTION| +|:---:|:---:|:---:|:---:| +|horizontal|boolean|false|

Direction of the scroll movement. (true: horizontal, false: vertical) If horizontal is false, inlinePos is left, inlineSize is width, contentPos is top, and contentSize is height. If horizontal is true, inlinePos is top, inlineSize is height, contentPos is left, and contentSize is width.

| +|percentage|Array<"position" \| "size"> \| boolean|false|

Whether to set the css size and position of the item to %.

| +|isEqualSize|boolean|false|

Indicates whether sizes of all card elements are equal to one another. If sizes of card elements to be arranged are all equal and this option is set to "true", the performance of layout arrangement can be improved.

| +|isConstantSize|boolean|false|

Indicates whether sizes of all card elements does not change, the performance of layout arrangement can be improved.

| +|gap|number|5|

Gap used to create space around items.

| +|attributePrefix|string|"data-grid-"|

The prefix to use element's data attribute.

| +|resizeDebounce|number|100|

Debounce time to set in the resize event. (unit: ms)

| +|maxResizeDebounce|number|0|

Maximum time to debounce the resize event. (0 is not set)

| +|autoResize|boolean|true|

Whether the resize method should be called automatically after a window resize event.

| +|useFit|boolean|true|

Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0.

| +|useTransform|boolean|false|

Whether to use transform property instead of using left and top css properties.

| +|renderOnPropertyChange|boolean|true|

Whether to automatically render through property change.

| +|preserveUIOnDestroy|boolean|false|

Whether to preserve the UI of the existing container or item when destroying.

| +|defaultDirection|"start" \| "end"|"end"|

The default direction value when direction is not set in the render option.

| +|outlineLength|number|0|

The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid.

| +|outlineSize|number|0|

The size of the outline. If the outline size is 0, it is calculated according to the grid type.

| +|useRoundedSize|boolean|true|

Whether to get the size as rounded size(offsetWidth, offsetHeight). Set to true if transform is applied to the container. If false, get the size through getBoundingClientRect.

| +|useResizeObserver|boolean|false|

Whether to use ResizeObserver event to detect container size change when autoResize option is used.

| +|observeChildren|boolean|false|

Whether to detect size change of children if useResizeObserver option is used.

| +|externalItemRenderer|ItemRenderer \| null||

You can set the ItemRenderer directly externally.

| +|externalContainerManager|ContainerManager \| null||

You can set the ContainerManager directly externally.

| +|aspectRatio|number|1|

The aspect ratio (inlineSize / contentSize) of the container with items.

| +|sizeWeight|number|1|

The size weight when placing items.

| +|ratioWeight|number|1|

The weight to keep ratio when placing items.

| +|weightPriority|"size" \| "ratio" \| "custom"|"custom"|

The priority that determines the weight of the item. "size" = (sizeWieght: 100, ratioWeight: 1), "ratio" = (sizeWeight: 1, ratioWeight; 100), "custom" = (set sizeWeight, ratioWeight)
item's weight = item's ratio(inlineSize / contentSize) change * ratioWeight + size(inlineSize * contentSize) change * sizeWeight.

| +|horizontal|boolean|false|

Direction of the scroll movement. (true: horizontal, false: vertical) If horizontal is false, inlinePos is left, inlineSize is width, contentPos is top, and contentSize is height. If horizontal is true, inlinePos is top, inlineSize is height, contentPos is left, and contentSize is width.

| +|percentage|Array<"position" \| "size"> \| boolean|false|

Whether to set the css size and position of the item to %.

| +|isEqualSize|boolean|false|

Indicates whether sizes of all card elements are equal to one another. If sizes of card elements to be arranged are all equal and this option is set to "true", the performance of layout arrangement can be improved.

| +|isConstantSize|boolean|false|

Indicates whether sizes of all card elements does not change, the performance of layout arrangement can be improved.

| +|gap|number|5|

Gap used to create space around items.

| +|attributePrefix|string|"data-grid-"|

The prefix to use element's data attribute.

| +|resizeDebounce|number|100|

Debounce time to set in the resize event. (unit: ms)

| +|maxResizeDebounce|number|0|

Maximum time to debounce the resize event. (0 is not set)

| +|autoResize|boolean|true|

Whether the resize method should be called automatically after a window resize event.

| +|useFit|boolean|true|

Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0.

| +|useTransform|boolean|false|

Whether to use transform property instead of using left and top css properties.

| +|renderOnPropertyChange|boolean|true|

Whether to automatically render through property change.

| +|preserveUIOnDestroy|boolean|false|

Whether to preserve the UI of the existing container or item when destroying.

| +|defaultDirection|"start" \| "end"|"end"|

The default direction value when direction is not set in the render option.

| +|outlineLength|number|0|

The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid.

| +|outlineSize|number|0|

The size of the outline. If the outline size is 0, it is calculated according to the grid type.

| +|useRoundedSize|boolean|true|

Whether to get the size as rounded size(offsetWidth, offsetHeight). Set to true if transform is applied to the container. If false, get the size through getBoundingClientRect.

| +|useResizeObserver|boolean|false|

Whether to use ResizeObserver event to detect container size change when autoResize option is used.

| +|observeChildren|boolean|false|

Whether to detect size change of children if useResizeObserver option is used.

| +|externalItemRenderer|ItemRenderer \| null||

You can set the ItemRenderer directly externally.

| +|externalContainerManager|ContainerManager \| null||

You can set the ContainerManager directly externally.

| +|container|boolean \| HTMLElement \| string \| Ref<HTMLElement>|false|

The target to which the container is applied. If false, create itself, if true, create container. A string or HTMLElement specifies the target directly.

| +|containerTag|string|"div"|

If you create a container, you can set the container's tag.

| +|threshold|number|100|

The size of the scrollable area for adding the next group of items.

| +|useRecycle|boolean|true|

Whether to show only the DOM of the visible area.

| +|scrollContainer|HTMLElement \| string \| Ref<HTMLElement> \| null||

You can set the scrollContainer directly. In this case, the container becomes the wrapper itself.

| +|gridConstructor|GridFunction||

Grid class to apply Infinite function.

| +|appliedItemChecker|(item: InfiniteGridItem, grid: Grid) => boolean||

A function that checks whether non-rendering items are included in the Grid.

| +|renderer|Renderer \| null||

class that renders the DOM.

| + diff --git a/packages/docs/versioned_docs/version-4.11.1/api/withInfiniteGridMethods.mdx b/packages/docs/versioned_docs/version-4.11.1/api/withInfiniteGridMethods.mdx new file mode 100644 index 000000000..1e9ec2b08 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/api/withInfiniteGridMethods.mdx @@ -0,0 +1,23 @@ +--- +custom_edit_url: null +--- + +```ts +const withInfiniteGridMethods +``` + +
+ +
+ +

Decorator that makes the method of InfiniteGrid available in the framework.

+ +```js +import { withInfiniteGridMethods } from "@egjs/infinitegrid"; + +class Grid extends React.Component> { + @withInfiniteGridMethods + private grid: NativeGrid; +} +``` + diff --git a/packages/docs/versioned_docs/version-4.11.1/installation.mdx b/packages/docs/versioned_docs/version-4.11.1/installation.mdx new file mode 100644 index 000000000..4916e9464 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/installation.mdx @@ -0,0 +1,136 @@ +--- +title: Installation +id: installation +slug: / +custom_edit_url: null +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +## Using the package managers (recommended) +You can easily install InfiniteGrid with package managers like [npm](https://www.npmjs.com/) or [yarn](https://classic.yarnpkg.com/en/) + +### npm + + + + +```shell +npm install @egjs/infinitegrid +``` + + + + +```shell +npm install @egjs/react-infinitegrid +``` + + + + +```shell +npm install @egjs/vue-infinitegrid +``` + + + + +```shell +npm install @egjs/vue3-infinitegrid +``` + + + + +```shell +npm install @egjs/ngx-infinitegrid +``` + + + + +```shell +npm install @egjs/svelte-infinitegrid +``` + + + + +### yarn + + + +```shell +yarn add @egjs/infinitegrid +``` + + + + +```shell +yarn add @egjs/react-infinitegrid +``` + + + + +```shell +yarn add @egjs/vue-infinitegrid +``` + + + + +```shell +yarn add @egjs/vue3-infinitegrid +``` + + + + +```shell +yarn add @egjs/ngx-infinitegrid +``` + + + + +```shell +yarn add @egjs/svelte-infinitegrid +``` + + + + +## CDN Links +### packaged(with dependencies) +```html + + + + + + +``` diff --git a/packages/docs/versioned_docs/version-4.11.1/listening-to-events.mdx b/packages/docs/versioned_docs/version-4.11.1/listening-to-events.mdx new file mode 100644 index 000000000..6cdc77574 --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/listening-to-events.mdx @@ -0,0 +1,110 @@ +--- +title: Listening to Events +id: listening-to-events +slug: /listening-to-events +custom_edit_url: null +--- + +import Link from "@docusaurus/Link"; +import useBaseUrl from "@docusaurus/useBaseUrl"; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +You can listen to InfiniteGrid's events with [InfiniteGrid#on](api/InfiniteGrid#on) + +```js +// If you're using a package manager + +ig.on("requestAppend", evt => { + console.log(evt); +}); +``` + + + + +All events are prefixed with `on-`, and `camelCase`d. + +```tsx +import { MasonryInfiniteGrid } from "@egjs/react-infinitegrid"; +import { OnRequestAppend } from "@egjs/infinitegrid"; + + { + console.log(e); + }} +> + {...} + +``` + + + + +All event names are renamed to `kebab-case`, following the [Vue event naming convention](https://vuejs.org/v2/guide/components-custom-events.html#Event-Names). + +```html + + +``` + + + + +All event names are renamed to `kebab-case`, following the [Vue 2 event naming convention](https://vuejs.org/v2/guide/components-custom-events.html#Event-Names). + +```html + + +``` + + + + +You can listen events of the `ngx-infinitegrid` using Angular's [event binding](https://angular.io/guide/event-binding). +```html + + {{ ... }} + +``` + + + + +You can use `on:eventName` syntax to listen InfiniteGrid events. +All event properties are available in the event's `detail` property. + +```jsx + + + { + console.log(e); + }}> + +``` + + + + +See all available events at InfiniteGrid#events. diff --git a/packages/docs/versioned_docs/version-4.11.1/migration-from-v3.mdx b/packages/docs/versioned_docs/version-4.11.1/migration-from-v3.mdx new file mode 100644 index 000000000..07d1fc72d --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/migration-from-v3.mdx @@ -0,0 +1,199 @@ +--- +title: Migration Guide from v3 to v4 +id: migration-from-v3 +slug: /migration-from-v3 +custom_edit_url: null +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +import Link from "@docusaurus/Link"; +import useBaseUrl from "@docusaurus/useBaseUrl"; + +## Changed Usage +Double options are combined into one option. + + + + +```js +import { MasonryInfiniteGrid } from "@egjs/infinitegrid"; + +const ig = new MasonryInfiniteGrid(".container", { + attributePrefix: "data-grid-", + column: 5, +}); + +ig.renderItems(); +``` + + + + +```jsx +import { MasonryInfiniteGrid } from "@egjs/react-infinitegrid"; + + + ... + +``` + + + + +```html + + +``` + + + + +```html + + +``` + + + + +```html +
+ ... +
+``` + +
+ + +```html + + + ... + +``` + + +
+ + + +## HTML structure +- The option called `isOverflowScroll` is renamed `container`. +- If you set the `container` option to true, a container is created inside the wrapper. + - The class name of container has been changed from `_eg-infinitegrid-container_` to `infinitegrid-container` + +```html {3} + +
+
+
Item 1
+
Item 2
+
Item 3
+
+
+ +``` +```js +const ig = new InfiniteGrid(".container", { + container: true, +}); +``` + + +## Changes when using umd modules +- We've removed `eg` namespace on umd modules. + - `eg.InfiniteGrid` is now just `InfiniteGrid` + + +## Changed module names + +|From|To| +|---|---| +|GridLayout|MasonryInfiniteGrid| +|JustifiedLayout|JustifiedInfiniteGrid| +|FrameLayout|FrameInfiniteGrid| +|SquareLayout|Integration into MasonryInfiniteGrid| +|PackingLayout|PackingInfiniteGrid| + +## Changed Options +- Default value of **attributePrefix** is now `data-grid-` (was `data-`) +- The option called `margin` is renamed `gap`. +- The option called `isOverflowScroll` is renamed `container`. + +## Changed Events +- The event called `append` is renamed `requestAppend`. +- The event called `prepend` is renamed `requestPrepend`. +- The event called `layoutComplete` is renamed `renderComplete`. +- The event called `change` is renamed `changeScroll`. +- The event called `imageError` is renamed `contentError`. + +## Changed Methods +- The method called `layout` is renamed `renderItems`. +- The method `getItems(true)` can be used as `getItems()`. +- The method `getItems(false)` can be used as `getVisibleItems()`. +- The usage of the `getStatus` method has changed. + - `getStatus(STATUS_TYPE.NOT_REMOVE)`(default) gets all infos + - `getStatus(STATUS_TYPE.REMOVE_INVISIBLE_GROUPS)` gets visible infos + - `getStatus(STATUS.MINIMIZE_INVISIBLE_ITEMS)` gets visible infos. However, the information is simplified for invisible items. + - `getStatus(STATUS.MINIMIZE_INVISIBLE_GROUPS)` gets visible infos. However, invisible items are removed and only the outline remains. + +## Removed Options +- The option called `transitionDuration` is removed. + - Use CSS. See Guides +## Removed Methods +- The method called `startLoading` is removed. + - Use a method called `wait` instead. +- The method called `endLoading` is removed. + - Automatically check whether loading is ended. +- The method called `isLoading` is removed. + - Use a method called `isWait` instead. +- The method called `isProcessing` is removed. diff --git a/packages/docs/versioned_docs/version-4.11.1/quick-start.mdx b/packages/docs/versioned_docs/version-4.11.1/quick-start.mdx new file mode 100644 index 000000000..9166403bc --- /dev/null +++ b/packages/docs/versioned_docs/version-4.11.1/quick-start.mdx @@ -0,0 +1,301 @@ +--- +title: Quick Start +id: quick-start +slug: /quick-start +custom_edit_url: null +--- +If you don't want to use Infinite's features, use [`@egjs/grid`](https://github.com/naver/egjs-grid). + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + + +Add the script/CSS to the page. +```html + + +``` + +Or, you can rather import them if you're using a bundler like [webpack](https://webpack.js.org/) or [rollup](https://rollupjs.org/guide/en/). +```js +import { MasonryInfiniteGrid } from "@egjs/infinitegrid"; +``` + +Then, add some basic HTML layout of InfiniteGrid to your page. + +```html +
+
1
+
2
+
3
+
+``` +Then initialize InfiniteGrid instance with JavaScript after. + +```js +import { MasonryInfiniteGrid } from "@egjs/infinitegrid"; + +const ig = new MasonryInfiniteGrid(".wrapper", { + align: "center", + gap: 5, +}); + +ig.on("requestAppend", e => { + const nextGroupKey = (e.groupKey || 0) + 1; + const length = items.length; + + ig.append([ + `
${length}
`, + `
${length + 1}
`, + `
${length + 2}
`, + ], nextGroupKey); +}); +ig.renderItems(); +``` + +
+ + +You can import & use InfiniteGrid as a React Component. + +```jsx title="SomeComponent.jsx" +import * as React from "react"; +import { MasonryInfiniteGrid } from "@egjs/react-infinitegrid"; + +export default () => { + const [items, setItems] = React.useState([]); + + return { + const nextGroupKey = (e.groupKey || 0) + 1; + const length = items.length; + + setItems([ + ...items, + { groupKey: nextGroupKey, key: length }, + { groupKey: nextGroupKey, key: length + 1 }, + { groupKey: nextGroupKey, key: length + 2 }, + ]); + }}> + {items.map((item) => { + return
{item.key}
+ })} +
; +} +``` + +
+ +You can import & use InfiniteGrid as a Vue Component. + +```html title="