import { BoardManager } from "./boardManager" ; /**
 * this class enables to positionate automatically a collection of magnets (typically the magnets from the menu)
 */ export class MagnetPositionner { /**
     * put extra space because we start a new group of magnets
     */ static newGroup ( ) { this . magnetX += 100 ; } /**
     * the next position of the next magnet to be added
     */ static magnetX = 0 ; static magnetY = 64 ; static magnetXseparation = 64 ; static magnetYseparation = 64 ; returns static getYTopWhenNewMagnets ( ) { return 64 ; } /**
     * set the seperation in pixels between two magnets
     */ static setSeparationX ( v ) { MagnetPositionner . magnetXseparation = v ; } static setSeperationY ( v ) { MagnetPositionner . magnetYseparation = v ; } /**
     * reset the positionning variables
     */ static resetPositionate ( ) { MagnetPositionner . magnetX = BoardManager . getCurrentScreenRectangle ( ) . x1 ; MagnetPositionner . magnetY = MagnetPositionner . getYTopWhenNewMagnets ( ) ; MagnetPositionner . magnetXseparation = 64 ; MagnetPositionner . magnetYseparation = 64 ; } param element returns static positionnate ( element ) { if ( MagnetPositionner . magnetX > BoardManager . getCurrentScreenRectangle ( ) . x2 - 10 ) { MagnetPositionner . magnetX = BoardManager . getCurrentScreenRectangle ( ) . x1 ; MagnetPositionner . magnetY += this . magnetYseparation ; } if ( element . style . left == "" ) { element . style . left = MagnetPositionner . magnetX + "px" ; element . style . top = MagnetPositionner . magnetY + "px" ; } MagnetPositionner . magnetX += this . magnetXseparation ; return element ; } }