API Docs for:
Show:

Component_Draggable Class

Module: gs

Makes a game object draggable using mouse/touch. The dragging can be vertical, horizontal or both. It can be configured as pixel-wise or step-wise dragging. For example: To create a slider for UI with fixed steps, step-wise is useful while a pixel-wise dragging could be used for a volume-slider.

Methods

dispose

()

Disposes the component.

onDataBundleRestore.

(
  • Object
  • gs.ObjectCodecContext
)

Called if this object instance is restored from a data-bundle. It can be used re-assign event-handler, anonymous functions, etc.

Parameters:

  • Object Object

    data - The data-bundle

  • gs.ObjectCodecContext Object

    context - The codec-context.

setup

()

Initializes the component. Adds event-handler for mouse/touch events to update the component only if a user-action happened.

setupEventHandlers

()

Adds event-handler for mouse/touch events to update the component only if a user-action happened.

update

()

Updates the dragging-logic.

updateAxisX

() protected

Updates the dragging-process on x-axis if configured.

updateAxisY

() protected

Updates the dragging-process on y-axis if configured.

updateDragging

() protected

Calculates the size of a single step if steps are configured for this component. Otherwise the step-size 1-pixel.

updateDragging

() protected

Updates the game object's dragging-state and fires a dragged-event if necessary.

Properties

mx

Number

Mouse/Pointer x coordinate

my

Number

Mouse/Pointer y coordinate

rect

gs.Rect

Drag Area

stepSize

gs.Point

Stepping in pixels.