@interactjs / core/Interaction / Interaction
Class: Interaction<T>
core/Interaction.Interaction
Type parameters
Name | Type |
---|---|
T | extends ActionName | null = ActionName |
Table of contents
Properties
- _reflowPromise
- _reflowResolve
- autoScroll
- autoStartHoldTimer
- coords
- doMove
- dropState
- element
- gesture
- holdIntervalHandle
- inertia
- interactable
- modification
- offset
- offsetBy
- pointerIsDown
- pointerType
- pointerWasMoved
- prepared
- prevTap
- rect
- resizeAxes
- resizeStartAspectRatio
- tapTime
Methods
Properties
_reflowPromise
• _reflowPromise: Promise
<void
>
Defined in
_reflowResolve
• _reflowResolve: (…args
: unknown
[]) => void
Type declaration
â–¸ (...args
): void
Parameters
Name | Type |
---|---|
...args | unknown [] |
Returns
void
Defined in
autoScroll
• Optional
autoScroll: Object
Type declaration
Name | Type |
---|---|
defaults | AutoScrollOptions |
i | number |
interaction | Interaction <keyof ActionMap > |
isScrolling | boolean |
margin | number |
now | () => number |
prevTime | number |
speed | number |
x | number |
y | number |
check | (interactable : Interactable , actionName : keyof ActionMap ) => boolean |
onInteractionMove | <T>(__namedParameters : { interaction : Interaction <T > ; pointer : PointerType }) => void |
scroll | () => void |
start | (interaction : Interaction <keyof ActionMap >) => void |
stop | () => void |
Defined in
autoStartHoldTimer
• Optional
autoStartHoldTimer: any
Defined in
coords
• coords: CoordsSet
Defined in
doMove
• doMove: (this
: void
) => any
Type declaration
â–¸ (this
): any
Parameters
Name | Type |
---|---|
this | void |
Returns
any
Defined in
dropState
• Optional
dropState: DropState
Defined in
element
• element: Element
= null
the target element of the interactable
Defined in
gesture
• Optional
gesture: Object
Type declaration
Name | Type |
---|---|
angle | number |
distance | number |
scale | number |
startAngle | number |
startDistance | number |
Defined in
holdIntervalHandle
• Optional
holdIntervalHandle: any
Defined in
pointer-events/holdRepeat.ts:12
inertia
• Optional
inertia: InertiaState
Defined in
interactable
• interactable: Interactable
= null
current interactable being interacted with
Defined in
modification
• Optional
modification: Modification
Defined in
offset
• offset: Object
Type declaration
Name | Type |
---|---|
pending | Point |
total | Point |
Defined in
offsetBy
• Optional
offsetBy: (this
: Interaction
<keyof ActionMap
>, __namedParameters
: Point
) => void
Type declaration
â–¸ (this
, «destructured»
): void
Parameters
Name | Type |
---|---|
this | Interaction <keyof ActionMap > |
«destructured» | Point |
Returns
void
Defined in
pointerIsDown
• pointerIsDown: boolean
= false
Defined in
pointerType
• pointerType: string
Defined in
pointerWasMoved
• pointerWasMoved: boolean
= false
Defined in
prepared
• prepared: ActionProps
<T
>
Defined in
prevTap
• Optional
prevTap: PointerEvent
<string
>
Defined in
rect
• rect: Required
<Rect
> = null
Defined in
resizeAxes
• resizeAxes: "x"
| "y"
| "xy"
Defined in
resizeStartAspectRatio
• resizeStartAspectRatio: number
Defined in
tapTime
• Optional
tapTime: number
Defined in
Methods
currentAction
â–¸ currentAction(): T
Returns
T
Defined in
destroy
â–¸ destroy(): void
Returns
void
Defined in
end
â–¸ end(event?
): void
interact(target)
.draggable(true)
.on('move', function (event) {
if (event.pageX > 1000) {
// end the current action
event.interaction.end()
// stop all further listeners from being called
event.stopImmediatePropagation()
}
})
Parameters
Name | Type |
---|---|
event? | PointerEventType |
Returns
void
Defined in
interacting
â–¸ interacting(): boolean
Returns
boolean
Defined in
move
â–¸ move(signalArg?
): void
interact(target)
.draggable(true)
.on('dragmove', function (event) {
if (someCondition) {
// change the snap settings
event.interactable.draggable({ snap: { targets: [] }})
// fire another move event with re-calculated snap
event.interaction.move()
}
})
Force a move of the current action at the same coordinates. Useful if snap/restrict has been changed and you want a movement with the new settings.
Parameters
Name | Type |
---|---|
signalArg? | any |
Returns
void
Defined in
pointerDown
â–¸ pointerDown(pointer
, event
, eventTarget
): void
Parameters
Name | Type |
---|---|
pointer | PointerType |
event | PointerEventType |
eventTarget | Node |
Returns
void
Defined in
pointerMove
â–¸ pointerMove(pointer
, event
, eventTarget
): void
Parameters
Name | Type |
---|---|
pointer | PointerType |
event | PointerEventType |
eventTarget | Node |
Returns
void
Defined in
start
â–¸ start<A
>(action
, interactable
, element
): boolean
interact(target)
.draggable({
// disable the default drag start by down->move
manualStart: true
})
// start dragging after the user holds the pointer down
.on('hold', function (event) {
var interaction = event.interaction
if (!interaction.interacting()) {
interaction.start({ name: 'drag' },
event.interactable,
event.currentTarget)
}
})
Start an action with the given Interactable and Element as tartgets. The action must be enabled for the target Interactable and an appropriate number of pointers must be held down - 1 for drag/resize, 2 for gesture.
Use it with interactable.<action>able({ manualStart: false })
to always start actions manually
Type parameters
Name | Type |
---|---|
A | extends keyof ActionMap |
Parameters
Name | Type | Description |
---|---|---|
action | ActionProps <A > | The action to be performed - drag, resize, etc. |
interactable | Interactable | - |
element | Element | The DOM Element to target |
Returns
boolean
Whether the interaction was successfully started
Defined in
stop
â–¸ stop(): void
Returns
void
Defined in
styleCursor
â–¸ styleCursor(newValue
): Interaction
<T
>
Parameters
Name | Type |
---|---|
newValue | boolean |
Returns
Interaction
<T
>
Defined in
â–¸ styleCursor(): boolean
Returns
boolean