![]() |
|
dynapi.fx.SnapX - Quick Reference |
Extends: DynLayer |
Remarks
SnapX is an extension to the DynLayer API which is used to make a layer snap to other snappable layers, and will trigger the onsnap() event whenever a snap occurs.
[none]
isSnapEnabled - Boolean flag used to determine if layer is snap enabled.
isStickySnapEnabled - Boolean flag used to determine if layer is sticky snap enabled.
isGridSnapEnabled - Boolean flag used to determine if layer is grid snap enabled.
x - Number value representing the X coordinate of a layer's upper-left corner.
y - Number value representing the Y coordinate of a layer's upper-left corner.
w - Number value representing the width of a layer.
h - Number value representing the height of a layer.
_snapX - Number value used primarily for calculation of direction of movement when compared to DynLayer's x.
_snapY - Number value used primarily for calculation of direction of movement when compared to DynLayer's y.
_snapDirection - String value used to hold the current direction of movement of a snap enabled layer.
_snapStickyX - Number value used primarily for sticky snap enabled calculations. Currently not used; reserved for possible future use.
_snapStickyY - Number value used primarily for sticky snap enabled calculations. Currently not used; reserved for possible future use.
_snapGridX - Number value used primarily for grid snap enabled calculations. Currently not used; reserved for possible future use.
_snapGridY - Number value used primarily for grid snap enabled calculations. Currently not used; reserved for possible future use.
_snapType - String value representing the layer's snap type (normal or null, sticky or grid).
_snapBoundaryType - String value representing the layer's snap boundary type (inner, outer or both).
_snapGridSize - Number value representing the granularity of snapping to imaginary grid lines of grid snap enabled dragged (source) layers.
_snapBndTi - Number value representing layer's inner-top boundary.
_snapBndRi - Number value representing layer's inner-right boundary.
_snapBndBi - Number value representing layer's inner-bottom boundary.
_snapBndLi - Number value representing layer's inner-left boundary.
_snapBndTo - Number value representing layer's outer-top boundary.
_snapBndRo - Number value representing layer's outer-right boundary.
_snapBndBo - Number value representing layer's outer-bottom boundary.
_snapBndLo - Number value representing layer's outer-left boundary.
DynLayer._snapBoundaryTypeDefault - String value representing the snap boundary type (inner, outer, or both) to be used as a default by other SnapX methods. DynLayer global scope.
DynLayer._snapBoundaryDefault - Number value representing the snap boundary size to be used as a default by other SnapX methods. DynLayer global scope.
DynLayer._snapGridSizeDefault - Number value representing the snap grid size to be used as a default by other SnapX methods. DynLayer global scope.
[null] enableSnap() - Enables snap checks, sets snap type and borders to the default. Both dragged (source) and other static or draggable (target) layers must be snap enabled. Normal snap occurs when either upper-left or lower-right source corners are within snap border, and direction of motion is towards (not parallel or away from) target's real layer edge. [null] disableSnap() - Disables all snap checking. Does not modify the sticky or grid snap enabled flags. [null] setSnapType([normal|null|sticky|grid]) - Allows you to set a snap type. Does not enable snap, as it is primarily called from enable snap. Enables sticky and grid snap flags. Snap types can be normal or null, sticky or grid. [null] setSnapBoundaryTypeDefault([inner|outer|both]) - Allows you to set a default snap boundary type so you don't have to keep specifying the snap boundary type of newly created snap-enabled DynLayers. Snap boundary types can be inner, outer or both. [inner|outer|both] getSnapBoundaryTypeDefault() - Returns the current snap boundary type default, either inner, outer, or both. [null] setSnapBoundaryType([inner|outer|both]) - Allows you to set the snap boundary type of the snap-enabled DynLayer. Snap types can be inner, outer, or both. [inner|outer|both] getSnapBoundaryType() - Returns the current snap boundary type of the layer, either inner, outer, or both. [null] setSnapBoundaryDefault(b) - Allows you to set a default snap boundary so you can later call setSnapBoundary() with no arguments to set to the default boundary value. Snap boundary is a number. [b] getSnapBoundaryDefault() - Returns the current snap boundary default. Snap boundary is a number. setSnapBoundary() - Can be used in many different ways:
getSnapBoundary() - Can be used in two different ways:
[null] enableStickySnap() - Enables sticky snap. Both dragged (source) and other static or draggable (target) layers must be snap enabled. Only dragged (source) layer need be sticky snap enabled. Sticky snap occurs when either upper-left or lower-right source corners are within snap border, regardless of direction of motion with respect to target layer's real edge. The intended effect is that while the dragged (source) layer is within the other (target) layer's border, the dragged (source) layer 'sticks' to the other (target) layer's real edge. [null] disableStickySnap() - Disables sticky snap. Turns off sticky snap behaviour. Doesn't enable or disable regular or grid snap behaviour. [null] enableGridSnap() - Enables grid snap. Both dragged (source) and other static or draggable (target) layers must be snap enabled. Only dragged (source) layer need be grid snap enabled. Grid snap occurs when either upper-left or lower-right source corners are within snap border, regardless of direction of motion with respect to target layer's real edge. The intended effect is that while the dragged (source) layer is within the other (target) layer's border, the dragged (source) layer snaps to imaginary grid lines whose distance can be set with setGridSnapSize(b). [null] disableGridSnap() - Disables grid snap. Turns off grid snap behaviour. Doesn't enable or disable regular or sticky snap behaviour. [null] setGridSnapSizeDefault(g) - Allows you to set the default grid snap size, so that further enabling of grid snap features will automatically set the grid snap size to the value specified. [g] getGridSnapSizeDefault() - Returns the current default grid snap size. [null] setGridSnapSize(g) - Allows you to set the grid snap size of individual layers. Only the dragged (source) layer's grid snap size will be used, not the other static or draggable (target) layer's grid snap size (if applicable). [g] getGridSnapSize() - Returns the current grid snap size. [null] setLocation(x,y) - Calls DynLayer's setLocation method, but if snap is enabled, this augmented version will also calculate the direction of movement and check for a snap condition. [string] getSnapDirection() - Returns a string representing the general direction in which the layer is moving. The following are all the possible directions returned by the getSnapDirection() method: [null] _snapSetLocation(x,y) - Backup copy of DynLayer's setLocation. [null] _checkForSnapInner() - Checks for a snap condition, i.e. if the dragged (source) layer moves within the inner top, right, bottom and left boundaries of the other static or draggable (target) layer. Moves dragged (source) layer to correct position depending on result of check. [null] _checkForSnapOuter() - Checks for a snap condition, i.e. if the dragged (source) layer moves within the outer top, right, bottom and left boundaries of the other static or draggable (target) layer. Moves dragged (source) layer to correct position depending on result of check. [none]
Can be used in five different ways:
# args
arg types
0
use defaults
1
snap type [normal|null|sticky|grid]
2
snap type [normal|null|sticky|grid],
boundary type [inner|outer|both]
3
snap type [normal|null|sticky|grid],
boundary type [inner|outer|both],
boundary
4
snap type [normal|null|sticky|grid],
boundary type [inner|outer|both],
boundary,
grid size (if applicable)
# args
arg types
0
[null] setSnapBoundary() - Set snapBoundaryType to snapBoundaryTypeDefault, set boundary for all sides to snapBoundaryDefault.
1
[null] setSnapBoundary([inner|outer|both]) - If snapBoundaryType, set boundary for all sides to snapBoundaryDefault.
1
[null] setSnapBoundary(b) - If boundary, set all sides to boundary, and snapBoundaryType to snapBoundaryTypeDefault.
2
[null] setSnapBoundary([inner|outer|both],b) - If snapBoundaryType and boundary, set snap boundary type and set boundary for all sides.
2
[null] setSnapBoundary(number,number) - If N1,N2 set all inner boundaries to N1 and all outer boundaries to N2 and set snapBoundaryType to both.
5
[null] setSnapBoundary([inner|outer|both],t,r,b,l) - Set snapBoundaryType, set top, right, bottom and left boundaries (either inner, outer, or both, as specified).
8
[null] setSnapBoundary(ti,ri,bi,li,to,ro,bo,lo) - Set snap boundary type to both, set top-inner, right-inner, bottom-inner, left-inner, top-outer, right-outer, bottom-outer and left-outer as specified.
N
North
S
South
E
East
W
West
NE
North East
NW
Noth West
SE
South East
SW
South West
Private Methods
Static Methods
Bugs & known issues
TODO