flatworld.extensions.mapZoom Class
Core plugin for the engine. Handles zooming for the map. Core plugins can always be overwrote if needed. Zooming happens when the user scrolls the mousewheel or in mobile, pinches the screen.
Item Index
Methods
Attributes
Methods
_calculateCenterMoveCoordinates
()
private
static
_isOverZoomLimit
()
private
static
_isOverZoomLimit
_zoom
()
private
static
handleZoomEventDesktop
-
map
Setup desktop zoomEvent by currying. Internally: Sets up correct scale + moves map accordingly to zoom to the current center coordinates
Parameters:
-
map
MapMap instance
init
-
mapObj
Required init functions for the plugin
Parameters:
-
mapObj
Mapinstantiated Map class object
setZoomLimits
-
farther
-
closer
How much can be zoomed in maximum and minimum
setZoomModifier
-
amount
How much one mouse wheel step zooms
Parameters:
-
amount
NumberHow much one mouse wheel step zooms. Needs to be in between 0 - 0.5
unifiedEventCB
-
e
-
delta
-
deltaX
-
deltaY
This starts the correct eventListener for the current environment. Mousewheel and pinch differ quite dramatically so we keep them as separate functions.
Parameters:
-
e
EventEvent object
-
delta
IntegerHamster.js provided delta
-
deltaX
IntegerHamster.js provided delta
-
deltaY
IntegerHamster.js provided delta
Attributes
zoomLimit
farther: Number, closer: Number
Maximum and minimum amount, the player can zoom the map
Fires event zoomLimitChange
Fires when the value for the configuration attribute zoomLimit
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
zoomModifier
Number
How much one step of zooming affects
Fires event zoomModifierChange
Fires when the value for the configuration attribute zoomModifier
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added: