Class: MovableCoord

eg. MovableCoord

new eg.MovableCoord(options)

A module used to change the information of user action entered by various input devices such as touch screen or mouse into logical coordinates within the virtual coordinate system. The coordinate information sorted by time events occurred is provided if animations are made by user actions. You can implement a user interface by applying the logical coordinates provided. For more information on the eg.MovableCoord module, see demos.

터치 입력 장치나 마우스와 같은 다양한 입력 장치로 전달 받은 사용자의 동작을 가상 좌표계의 논리적 좌표로 변경하는 모듈. 사용자의 동작으로 애니메이션이 일어나면 시간순으로 변경되는 좌표 정보도 제공한다. 변경된 논리적 좌표를 반영해 UI를 구현할 수 있다. eg.MovableCoord 모듈의 자세한 작동 방식은 데모를 참고한다.

  • options
    Type: Object

    The option object of the eg.MovableCoord module

    eg.MovableCoord 모듈의 옵션 객체

    • min
      Type: Array

      The minimum value of X and Y coordinates

      좌표계의 최솟값

      • 0 (default: 0) optional
        Type: Number

        The X coordinate of the minimum

        최소 x좌표

      • 1 (default: 0) optional
        Type: Number

        The Y coordinate of the minimum

        최소 y좌표

    • max
      Type: Array

      The maximum value of X and Y coordinates

      좌표계의 최댓값

      • 0 (default: 100) optional
        Type: Number

        The X coordinate of the maximum

        최대 x좌표

      • 1 (default: 100) optional
        Type: Number

        The Y coordinate of the maximum

        최대 y좌표

    • bounce
      Type: Array

      The size of bouncing area. The coordinates can exceed the coordinate area as much as the bouncing area based on user action. If the coordinates does not exceed the bouncing area when an element is dragged, the coordinates where bouncing effects are applied are retuned back into the coordinate area

      바운스 영역의 크기. 사용자의 동작에 따라 좌표가 좌표 영역을 넘어 바운스 영역의 크기만큼 더 이동할 수 있다. 사용자가 끌어다 놓는 동작을 했을 때 좌표가 바운스 영역에 있으면, 바운스 효과가 적용된 좌표가 다시 좌표 영역 안으로 들어온다

      • 0 (default: 10) optional
        Type: Boolean

        The size of top area

        위쪽 바운스 영역의 크기

      • 1 (default: 10) optional
        Type: Boolean

        The size of right area

        오른쪽 바운스 영역의 크기

      • 2 (default: 10) optional
        Type: Boolean

        The size of bottom area

        아래쪽 바운스 영역의 크기

      • 3 (default: 10) optional
        Type: Boolean

        The size of left area

        왼쪽 바운스 영역의 크기

    • margin
      Type: Array

      The size of accessible space outside the coordinate area. If an element is dragged outside the coordinate area and then dropped, the coordinates of the element are returned back into the coordinate area. The size of margins that can be exceeded

      − 좌표 영역을 넘어 이동할 수 있는 바깥 영역의 크기. 사용자가 좌표를 바깥 영역까지 끌었다가 놓으면 좌표가 좌표 영역 안으로 들어온다.

      • 0 (default: 0) optional
        Type: Boolean

        The size of top margin

        위쪽 바깥 영역의 크기

      • 1 (default: 0) optional
        Type: Boolean

        The size of right margin

        오른쪽 바깥 영역의 크기

      • 2 (default: 0) optional
        Type: Boolean

        The size of bottom margin

        아래쪽 바깥 영역의 크기

      • 3 (default: 0) optional
        Type: Boolean

        The size of left margin

        왼쪽 바깥 영역의 크기

    • circular
      Type: Array

      Indicates whether a circular element is available. If it is set to "true" and an element is dragged outside the coordinate area, the element will appear on the other side.

      순환 여부. 'true'로 설정한 방향의 좌표 영역 밖으로 엘리먼트가 이동하면 반대 방향에서 엘리먼트가 나타난다

      • 0 (default: false) optional
        Type: Boolean

        Indicates whether to circulate to top

        위로 순환 여부

      • 1 (default: false) optional
        Type: Boolean

        Indicates whether to circulate to right

        오른쪽으로 순환 여부

      • 2 (default: false) optional
        Type: Boolean

        Indicates whether to circulate to bottom

        아래로 순환 여부

      • 3 (default: false) optional
        Type: Boolean

        Indicates whether to circulate to left

        왼쪽으로 순환 여부

    • easing (default: easing.easeOutCubic) optional
      Type: function

      The easing function to apply to an animation

      애니메이션에 적용할 easing 함수

    • maximumDuration (default: Infinity) optional
      Type: Number

      Maximum duration of the animation

      가속도에 의해 애니메이션이 동작할 때의 최대 좌표 이동 시간

    • deceleration (default: 0.0006) optional
      Type: Number

      Deceleration of the animation where acceleration is manually enabled by user. A higher value indicates shorter running time.

      사용자의 동작으로 가속도가 적용된 애니메이션의 감속도. 값이 높을수록 애니메이션 실행 시간이 짧아진다

See:

Codepen:

MovableCoord Cube 예제
MovableCoord Cube example

See the Pen eg.Flicking by egjs (@egjs) on CodePen.

Browser Support

Browser Version
Desktop - Internet Explorer 10+
Desktop - Chrome latest
Desktop - Firefox latest
Desktop - Safari latest
Desktop - Edge latest
iOS 7+
Andorid 2.3+ (except 3.x)

Extends

Members

static,constanteg.MovableCoord.DIRECTION_ALLNumber

static,constanteg.MovableCoord.DIRECTION_DOWNNumber

static,constanteg.MovableCoord.DIRECTION_HORIZONTALNumber

static,constanteg.MovableCoord.DIRECTION_LEFTNumber

static,constanteg.MovableCoord.DIRECTION_NONENumber

static,constanteg.MovableCoord.DIRECTION_RIGHTNumber

static,constanteg.MovableCoord.DIRECTION_UPNumber

static,constanteg.MovableCoord.DIRECTION_VERTICALNumber

Methods

bind(element, options){eg.MovableCoord}

Registers an element to use the eg.MovableCoord module.

eg.MovableCoord 모듈을 사용할 엘리먼트를 등록한다

  • element
    Type: HTMLElement | String | jQuery

    An element to use the eg.MovableCoord module

    − eg.MovableCoord 모듈을 사용할 엘리먼트

  • options
    Type: Object

    The option object of the bind() method

    bind() 메서드의 옵션 객체

    • direction (default: eg.MovableCoord.DIRECTION_ALL) optional
      Type: Number

      Coordinate direction that a user can move
      - eg.MovableCoord.DIRECTION_ALL: All directions available.
      - eg.MovableCoord.DIRECTION_HORIZONTAL: Horizontal direction only.
      - eg.MovableCoord.DIRECTION_VERTICAL: Vertical direction only

      사용자의 동작으로 움직일 수 있는 좌표의 방향.
      - eg.MovableCoord.DIRECTION_ALL: 모든 방향으로 움직일 수 있다.
      - eg.MovableCoord.DIRECTION_HORIZONTAL: 가로 방향으로만 움직일 수 있다.
      - eg.MovableCoord.DIRECTION_VERTICAL: 세로 방향으로만 움직일 수 있다.

    • scale
      Type: Array

      Coordinate scale that a user can move

      사용자의 동작으로 이동하는 좌표의 배율

      • 0 (default: 1) optional
        Type: Number

        X-axis scale

        x축 배율

      • 1 (default: 1) optional
        Type: Number

        Y-axis scale

        y축 배율

    • thresholdAngle (default: 45) optional
      Type: Number

      The threshold value that determines whether user action is horizontal or vertical (0~90)

      사용자의 동작이 가로 방향인지 세로 방향인지 판단하는 기준 각도(0~90)

    • interruptable (default: true) optional
      Type: Number

      Indicates whether an animation is interruptible.
      - true: It can be paused or stopped by user action or the API.
      - false: It cannot be paused or stopped by user action or the API while it is running.

      진행 중인 애니메이션 중지 가능 여부.
      - true: 사용자의 동작이나 API로 애니메이션을 중지할 수 있다.
      - false: 애니메이션이 진행 중일 때는 사용자의 동작이나 API가 적용되지 않는다

    • inputType optional
      Type: Array

      Types of input devices. (default: ["touch", "mouse"])
      - touch: Touch screen
      - mouse: Mouse

      입력 장치 종류.(기본값: ["touch", "mouse"])
      - touch: 터치 입력 장치
      - mouse: 마우스

Returns:
Type Description
eg.MovableCoord
An instance of a module itself

모듈 자신의 인스턴스

Destroys elements, properties, and events used in a module.

모듈에 사용한 엘리먼트와 속성, 이벤트를 해제한다.

disableInput(element){eg.MovableCoord}

Disables input devices

입력 장치를 사용할 수 없게 한다.

  • element optional
    Type: HTMLElement | String | jQuery

    An element from which the eg.MovableCoord module is using (if the element parameter is not present, it applies to all binded elements)<

    eg.MovableCoord 모듈을 사용하는 엘리먼트 (element 파라미터가 존재하지 않을 경우, 바인드된 모든 엘리먼트에 적용된다)

Returns:
Type Description
eg.MovableCoord
An instance of a module itself

자신의 인스턴스

enableInput(element){eg.MovableCoord}

Enables input devices

입력 장치를 사용할 수 있게 한다

  • element optional
    Type: HTMLElement | String | jQuery

    An element from which the eg.MovableCoord module is using (if the element parameter is not present, it applies to all binded elements)

    eg.MovableCoord 모듈을 사용하는 엘리먼트 (element 파라미터가 존재하지 않을 경우, 바인드된 모든 엘리먼트에 적용된다)

Returns:
Type Description
eg.MovableCoord
An instance of a module itself

자신의 인스턴스

get(){Array}

Returns the current position of the logical coordinates.

논리적 좌표의 현재 위치를 반환한다

Returns:
Name Type Description
pos Array

좌표

Name Type Description
0 Number
The X coordinate

x 좌표

1 Number
The Y coordinate

y 좌표

getHammer(element){Hammer|null}

get a hammer instance from elements using the eg.MovableCoord module.

eg.MovableCoord 모듈을 사용하는 엘리먼트에서 hammer 객체를 얻는다

  • element
    Type: HTMLElement | String | jQuery

    An element from which the eg.MovableCoord module is using

    eg.MovableCoord 모듈을 사용하는 엘리먼트

Returns:
Type Description
Hammer | null
An instance of Hammer.JS

Hammer.JS의 인스턴스

inherited hasOn(eventName){Boolean}

Checks whether an event has been attached to a component.

컴포넌트에 이벤트가 등록됐는지 확인한다.

  • eventName
    Type: String

    The name of the event to be attached

    등록 여부를 확인할 이벤트의 이름

Returns:
Type Description
Boolean
Indicates whether the event is attached.

이벤트 등록 여부

Example
        var Some = eg.Class.extend(eg.Component,{
            "some": function(){
                this.hasOn("hi");// check hi event.
            }
        });

inherited off(eventName, handlerToDetach){eg.Component}

Detaches an event from the component.

컴포넌트에 등록된 이벤트를 해제한다

  • eventName
    Type: eventName

    The name of the event to be detached

    해제할 이벤트의 이름

  • handlerToDetach
    Type: function

    The handler function of the event to be detached

    해제할 이벤트의 핸들러 함수

Returns:
Type Description
eg.Component
An instance of a component itself

컴포넌트 자신의 인스턴스

Example
        var Some = eg.Class.extend(eg.Component,{
            "hi": function(){},
            "some": function(){
                this.off("hi",this.hi); //detach event
            }
        });

inherited on(eventName, handlerToAttach){eg.Component}

Attaches an event to a component.

컴포넌트에 이벤트를 등록한다.

  • eventName
    Type: eventName

    The name of the event to be attached

    등록할 이벤트의 이름

  • handlerToAttach
    Type: function

    The handler function of the event to be attached

    등록할 이벤트의 핸들러 함수

Returns:
Type Description
eg.Component
An instance of a component itself

컴포넌트 자신의 인스턴스

Example
        var Some = eg.Class.extend(eg.Component,{
            "hi": function(){},
            "some": function(){
                this.on("hi",this.hi); //attach event
            }
        });

inherited once(eventName, handlerToAttach){eg.Component}

Executed event just one time.

이벤트가 한번만 실행된다.

  • eventName
    Type: eventName

    The name of the event to be attached

    등록할 이벤트의 이름

  • handlerToAttach
    Type: function

    The handler function of the event to be attached

    등록할 이벤트의 핸들러 함수

Returns:
Type Description
eg.Component
An instance of a component itself

컴포넌트 자신의 인스턴스

Example
        var Some = eg.Class.extend(eg.Component,{
            "hi": function(){
                alert("hi");
            },
            "thing": function(){
                this.once("hi",this.hi);
            }
        });

        var some = new Some();
        some.thing();
        some.trigger("hi");
        // fire alert("hi");
        some.trigger("hi");
        // Nothing happens

inherited option(key, value){eg.Component|Object}

Sets options in a component or returns them.

컴포넌트에 옵션을 설정하거나 옵션을 반환한다

  • key
    Type: String

    The key of the option

    옵션의 키

  • value optional
    Type: Object

    The option value that corresponds to a given key

    키에 해당하는 옵션값

Returns:
Type Description
eg.Component | Object
An instance, an option value, or an option object of a component itself.
- If both key and value are used to set an option, it returns an instance of a component itself.
- If only a key is specified for the parameter, it returns the option value corresponding to a given key.
- If nothing is specified, it returns an option object.

컴포넌트 자신의 인스턴스나 옵션값, 옵션 객체.
- 키와 값으로 옵션을 설정하면 컴포넌트 자신의 인스턴스를 반환한다.
- 파라미터에 키만 설정하면 키에 해당하는 옵션값을 반환한다.
- 파라미터에 아무것도 설정하지 않으면 옵션 객체를 반환한다.

Example
        var Some = eg.Class.extend(eg.Component, {
            construct: function(options){
                this.options = options; // You have to set this.options.
            }
        });

        var some = new Some({
            "foo": 1,
            "bar": 2,
        });
        some.option("foo"); // return 1
        some.option("foo",3); // return some instance
        some.option(); // return options object.
        some.option({
            "foo" : 10,
            "bar" : 20,
            "baz" : 30
        }); // return some instance.

setBy(x, y, duration){eg.MovableCoord}

Moves an element from the current coordinates to specific coordinates. The change event is fired when the method is executed.

현재 좌표를 기준으로 좌표를 이동한다. 메서드가 실행되면 change 이벤트가 발생한다

  • x
    Type: Number

    The X coordinate to move to

    이동할 x좌표

  • y
    Type: Number

    The Y coordinate to move to

    이동할 y좌표

  • duration (default: 0) optional
    Type: Number

    Duration of the animation (unit: ms)

    애니메이션 진행 시간(단위: ms)

Returns:
Type Description
eg.MovableCoord
An instance of a module itself

자신의 인스턴스

setTo(x, y, duration){eg.MovableCoord}

Moves an element to specific coordinates.

좌표를 이동한다.

  • x
    Type: Number

    The X coordinate to move to

    이동할 x좌표

  • y
    Type: Number

    The Y coordinate to move to

    이동할 y좌표

  • duration (default: 0) optional
    Type: Number

    Duration of the animation (unit: ms)

    애니메이션 진행 시간(단위: ms)

Returns:
Type Description
eg.MovableCoord
An instance of a module itself

자신의 인스턴스

inherited trigger(eventName, customEvent){Boolean}

Triggers a custom event.

커스텀 이벤트를 발생시킨다

  • eventName
    Type: String

    The name of the custom event to be triggered

    발생할 커스텀 이벤트의 이름

  • customEvent
    Type: Object

    Event data to be sent when triggering a custom event

    커스텀 이벤트가 발생할 때 전달할 데이터

Returns:
Type Description
Boolean
Indicates whether the event has occurred. If the stop() method is called by a custom event handler, it will return false and prevent the event from occurring.

이벤트 발생 여부. 커스텀 이벤트 핸들러에서 stop() 메서드를 호출하면 'false'를 반환하고 이벤트 발생을 중단한다.

Example
        var Some = eg.Class.extend(eg.Component,{
            "some": function(){
                this.trigger("hi");// fire hi event.
            }
        });

Detaches an element using the eg.MovableCoord module.

eg.MovableCoord 모듈을 사용하는 엘리먼트를 해제한다

  • element
    Type: HTMLElement | String | jQuery

    An element from which the eg.MovableCoord module is detached

    eg.MovableCoord 모듈을 해제할 엘리먼트

Returns:
Type Description
eg.MovableCoord
An instance of a module itself

모듈 자신의 인스턴스

Events

animationEnd

This event is fired when animation ends.

에니메이션이 끝났을 때 발생한다.

This event is fired when coordinate changes.

좌표가 변경됐을 때 발생하는 이벤트

  • param
    Type: Object

    The object of data to be sent when the event is fired

    이벤트가 발생할 때 전달되는 데이터 객체

    • pos
      Type: Array

      departure coordinate

      좌표

      • 0
        Type: Number

        The X coordinate

        x 좌표

      • 1
        Type: Number

        The Y coordinate

        y 좌표

    • holding
      Type: Boolean

      Indicates whether a user holds an element on the screen of the device.

      사용자가 기기의 화면을 누르고 있는지 여부

    • hammerEvent
      Type: Object

      The event information of Hammer.JS. It returns null if the event is fired through a call to the setTo() or setBy() method.

      Hammer.JS의 이벤트 정보. setTo() 메서드나 setBy() 메서드를 호출해 이벤트가 발생했을 때는 'null'을 반환한다.

This event is fired when a user holds an element on the screen of the device.

사용자가 기기의 화면에 손을 대고 있을 때 발생하는 이벤트

  • param
    Type: Object

    The object of data to be sent when the event is fired

    이벤트가 발생할 때 전달되는 데이터 객체

    • pos
      Type: Array

      coordinate

      좌표 정보

      • 0
        Type: Number

        The X coordinate

        x 좌표

      • 1
        Type: Number

        The Y coordinate

        y 좌표

    • hammerEvent
      Type: Object

      The event information of Hammer.JS. It returns null if the event is fired through a call to the setTo() or setBy() method.

      Hammer.JS의 이벤트 정보. setTo() 메서드나 setBy() 메서드를 호출해 이벤트가 발생했을 때는 'null'을 반환한다.

This event is fired when a user release an element on the screen of the device.

사용자가 기기의 화면에서 손을 뗐을 때 발생하는 이벤트

  • param
    Type: Object

    The object of data to be sent when the event is fired

    이벤트가 발생할 때 전달되는 데이터 객체

    • depaPos
      Type: Array

      The coordinates when releasing an element

      손을 뗐을 때의 좌표현재

      • 0
        Type: Number

        The X coordinate

        x 좌표

      • 1
        Type: Number

        The Y coordinate

        y 좌표

    • destPos
      Type: Array

      The coordinates to move to after releasing an element

      손을 뗀 뒤에 이동할 좌표

      • 0
        Type: Number

        The X coordinate

        x 좌표

      • 1
        Type: Number

        The Y coordinate

        y 좌표

    • hammerEvent
      Type: Object

      The event information of Hammer.JS. It returns null if the event is fired through a call to the setTo() or setBy() method.

      Hammer.JS의 이벤트 정보. setTo() 메서드나 setBy() 메서드를 호출해 이벤트가 발생했을 때는 'null'을 반환한다

comments powered by Disqus