@leafer-ui/interaction 1.0.0-rc.23 → 1.0.0-rc.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -6
- package/src/Interaction.ts +11 -6
- package/types/index.d.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/interaction",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.24",
|
|
4
4
|
"description": "@leafer-ui/interaction",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.0.0-rc.
|
|
26
|
-
"@leafer-ui/draw": "1.0.0-rc.
|
|
27
|
-
"@leafer-ui/event": "1.0.0-rc.
|
|
25
|
+
"@leafer/core": "1.0.0-rc.24",
|
|
26
|
+
"@leafer-ui/draw": "1.0.0-rc.24",
|
|
27
|
+
"@leafer-ui/event": "1.0.0-rc.24"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@leafer/interface": "1.0.0-rc.
|
|
31
|
-
"@leafer-ui/interface": "1.0.0-rc.
|
|
30
|
+
"@leafer/interface": "1.0.0-rc.24",
|
|
31
|
+
"@leafer-ui/interface": "1.0.0-rc.24"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/Interaction.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IUIEvent, IPointerEvent, ILeaf, IInteraction, IInteractionConfig, ILeafList, IMoveEvent, IZoomEvent, IRotateEvent, ISelector, IBounds, IEventListenerId, IInteractionCanvas, ITimer, IKeepTouchData, IKeyEvent, IPickOptions, ICursorType, IBooleanMap, IPickBottom } from '@leafer/interface'
|
|
1
|
+
import { IUIEvent, IPointerEvent, ILeaf, IInteraction, IInteractionConfig, ILeafList, IMoveEvent, IZoomEvent, IRotateEvent, ISelector, IBounds, IEventListenerId, IInteractionCanvas, ITimer, IKeepTouchData, IKeyEvent, IPickOptions, ICursorType, IBooleanMap, IPickBottom, IClientPointData, IPointData } from '@leafer/interface'
|
|
2
2
|
import { LeaferEvent, ResizeEvent, LeafList, Bounds, PointHelper, DataHelper } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { IApp } from '@leafer-ui/interface'
|
|
@@ -309,8 +309,8 @@ export class InteractionBase implements IInteraction {
|
|
|
309
309
|
protected tap(data: IPointerEvent): void {
|
|
310
310
|
const { pointer } = this.config
|
|
311
311
|
|
|
312
|
-
const
|
|
313
|
-
if (!pointer.tapMore &&
|
|
312
|
+
const hasLong = this.longTap(data)
|
|
313
|
+
if (!pointer.tapMore && hasLong) return // long_press / long_tap
|
|
314
314
|
|
|
315
315
|
if (!this.waitTap) return
|
|
316
316
|
if (pointer.tapMore) this.emitTap(data)
|
|
@@ -446,6 +446,11 @@ export class InteractionBase implements IInteraction {
|
|
|
446
446
|
this.cursor = cursor
|
|
447
447
|
}
|
|
448
448
|
|
|
449
|
+
public getLocal(clientPoint: IClientPointData, updateClient?: boolean): IPointData {
|
|
450
|
+
const clientBounds = this.canvas.getClientBounds(updateClient)
|
|
451
|
+
return { x: clientPoint.clientX - clientBounds.x, y: clientPoint.clientY - clientBounds.y }
|
|
452
|
+
}
|
|
453
|
+
|
|
449
454
|
|
|
450
455
|
protected emitTap(data: IPointerEvent) {
|
|
451
456
|
this.emit(PointerEvent.TAP, data)
|
|
@@ -482,13 +487,13 @@ export class InteractionBase implements IInteraction {
|
|
|
482
487
|
}
|
|
483
488
|
|
|
484
489
|
protected longTap(data: IPointerEvent): boolean {
|
|
485
|
-
let
|
|
490
|
+
let hasLong
|
|
486
491
|
if (this.longPressed) {
|
|
487
492
|
this.emit(PointerEvent.LONG_TAP, data)
|
|
488
|
-
if (pathHasEventType(data.path, PointerEvent.LONG_TAP))
|
|
493
|
+
if (pathHasEventType(data.path, PointerEvent.LONG_TAP) || pathHasEventType(data.path, PointerEvent.LONG_PRESS)) hasLong = true
|
|
489
494
|
}
|
|
490
495
|
this.longPressWaitCancel()
|
|
491
|
-
return
|
|
496
|
+
return hasLong
|
|
492
497
|
}
|
|
493
498
|
|
|
494
499
|
protected longPressWaitCancel(): void {
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMoveEvent, IZoomEvent, IRotateEvent, ITimer, IDragEvent, IPointerEvent, ILeafList, IPointDataMap, IFunction, ILeaf, IInteraction, IInteractionCanvas, ISelector, IInteractionConfig, ICursorType, IPickBottom, IBounds, IEventListenerId, IBooleanMap, IUIEvent, IKeepTouchData, IKeyEvent, IPickOptions, IPointData, IEvent, IObject, IDropEvent, ISwipeEvent, IMultiTouchData, ICursorTypeMap, IHitCanvasManager, ILeaferCanvasConfig, IHitCanvas } from '@leafer/interface';
|
|
1
|
+
import { IMoveEvent, IZoomEvent, IRotateEvent, ITimer, IDragEvent, IPointerEvent, ILeafList, IPointDataMap, IFunction, ILeaf, IInteraction, IInteractionCanvas, ISelector, IInteractionConfig, ICursorType, IPickBottom, IBounds, IEventListenerId, IBooleanMap, IUIEvent, IKeepTouchData, IKeyEvent, IPickOptions, IClientPointData, IPointData, IEvent, IObject, IDropEvent, ISwipeEvent, IMultiTouchData, ICursorTypeMap, IHitCanvasManager, ILeaferCanvasConfig, IHitCanvas } from '@leafer/interface';
|
|
2
2
|
import { LeafList, CanvasManager } from '@leafer/core';
|
|
3
3
|
|
|
4
4
|
declare class Transformer {
|
|
@@ -128,6 +128,7 @@ declare class InteractionBase implements IInteraction {
|
|
|
128
128
|
updateHoverData(data?: IPointerEvent): void;
|
|
129
129
|
updateCursor(data?: IPointerEvent): void;
|
|
130
130
|
setCursor(cursor: ICursorType | ICursorType[]): void;
|
|
131
|
+
getLocal(clientPoint: IClientPointData, updateClient?: boolean): IPointData;
|
|
131
132
|
protected emitTap(data: IPointerEvent): void;
|
|
132
133
|
protected emitDoubleTap(data: IPointerEvent): void;
|
|
133
134
|
pointerWaitCancel(): void;
|