BoundaryRule QML Type
Defines a restriction on the range of values that can be set on a numeric property. More...
Import Statement: | import Qt.labs.animation 1.0 |
Since: | Qt 5.14 |
Properties
- currentOvershoot : qreal
- easing : qreal
- enabled : bool
- maximum : qreal
- maximumOvershoot : qreal
- minimum : qreal
- minimumOvershoot : qreal
- overshootFilter : enum
- overshootScale : qreal
- peakOvershoot : qreal
- returnDuration : int
Methods
- bool returnToBounds()
Detailed Description
A BoundaryRule defines the range of values that a particular property is allowed to have. When an out-of-range value would otherwise be set, it applies "resistance" via an easing curve.
For example, the following BoundaryRule prevents DragHandler from dragging the Rectangle too far:
import QtQuick 2.14 import Qt.labs.animation 1.0 Rectangle { id: root width: 170; height: 120 color: "green" DragHandler { id: dragHandler yAxis.minimum: -1000 xAxis.minimum: -1000 onActiveChanged: if (!active) xbr.returnToBounds(); } BoundaryRule on x { id: xbr minimum: -50 maximum: 100 minimumOvershoot: 40 maximumOvershoot: 40 } }
Note that a property cannot have more than one assigned BoundaryRule.
See also Animation and Transitions in Qt Quick, Behavior example, and Qt QML.
Property Documentation
This property holds the easing curve to be applied in overshoot mode (whenever the minimum or maximum constraint is violated, while the value is still within the respective overshoot range).
The default easing curve is QEasingCurve::OutQuad.
This property holds whether the rule will be enforced when the tracked property changes value.
By default a BoundaryRule is enabled.
This property holds the largest unconstrained value that the property is allowed to have. If the property is set to a larger value, it will be constrained by easing and maximumOvershoot.
The default is 1
.
This property holds the amount that the property is allowed to be more than maximum. Whenever the value is greater than maximum and less than maximum + maximumOvershoot
, it is constrained by the easing curve. When the value attempts to exceed maximum + maximumOvershoot
there is a hard stop.
The default is 0.
This property holds the smallest unconstrained value that the property is allowed to have. If the property is set to a smaller value, it will be constrained by easing and minimumOvershoot.
The default is 0
.
This property holds the amount that the property is allowed to be less than minimum. Whenever the value is less than minimum and greater than minimum - minimumOvershoot
, it is constrained by the easing curve. When the value attempts to go under minimum - minimumOvershoots
there is a hard stop.
The default is 0
.
This property specifies the aggregation function that will be applied to the intercepted property value.
If this is set to BoundaryRule.None
(the default), the intercepted property will hold a value whose overshoot is limited to currentOvershoot. If this is set to BoundaryRule.Peak
, the intercepted property will hold a value whose overshoot is limited to peakOvershoot.
This property holds the amount by which the easing is scaled during the overshoot condition. For example if an Item is restricted from moving more than 100 pixels beyond some limit, and the user (by means of some Input Handler) is trying to drag it 100 pixels past the limit, if overshootScale is set to 1, the user will succeed: the only effect of the easing curve is to change the rate at which the item moves from overshoot 0 to overshoot 100. But if it is set to 0.5, the BoundaryRule provides resistance such that when the user tries to move 100 pixels, the Item will only move 50 pixels; and the easing curve modulates the rate of movement such that it may move in sync with the user's attempted movement at the beginning, and then slows down, depending on the shape of the easing curve.
The default is 0.5.
This property holds the most-positive or most-negative value of currentOvershoot that has been seen, until returnToBounds() is called.
This can be useful when the intercepted property value is known to fluctuate, and you want to find and react to the maximum amount of overshoot rather than to the fluctuations.
See also overshootFilter.
This property holds the amount of time in milliseconds that returnToBounds() will take to return the target property to the nearest bound. If it is set to 0, returnToBounds() will set the property immediately rather than creating an animation job.
The default is 100 ms.
Method Documentation
Returns the intercepted property to a value between minimum and maximum, such that currentOvershoot and peakOvershoot are both zero. This will be animated if returnDuration is greater than zero.
Returns true if the value needed to be adjusted, or false if it was already within bounds.