WidgetPositionConstrain Class
A widget extension, which can be used to add constrained xy positioning support to the base Widget class, through the Base.build method. This extension requires that the WidgetPosition extension be added to the Widget (before WidgetPositionConstrain, if part of the same extension list passed to Base.build).
Methods
constrain
-
xy
-
node
Constrains the widget's bounding box to a node (or the viewport). If xy or node are not passed in, the current position and the value of "constrain" will be used respectively.
The widget's position will be changed to the constrained position.
Properties
ATTRS
Object
static
Static property used to define the default attribute configuration introduced by WidgetPositionConstrain.
Attributes
constrain
Boolean | Node
The node to constrain the widget's bounding box to, when setting xy. Can also be set to true, to constrain to the viewport.
Default: null
Fires event constrainChange
Fires when the value for the configuration attribute constrain
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:
preventOverlap
Boolean
If set to true, and WidgetPositionAlign is also added to the Widget, constrained positioning will attempt to prevent the widget's bounding box from overlapping the element to which it has been aligned, by flipping the orientation of the alignment for corner based alignments
Fires event preventOverlapChange
Fires when the value for the configuration attribute preventOverlap
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: