import { OnDrag } from "@daybrush/drag" ; export function measureSpeed ( e ) { const { deltaX , deltaY , datas } = e ; const time = Date . now ( ) ; const prevSpeed = datas . speed ; if ( ! prevSpeed ) { datas . speed = [ 0 , 0 ] ; datas . time = time ; return ; } const dt = time - datas . time ; datas . speed = [ prevSpeed [ 0 ] / 2 + deltaX / dt , prevSpeed [ 1 ] / 2 + deltaY / dt ] ; } export function getDuration ( speed , a ) { const normalSpeed = Math . sqrt ( speed [ 0 ] * speed [ 0 ] + speed [ 1 ] * speed [ 1 ] ) ; return Math . abs ( normalSpeed / a ) ; } export function getDestPos ( speed , a ) { const duration = getDuration ( speed , a ) ; return [ speed [ 0 ] / 2 * duration , speed [ 1 ] / 2 * duration , ] ; }