Class: Grid

Grid

new Grid(containerElement, options)

  • containerElement
    Type: HTMLElement | string

    A base element for a module

    모듈을 적용할 기준 엘리먼트

  • options (default: {}) optional
    Type: Partial<Options>

    The option object of the Grid module

    Grid 모듈의 옵션 객체

Extends

  • eg.Component

Classes

PackingGrid
MasonryGrid
JustifiedGrid
GridItem
FrameGrid

Members

defaultDirectionGrid.GridOptions["defaultDirection"]

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

render옵션에서 direction을 미설정시의 기본 방향값.

Default Value:
  • "end"
Example
import { MasonryGrid } from "@egjs/grid";

const grid = new MasonryGrid(container, {
  defaultDirection: "end",
});

grid.defaultDirection = "start";

gapGrid.GridOptions["gap"]

Gap used to create space around items.

아이템들 사이의 공간.

Default Value:
  • 0
Example
import { MasonryGrid } from "@egjs/grid";

const grid = new MasonryGrid(container, {
  gap: 0,
});

grid.gap = 5;

outlineLengthGrid.GridOptions["outlineLength"]

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

outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.

Default Value:
  • 0
Example
import { MasonryGrid } from "@egjs/grid";

const grid = new MasonryGrid(container, {
  outlineLength: 0,
  outlineSize: 0,
});

grid.outlineLength = 3;

outlineSizeGrid.GridOptions["outlineSize"]

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

outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다.

Default Value:
  • 0
Example
import { MasonryGrid } from "@egjs/grid";

const grid = new MasonryGrid(container, {
  outlineLength: 0,
  outlineSize: 0,
});

grid.outlineSize = 300;

preserveUIOnDestroyGrid.GridOptions["preserveUIOnDestroy"]

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

destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.

Default Value:
  • false
Example
import { MasonryGrid } from "@egjs/grid";

const grid = new MasonryGrid(container, {
  preserveUIOnDestroy: false,
});

grid.preserveUIOnDestroy = true;

useFitGrid.GridOptions["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)

렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다. (default: true)

Default Value:
  • true
Example
import { MasonryGrid } from "@egjs/grid";

const grid = new MasonryGrid(container, {
  useFit: true,
});

grid.useFit = false;

Methods

abstractapplyGrid(direcion, outline)

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

Grid에 맞게 아이템들의 CSS rect를 적용하고 outline을 계산한다.

  • direcion
    Type: "start" | "end"

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

    Grid를 적용할 방향. ("end": 시작에서 끝 방향, "start": 끝에서 시작 방향)

  • outline
    Type: Array.<number>

    The start outline to apply the Grid.

    Grid를 적용할 시작 outline.

destroy(Options)

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

인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다.

  • Options (default: {}) optional

    for destroy.

    destory()를 위한 옵션

getChildren(){HTMLElement[]}

Returns the children of the container element.

컨테이너 엘리먼트의 children을 반환한다.

Returns:
Type Description
HTMLElement[]

getComputedOutlineLength(items){number}

Get the length corresponding to outline.

outline에 해당하는 length를 가져온다.

  • items (default: this.items) optional
    Type: GridItem[]

    Items to get outline length.

    outline length를 구하기 위한 아이템들.

Returns:
Type Description
number

getComputedOutlineSize(items)

Get the inline size corresponding to outline.

outline에 해당하는 inline 사이즈를 구한다.

  • items (default: this.items) optional
    Type: GridItem[]

    Items to get outline size.

    outline 사이즈를 구하기 위한 아이템들.

getContainerElement(){HTMLElement}

Return Container Element.

컨테이너 엘리먼트를 반환한다.

Returns:
Type Description
HTMLElement

getContainerInlineSize(){number}

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

container의 inline 사이즈를 가져온다. (horizontal이 false면 "width", 아니면 "height")

Returns:
Type Description
number

getItems(){GridItem[]}

Return items.

아이템들을 반환한다.

Returns:
Type Description
GridItem[]

getOutlines(){GridOutlines}

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

Grid의 처음과 끝의 outline을 반환한다.

Returns:
Type Description
GridOutlines

getStatus(minimize){GridStatus}

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

아이템의 위치, 사이즈 등 현재 상태를 반환한다. 반환한 상태는 setStatus() 메서드로 복원할 수 있다.

  • minimize optional
    Type: boolean

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

    item의 status를 최소화할지 여부. (default: false)

Returns:
Type Description
GridStatus

renderItems(options)

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

grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 renderComplete 이벤트가 발생한다.

  • options (default: {}) optional

    Options for rendering.

    렌더링을 하기 위한 옵션.

Example
import { MasonryGrid } from "@egjs/grid";
const grid = new MasonryGrid();

grid.on("renderComplete", e => {
  console.log(e);
});
grid.renderItems();

setItems(items){this}

Set items.

아이템들을 설정한다.

  • items
    Type: GridItem[]

    The items to set.

    설정할 아이템들

Returns:
Type Description
this

setOutlines(outlines)

Set outlines.

아웃라인을 설정한다.

  • outlines

    The outlines to set.

    설정할 아웃라인.

setStatus(status)

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

getStatus() 메서드에 대한 호출을 통해 반환된 상태로 Grid 모듈의 상태를 설정한다.

syncElements(options)

When elements change, it synchronizes and renders items.

elements가 바뀐 경우 동기화를 하고 렌더링을 한다.

  • options (default: {}) optional

    Options for rendering.

    렌더링을 하기 위한 옵션.

updateItems(items, options)

Update the size of the items and render them.

아이템들의 사이즈를 업데이트하고 렌더링을 한다.

  • items (default: this.items) optional
    Type: GridItem[]

    Items to be updated.

    업데이트할 아이템들.

  • options (default: {}) optional

    Options for rendering.

    렌더링을 하기 위한 옵션.

Type Definitions

Grid.DestroyOptionsTSInterface

Properties:
Name Type Argument Description
preserveUI boolean <optional>

Whether to preserve the current UI.

현재의 UI를 보존할지 여부.

Grid.DOMRectTSInterface

Properties:
Name Type Argument Description
width number <optional>
height number <optional>
top number <optional>
left number <optional>

Grid.GridAlign/users/user/desktop/naver/egjs-grid/src/types.ts">"start" | "center" | "end" | "justify" | "stretch"

Grid.GridOptionsTSInterface

Properties:
Name Type Argument Default Description
horizontal boolean <optional>
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.

스크롤 이동 방향. (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 <optional>
false

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

item의 css size와 position를 %로 설정할지 여부.

isEqualSize boolean <optional>
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.

카드 엘리먼트의 크기가 동일한지 여부. 배치될 카드 엘리먼트의 크기가 모두 동일할 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.

isConstantSize boolean <optional>
false

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

모든 카드 엘리먼트의 크기가 불변일 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다.

gap number <optional>
5

Gap used to create space around items.

아이템들 사이의 공간.

attributePrefix string <optional>
"data-grid-"

The prefix to use element's data attribute.

엘리먼트의 데이타 속성에 사용할 접두사.

resizeDebounce number <optional>
100

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

리사이즈 이벤트에 설정할 디바운스 시간.(단위: ms)

maxResizeDebounce number <optional>
0

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

리사이즈 이벤트를 디바운스할 수 있는 최대 시간. (0은 미설정이다)

autoResize boolean <optional>
true

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

window의 resize 이벤트 이후 자동으로 resize()메소드를 호출할지의 여부.

useFit boolean <optional>
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.

렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다.

useTransform boolean <optional>
false

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

left, top css 속성 쓰는 대신 transform 속성을 사용할지 여부.

renderOnPropertyChange boolean <optional>
true

Whether to automatically render through property change.

property의 변화를 통해 자동으로 render를 할지 여부.

preserveUIOnDestroy boolean <optional>
false

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

destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.

defaultDirection "start" | "end" <optional>
"end"

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

render옵션에서 direction을 미설정시의 기본 방향값.

outlineLength number <optional>
0

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

outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.

outlineSize number <optional>
0

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

outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다.

useRoundedSize boolean <optional>
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.

사이즈를 반올림된 사이즈(offsetWidth, offsetHeight)로 가져올지 여부. container에 transform이 적용되어 있다면 true로 설정해라. false면 getBoundingClientRect를 통해 사이즈를 가져온다.

useResizeObserver boolean <optional>
false

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

autoResize 옵션 사용시 container의 사이즈 변화 감지를 위해 ResizeObserver 이벤트를 사용할지 여부.

observeChildren boolean <optional>
false

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

useResizeObserver옵션을 사용한다면 children의 사이즈 변화 감지 여부.

externalItemRenderer ItemRenderer | null <optional>

You can set the ItemRenderer directly externally.

외부에서 직접 ItemRenderer를 설정할 수 있다.

externalContainerManager ContainerManager | null <optional>

You can set the ContainerManager directly externally.

외부에서 직접 ContainerManager를 설정할 수 있다.

Grid.GridOutlinesTSInterface

Properties:
Name Type Description
start number[]
end number[]

Grid.GridRectTSInterface

Properties:
Name Type Argument Description
inlinePos number <optional>

The pos in inline direction. "left" if horizontal is false, "top" otherwise.

inline 방향의 위치. horizontal이 false면 "left", 아니면 "top".

contentPos number <optional>

The pos in content direction. "top" if horizontal is false, "left" otherwise.

content 방향의 위치. horizontal이 false면 "top", 아니면 "left".

inlineSize number <optional>

The size in inline direction. "width" if horizontal is false, "height" otherwise.

inline 방향의 사이즈. horizontal이 false면 "width", 아니면 "height".

contentSize number <optional>

The size in content direction. "heighht" if horizontal is false, "width" otherwise.

content 방향의 사이즈. horizontal이 false면 "height", 아니면 "width".

Grid.GridStatusTSInterface

Properties:
Name Type Description
items GridItemStatus[]
outlines GridOutlines
containerManager ContainerManagerStatus
itemRenderer ItemRendererStatus

Grid.MasonryGridVerticalAlign/users/user/desktop/naver/egjs-grid/src/types.ts">"masonry" | "start"

Grid.OnContentErrorTSInterface

Properties:
Name Type Description
element HTMLElement

The item's element.

아이템의 엘리먼트.

target HTMLElement

The content element with error.

에러난 발생한 콘텐츠 엘리먼트.

item GridItem

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.

에러를 해결했고 재검사하고 싶으면 update()를 호출해라. 만약 엘리먼트를 삭제한 경우 syncElements() 메서드를 호출해라.

Grid.OnRenderCompleteTSInterface

Properties:
Name Type Description
direction "start" | "end"

The direction the grid was rendered.

Grid가 렌더링된 방향.

isResize boolean

The items rendered for the first time.

처음 렌더링한 아이템들,

mounted GridItem[]

The items updated in size.

사이즈 업데이트한 아이템들.

updated GridItem[]

Whether rendering was done using the resize event or the useResize option.

resize 이벤트 또는 useResize 옵션을 사용하여 렌더링를 했는지 여부.

Grid.RenderOptionsTSInterface

Properties:
Name Type Argument Description
outline number[] <optional>

Array of outline points to be reference points.

기준점이 되는 아웃라인 점들의 배열

direction "start" | "end" <optional>

The direction to render the grid.

Grid를 렌더링할 방향.

useResize boolean <optional>

Whether to resize containers and items.

컨테이너와 아이템들을 리사이즈할지 여부.

useOrgResize boolean <optional>

Whether to resize items to their original size.

아이템들의 원본 사이즈까지 리사이즈할지 여부.

Grid.SizeRectTSInterface

Properties:
Name Type Description
width number
height number

Events

contentError

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

콘텐츠 로드에 에러가 날 때 발생하는 이벤트.

  • e

    The object of data to be sent to an event

    이벤트에 전달되는 데이터 객체

Example
grid.on("contentError", e => {
  e.update();
});

renderComplete

This event is fired when the Grid has completed rendering.

Grid가 렌더링이 완료됐을 때 발생하는 이벤트이다.

  • e

    The object of data to be sent to an event

    이벤트에 전달되는 데이터 객체

Example
grid.on("renderComplete", e => {
  console.log(e.mounted, e.updated, e.useResize);
});
comments powered by Disqus