import { Point } from "../std/Point" ; import { PlaygroundViewModel } from "../ViewModels/PlaygroundViewModel" ; import { PositionTransformation } from "../std/DragBehavior" ; export interface SvgContext { mouseToSvgCoordinates ( mousePos ) : Point ; } export interface TimeOffsetConversion { getOffset ( time ) : number ; getTime ( offset ) : number ; offsetPerTime : number ; } export function handleMouseDownOnTimedObj ( e , data , setTime , playground , svgContext , timeOffsetConversion , end ? ) { e . preventDefault ( ) ; e . stopPropagation ( ) ; const op = playground . timedObjDragBehavior . start ( data , new PositionTransformation ( p => svgContext . mouseToSvgCoordinates ( p ) ) . then ( p => new Point ( 0 , timeOffsetConversion . getTime ( p . y ) ) ) ) . endOnMouseUp ( ) ; op . onDrag . sub ( data => { setTime ( data . position . y ) ; } ) ; op . onEnd . sub ( data => { if ( end ) { end ( ) ; } } ) ; }