Skip to content

Commit

Permalink
add distance to DragEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
TahaSh committed Jun 29, 2024
1 parent 80efb01 commit 2d4c1d3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/builtin-plugins/DragEventPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EventBus, Events } from '..'
import { EventBus, Events, Utils } from '..'
import { EventPlugin } from '../core/Plugin'

import { View } from '../core/View'
Expand All @@ -17,6 +17,7 @@ export class DragEvent {
directions: Array<Direction> = []
width: number
height: number
distance: number
constructor(
public props: {
view: View
Expand All @@ -26,6 +27,7 @@ export class DragEvent {
y: number
width: number
height: number
distance: number
isDragging: boolean
target: EventTarget | null
directions: Array<Direction>
Expand All @@ -37,6 +39,7 @@ export class DragEvent {
this.y = props.y
this.width = props.width
this.height = props.height
this.distance = props.distance
this.view = props.view
this.isDragging = props.isDragging
this.target = props.target
Expand Down Expand Up @@ -144,6 +147,10 @@ export class DragEventPlugin extends EventPlugin {

const height = this._pointerY - this._initialPointer.y
const width = this._pointerX - this._initialPointer.x
const distance = Utils.distanceBetweenTwoPoints(this._initialPointer, {
x: this._pointerX,
y: this._pointerY
})

const target = this._targetPerView.get(view.id)
if (!target) return
Expand All @@ -162,6 +169,7 @@ export class DragEventPlugin extends EventPlugin {
previousY,
x,
y,
distance,
width,
height,
isDragging,
Expand Down

0 comments on commit 2d4c1d3

Please sign in to comment.