Skip to content

Commit

Permalink
feat(core/interactable): add options.getRect
Browse files Browse the repository at this point in the history
  • Loading branch information
taye committed Nov 24, 2023
1 parent 539223f commit 88943e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/@interactjs/core/Interactable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,11 @@ export class Interactable implements Partial<Eventable> {
}

for (const setting in options) {
if (setting === 'getRect') {
this.rectChecker(options.getRect)
continue
}

if (is.func((this as any)[setting])) {
;(this as any)[setting](options[setting as keyof typeof options])
}
Expand Down
3 changes: 2 additions & 1 deletion packages/@interactjs/core/options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Point, Listeners, OrBoolean, Element } from '@interactjs/core/types'
import type { Point, Listeners, OrBoolean, Element, Rect } from '@interactjs/core/types'

export interface Defaults {
base: BaseDefaults
Expand All @@ -13,6 +13,7 @@ export interface BaseDefaults {
preventDefault?: 'auto' | 'never' | string
deltaSource?: 'page' | 'client'
context?: Node
getRect?: (element: Element) => Rect
}

export interface PerActionDefaults {
Expand Down

0 comments on commit 88943e3

Please sign in to comment.