From 88943e3f28aaad8886448a8cde7c74854c2cd784 Mon Sep 17 00:00:00 2001 From: Taye Adeyemi Date: Sun, 19 Nov 2023 14:41:48 +0100 Subject: [PATCH] feat(core/interactable): add options.getRect --- packages/@interactjs/core/Interactable.ts | 5 +++++ packages/@interactjs/core/options.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/@interactjs/core/Interactable.ts b/packages/@interactjs/core/Interactable.ts index dd23b1d32..f9ad5168b 100644 --- a/packages/@interactjs/core/Interactable.ts +++ b/packages/@interactjs/core/Interactable.ts @@ -436,6 +436,11 @@ export class Interactable implements Partial { } 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]) } diff --git a/packages/@interactjs/core/options.ts b/packages/@interactjs/core/options.ts index 37828f4f9..987ae06e0 100644 --- a/packages/@interactjs/core/options.ts +++ b/packages/@interactjs/core/options.ts @@ -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 @@ -13,6 +13,7 @@ export interface BaseDefaults { preventDefault?: 'auto' | 'never' | string deltaSource?: 'page' | 'client' context?: Node + getRect?: (element: Element) => Rect } export interface PerActionDefaults {