Skip to main content
Version: 4.0.0

SnapControl

class SnapControl extends Control

A Control that uses a release momentum to choose destination panel

Properties

controller

readonlyinherited

A controller that handles the @egjs/axes events

Type: AxesController

activeIndex

readonlyinherited

Index number of the currentPanel

Type: number

Default: 0

activePanel

readonlyinherited

An active panel

Type: Panel | null

animating

readonlyinherited

Whether Flicking's animating

Type: boolean

holding

readonlyinherited

Whether user is clicking or touching

Type: boolean

Methods

moveToPosition

async

Move Camera to the given position

Returns: Promise<void>

  • A Promise which will be resolved after reaching the target position

Emits: Flicking#event:moveStart, Flicking#event:move, Flicking#event:moveEnd, Flicking#event:willChange, Flicking#event:changed, Flicking#event:willRestore, Flicking#event:restored, Flicking#event:needPanel, Flicking#event:visibleChange, Flicking#event:reachEdge

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
positionnumbernoThe target position to move
durationnumbernoDuration of the panel movement animation (unit: ms).
axesEventobjectyesrelease event of Axes

Throws: FlickingError

codecondition
POSITION_NOT_REACHABLEWhen the given panel is already removed or not in the Camera's range
NOT_ATTACHED_TO_FLICKINGWhen init is not called before
ANIMATION_INTERRUPTEDWhen the animation is interrupted by user input
STOP_CALLED_BY_USERWhen the animation is interrupted by user input

init

inherited

Initialize Control

Returns: this

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
flickingFlickingnoAn instance of Flicking

destroy

inherited

Destroy Control and return to initial state

Returns: void

enable

inherited

Enable input from the user (mouse/touch)

Returns: this

disable

inherited

Disable input from the user (mouse/touch)

Returns: this

updatePosition

inheritedasync

Update position after resizing

Returns: Promise<void>

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
progressInPanelnumbernoPrevious camera's progress in active panel before resize

Throws: FlickingError

NOT_ATTACHED_TO_FLICKING When init is not called before

updateInput

inherited

Update controller's state

Returns: this

resetActive

inherited

Reset activePanel and activeAnchor to null

Returns: this

moveToPanel

inheritedasync

Move Camera to the given panel

Returns: Promise<void>

  • A Promise which will be resolved after reaching the target panel

Emits: Flicking#event:moveStart, Flicking#event:move, Flicking#event:moveEnd, Flicking#event:willChange, Flicking#event:changed, Flicking#event:willRestore, Flicking#event:restored, Flicking#event:needPanel, Flicking#event:visibleChange, Flicking#event:reachEdge

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
panelPanelnoThe target panel to move
optionsobjectnoAn options object
durationnumbernoDuration of the animation (unit: ms)
axesEventobjectyesrelease event of Axes
directionDIRECTIONyesDIRECTION.NONEDirection to move, only available in the circular mode

Throws: FlickingError

codecondition
POSITION_NOT_REACHABLEWhen the given panel is already removed or not in the Camera's range
NOT_ATTACHED_TO_FLICKINGWhen init is not called before
ANIMATION_INTERRUPTEDWhen the animation is interrupted by user input
STOP_CALLED_BY_USERWhen the animation is interrupted by user input