import { ConstraintDrawing } from './ConstraintDrawing' ; import { ActionSerialized } from './ActionSerialized' ; import { Action } from "./Action" ; import { MagnetMovementUpdater } from './MagnetMovementRecorder' ; export class ActionMagnetMove extends Action { readonly magnetid : string ; readonly points : { x : number ; y : number ; } [ ] = [ ] ; get xMax ( ) : number { return 0 ; } serializeData ( ) { return { type : "magnetmove" , pause : this . pause , userid : this . userid , magnetid : this . magnetid , points : this . points } ; } param userid param magnetid param points constructor ( userid , magnetid , points ) { super ( userid ) ; this . magnetid = magnetid ; this . points = points ; this . isDirectlyUndoable = true ; } createOverviewImage ( ) { return "url(img/icons/E103.svg)" ; } private setPosition ( point ) { if ( document . getElementById ( this . magnetid ) ) { MagnetMovementUpdater . update ( document . getElementById ( this . magnetid ) , point . x , point . y ) ; ConstraintDrawing . update ( ) ; } } async redo ( ) { this . setPosition ( this . points [ this . points . length - 1 ] ) ; } async undo ( ) { this . setPosition ( this . points [ 0 ] ) ; } returns async redoAnimated ( ) { for ( let i = 0 ; i < this . points . length ; i ++ ) { this . setPosition ( this . points [ i ] ) ; await this . delay ( ) ; } } }