Utility that provides touch and mouse wheel scrolling capabilities for any interactive display object.

Events:

feathers.events.ScrollEvent.SCROLL

Dispatched when the scroll position changes, or when the minimum or maximum scroll positions change.

feathers.events.ScrollEvent.SCROLL_START

Dispatched when scrolling begins.

feathers.events.ScrollEvent.SCROLL_COMPLETE

Dispatched when scrolling ends.

Available since

1.0.0

.

Constructor

new(?target:InteractiveObject)

Creates a new Scroller object with the given arguments.

Available since

1.0.0

.

Variables

@:value(null)bounceEase:IEasing = null

The easing function to use when the scroll position goes outside of the minimum or maximum edge and bounces back.

Available since

1.0.0

.

See also:

read onlycontentHeight:Float

The height of the target's content. Will not scroll unless the height of the content is larger than the height of the target.

Available since

1.0.0

.

read onlycontentWidth:Float

The width of the target's content. Will not scroll unless the width of the content is larger than the width of the target.

Available since

1.0.0

.

decelerationRate:Float

This value is used to decelerate the scroller when "thrown". The velocity of a throw is multiplied by this value once per millisecond to decelerate. A value greater than 0.0 and less than 1.0 is expected.

Available since

1.0.0

.

read onlydraggingX:Bool

Determines if a touch is dragging the target horizontally (on the x-axis).

Available since

1.0.0

.

read onlydraggingY:Bool

Determines if a touch is dragging the target vertically (on the y-axis).

Available since

1.0.0

.

@:value(Quart.easeOut)ease:IEasing = Quart.easeOut

The easing function to use when animating the scroll position.

Available since

1.0.0

.

@:value(true)elasticEdges:Bool = true

Determines if the scrolling can go beyond the edges of the viewport and snap back to the minimum or maximum when released.

Available since

1.0.0

.

See also:

@:value(0.5)elasticSnapDuration:Float = 0.5

The duration, measured in seconds, of the animation when a the scroller snaps back to the minimum or maximum position after going out of bounds.

If elasticEdges is false, this property is ignored.

Available since

1.0.0

.

@:value(0.33)elasticity:Float = 0.33

If the scroll position goes outside the minimum or maximum bounds when the scroller's content is being actively dragged, the scrolling will be constrained using this multiplier. A value of 0.0 means that the scroller will not go beyond its minimum or maximum bounds. A value of 1.0 means that going beyond the minimum or maximum bounds is completely unrestrained.

If elasticEdges is false, this property is ignored.

Available since

1.0.0

.

See also:

  • Scroller.elasticEdges

@:value(true)enabledX:Bool = true

Determines if the target can be scrolled horizontally (on the x-axis).

Available since

1.0.0

.

@:value(true)enabledY:Bool = true

Determines if the target can be scrolled vertically (on the y-axis).

Available since

1.0.0

.

@:value(false)forceElasticBottom:Bool = false

Forces elasticity on the bottom edge, even if the height of the target's content is not larger than the width height the target.

If elasticEdges is false, this property is ignored.

Available since

1.0.0

.

See also:

@:value(false)forceElasticLeft:Bool = false

Forces elasticity on the left edge, even if the width of the target's content is not larger than the width of the target.

If elasticEdges is false, this property is ignored.

Available since

1.0.0

.

See also:

@:value(false)forceElasticRight:Bool = false

Forces elasticity on the right edge, even if the width of the target's content is not larger than the width of the target.

If elasticEdges is false, this property is ignored.

Available since

1.0.0

.

See also:

@:value(false)forceElasticTop:Bool = false

Forces elasticity on the top edge, even if the height of the target's content is not larger than the width height the target.

If elasticEdges is false, this property is ignored.

Available since

1.0.0

.

See also:

read onlymaxScrollX:Float

The maximum horizontal scroll position.

Available since

1.0.0

.

read onlymaxScrollY:Float

The maximum vertical scroll position.

Available since

1.0.0

.

@:value(6.0)minDragDistance:Float = 6.0

The minimum distance, measured in pixels, that the target must be dragged to begin scrolling.

Available since

1.0.0

.

read onlyminScrollX:Float

The minimum horizontal scroll position.

Available since

1.0.0

.

read onlyminScrollY:Float

The minimum vertical scroll position.

Available since

1.0.0

.

@:value(10.0)mouseWheelDeltaX:Float = 10.0

The distance to scroll when the mouse wheel is scrolled horizontally.

Available since

1.0.0

.

@:value(10.0)mouseWheelDeltaY:Float = 10.0

The distance to scroll when the mouse wheel is scrolled vertically.

Available since

1.0.0

.

@:value(0.0)mouseWheelDuration:Float = 0.0

The duration, measured in seconds, of the animation when scrolling with the mouse wheel.

Available since

1.0.0

.

@:value(false)mouseWheelYScrollsX:Bool = false

Determines if rotating the mouse wheel vertically changes the scrollX position instead of scrollY.

Available since

1.0.0

.

@:bindable("scroll")restrictedScrollX:Float

Setting restrictedScrollX will clamp the value to the range between minScrollX and maxScrollX.

Available since

1.0.0

.

@:bindable("scroll")restrictedScrollY:Float

Setting restrictedScrollY will clamp the value to the range between minScrollY and maxScrollY.

Available since

1.0.0

.

@:bindable("scroll")scrollX:Float

The current horizontal scroll position.

When the value of the scrollX property changes, the scroller will dispatch an event of type ScrollEvent.SCROLL. This event is dispatched when other scroll position properties change too.

Available since

1.0.0

.

See also:

@:bindable("scroll")scrollY:Float

The current vertical scroll position.

When the value of the scrollY property changes, the scroller will dispatch an event of type ScrollEvent.SCROLL. This event is dispatched when other scroll position properties change too.

Available since

1.0.0

.

See also:

read onlyscrolling:Bool

Determines if scrolling is currently active.

Available since

1.0.0

.

@:value(false)simulateTouch:Bool = false

Determines if mouse events should be treated like touch events.

Available since

1.0.0

.

@:value(null)snapPositionsX:Array<Float> = null

If not null, and the scroller is dragged with touch, the scrollX position is snapped to the nearest position in the array when the drag completes.

Available since

1.0.0

.

@:value(null)snapPositionsY:Array<Float> = null

If not null, and the scroller is dragged with touch, the scrollY position is snapped to the nearest position in the array when the drag completes.

Available since

1.0.0

.

target:InteractiveObject

The container used for scrolling.

Available since

1.0.0

.

@:value(0.05)throwElasticity:Float = 0.05

If the scroll position goes outside the minimum or maximum bounds when when the scroller's content is "thrown", the scrolling will be constrained using this multiplier. A value of 0.0 means that the scroller will not go beyond its minimum or maximum bounds. A value of 1.0 means that going beyond the minimum or maximum bounds is completely unrestrained.

If elasticEdges is false, this property is ignored.

Available since

1.0.0

.

See also:

  • Scroller.elasticEdges

  • Scroller.elasticity

read onlytouchPointID:Null<Int>

The touch point that is currently dragging the scroll target. Returns null if no touch point is currently associated with the drag.

If simulateTouch is true, the touchPointIsSimulated property will indicate if the mouse is current dragging the scroll target.

Available since

1.0.0

.

See also:

read onlytouchPointIsSimulated:Bool

Returns true if the mouse is dragging the scroll target as a simulated touch point.

Available since

1.0.0

.

See also:

read onlyvisibleHeight:Float

The height of the target's scrollable region.

Available since

1.0.0

.

read onlyvisibleWidth:Float

The width of the target's scrollable region.

Available since

1.0.0

.

Methods

applyLayoutShift(x:Null<Float>, y:Null<Float>):Void

An advanced method used to adjust the current scroll position and the target scroll position of throwTo() if there is a shift in the content's layout. For example, this may be used by containers with virtual layouts, where the dimensions of items might change from an estimated size to their actual rendered size.

Available since

1.2.0

.

applyScrollRestrictions():Void

Applies the minScrollX and maxScrollX restrictions to the current scrollX, and applies the minScrollY and maxScrollY restrictions to the current scrollY.

Available since

1.0.0

.

setDimensions(?visibleWidth:Float, ?visibleHeight:Float, ?contentWidth:Float, ?contentHeight:Float):Void

Updates the dimensions of both the target and its content.

Available since

1.0.0

.

stop():Void

Immediately stops any animation that affects the scrolling.

Available since

1.0.0

.

@:value({ ease : null, duration : null })throwTo(scrollX:Null<Float>, scrollY:Null<Float>, ?duration:Float, ?ease:IEasing):Void

Immediately throws the scroller to the specified position, with optional animation. If you want to throw in only one direction, pass in null for the value that you do not want to change.

Available since

1.0.0

.