Packagesekati.ui
Classpublic class Scroll

Scroll provides a flexible scrollbar controller class: handling mouseWheel (PC & Mac), dynamic resizing content, external size tracking for accordian style content scrolling, slideContent method, modal ui states, proportional bar, gutter and more.

See also

sekati.external.ExternalMouseWheel
sekati.events.ExternalMouseEvent
http://code.google.com/p/sekati/source/browse/trunk/deploy/js/swfmouse.js


Public Properties
 PropertyDefined by
  isDragging : Boolean
[read-only] Check if bar is being dragged.
Scroll
  isMouseInArea : Boolean
[read-only] Check if Mouse is in scrollable area.
Scroll
  isScrollable : Boolean
[read-only] Check if content is scrollable.
Scroll
Public Methods
 MethodDefined by
  
Scroll(content:DisplayObject, scrollArea:DisplayObject, gutter:Sprite, bar:Sprite, axis:String = "y", isInit:Boolean = true, hasMouseWheel:Boolean = true, isProportionalGutter:Boolean = true, isProportionalBar:Boolean = true, ease:String = "easeOutExpo", contentSizeTracker:DisplayObject = null, friction:Number = 0.8, ratio:Number = 0.5)
Scroll Constructor
Scroll
  
destroy():void
Cleanly destroy Scroll instances.
Scroll
  
init():void
Initialize scroll behavior: define confines, mouseWheel, and set scroller to rollout color state.
Scroll
  
moveAmount(amount:Number, sec:Number):void
Tween the scroll _bar by a certain amount.
Scroll
  
moveBar(pos:Number, sec:Number):void
Tween _bar to position, _content will reposition accordingly.
Scroll
  
moveContent(pos:Number, sec:Number):void
Tween to a position within the _content, scroll _bar will reposition accordingly.
Scroll
  
movePercent(contentPercent:Number, sec:Number):void
Tween the scroll _bar by the specified percentage of the total content.
Scroll
  
reset():void
Reset the Scroll and content positioning and reinitialize.
Scroll
  
stopScroll():void
Stop all scrolling motions
Scroll
Protected Methods
 MethodDefined by
  
barDownHandler(e:MouseEvent):void
Bar Press - start bar drag: register a pseudo onReleaseOutside event listener on stage.
Scroll
  
barUpHandler(e:MouseEvent):void
Bar Release - stop bar drag: unregister a pseudo onReleaseOutside event listener from stage.
Scroll
  
enterFrame(e:Event):void
EnterFrame runs the core scroll logic.
Scroll
  
gutterClickHandler(e:MouseEvent):void
Gutter clicks.
Scroll
  
mouseWheelHandler(e:MouseEvent):void
MouseWheel handler for MouseEvent.MOUSE_WHEEL or mac ExternalMouseEvent.MOUSE_WHEEL.
Scroll
  
resolvePosition(pos:Number):Number
ResolvePosition insure that the scroller moves within its gutter boundaries.
Scroll
  
setConfines():void
Store the scrollable confines & resize the bar and gutter if necessary.
Scroll
  
Initialize Mac/PC compatible MouseWheel support.
Scroll
  
Set content related confines (isloated from setConfines as this may need to be called upon content size changes).
Scroll
Protected Constants
 ConstantDefined by
  MOVE_PERCENT : Number = 0.05
[static] Default percentage of content to tween by in move methods.
Scroll
  MOVE_TIME : Number = 0.2
[static] Default tween duration, in second, in move methods.
Scroll
Property detail
isDraggingproperty
isDragging:Boolean  [read-only]

Check if bar is being dragged.

Implementation
    public function get isDragging():Boolean
isMouseInAreaproperty 
isMouseInArea:Boolean  [read-only]

Check if Mouse is in scrollable area.

Implementation
    public function get isMouseInArea():Boolean
isScrollableproperty 
isScrollable:Boolean  [read-only]

Check if content is scrollable.

Implementation
    public function get isScrollable():Boolean
Constructor detail
Scroll()constructor
public function Scroll(content:DisplayObject, scrollArea:DisplayObject, gutter:Sprite, bar:Sprite, axis:String = "y", isInit:Boolean = true, hasMouseWheel:Boolean = true, isProportionalGutter:Boolean = true, isProportionalBar:Boolean = true, ease:String = "easeOutExpo", contentSizeTracker:DisplayObject = null, friction:Number = 0.8, ratio:Number = 0.5)

Scroll Constructor

Parameters
content:DisplayObject — The scrollable content DisplayObject (Registered 0,0 in its container).
 
scrollArea:DisplayObject — The area within which the content is to be scrolled; usually a mask, background or overlay. Also the area within which MouseWheel support is active.
 
gutter:Sprite — The clickable, interactive "track" area for the scroll bar (Registered axis 0 in its container).
 
bar:Sprite — The object which is dragged or thrown to scroll content inside the viewArea (Registered axis 0 in its container).
 
axis:String (default = "y") — The axis (must be: x || y) upon which to scroll.
 
isInit:Boolean (default = true) — The (optional) initialization Scroll upon instantiation, otherwise init() must be called manually.
 
hasMouseWheel:Boolean (default = true) — The (optional) enabling of MouseWheel support (both Mac & PC) of the Scroll instance.
 
isProportionalGutter:Boolean (default = true) — The (optional) resizing of the gutter to match the viewArea's width or height depending on axis.
 
isProportionalBar:Boolean (default = true) — The (optional) resizing of the scroll bar to reflect the viewArea's scrollable content.
 
ease:String (default = "easeOutExpo") — The Tweener easing equation applied to slideContent, slideScroller or moveScroller calls.
 
contentSizeTracker:DisplayObject (default = null) — The (optional) content size tracking object; used to calculate the viewable scroll area. For use in accordian style content where child objects of content visible property is toggled throwing off the scroll calculations.
 
friction:Number (default = 0.8) — The motion friction of the content & bar. Note: this does not reflect the motion of slideContent, slideScroller or moveScroller calls.
 
ratio:Number (default = 0.5) — The motion ratio of the content & bar. Note: this does not reflect the motion of slideContent, slideScroller or moveScroller calls.

Throws
— if axis is not "x" or "y" & returns without proper instantiation

Example
The following code creates a new Scroll instance:
   // Scroll(content, scrollArea, gutter, bar, axis, isInit, hasMouseWheel, isProportionalGutter, isProportionalBar, easingEquation, contentSizeTracker, friction, ratio); 
   var scroll:Scroll = new Scroll( content, scrollArea, gutter, bar, "x", true, true, true, true, "easeOutQuint", null, 0.7, 0.4 );
   

Method detail
barDownHandler()method
protected function barDownHandler(e:MouseEvent):void

Bar Press - start bar drag: register a pseudo onReleaseOutside event listener on stage.

Parameters
e:MouseEvent
barUpHandler()method 
protected function barUpHandler(e:MouseEvent):void

Bar Release - stop bar drag: unregister a pseudo onReleaseOutside event listener from stage.

Parameters
e:MouseEvent
destroy()method 
public function destroy():void

Cleanly destroy Scroll instances.

enterFrame()method 
protected function enterFrame(e:Event):void

EnterFrame runs the core scroll logic.

Parameters
e:Event
gutterClickHandler()method 
protected function gutterClickHandler(e:MouseEvent):void

Gutter clicks.

Parameters
e:MouseEvent
init()method 
public function init():void

Initialize scroll behavior: define confines, mouseWheel, and set scroller to rollout color state.

mouseWheelHandler()method 
protected function mouseWheelHandler(e:MouseEvent):void

MouseWheel handler for MouseEvent.MOUSE_WHEEL or mac ExternalMouseEvent.MOUSE_WHEEL.

Parameters
e:MouseEvent
moveAmount()method 
public function moveAmount(amount:Number, sec:Number):void

Tween the scroll _bar by a certain amount. Useful when scroll UI arrows are required.

Parameters
amount:Number — of pixels to move: positive or negative.
 
sec:Number — tween duration in seconds. _myScroll.moveAmount( -100 );
moveBar()method 
public function moveBar(pos:Number, sec:Number):void

Tween _bar to position, _content will reposition accordingly.

Parameters
pos:Number — the position to slide scroller on axis.
 
sec:Number — the tween duration in seconds.
moveContent()method 
public function moveContent(pos:Number, sec:Number):void

Tween to a position within the _content, scroll _bar will reposition accordingly.

Parameters
pos:Number — the position to slide content on axis.
 
sec:Number — the tween duration in seconds.
movePercent()method 
public function movePercent(contentPercent:Number, sec:Number):void

Tween the scroll _bar by the specified percentage of the total content.

Parameters
contentPercent:Number — of total content (e.g. MyScroll.movePercent(.1); // increases position by 10%).
 
sec:Number — (Number) optional tween duration in seconds
reset()method 
public function reset():void

Reset the Scroll and content positioning and reinitialize.

resolvePosition()method 
protected function resolvePosition(pos:Number):Number

ResolvePosition insure that the scroller moves within its gutter boundaries.

Parameters
pos:Number

Returns
Number
setConfines()method 
protected function setConfines():void

Store the scrollable confines & resize the bar and gutter if necessary.

setMouseWheel()method 
protected function setMouseWheel():void

Initialize Mac/PC compatible MouseWheel support.

stopScroll()method 
public function stopScroll():void

Stop all scrolling motions

updateConfines()method 
protected function updateConfines():void

Set content related confines (isloated from setConfines as this may need to be called upon content size changes).

Constant detail
MOVE_PERCENTconstant
protected static const MOVE_PERCENT:Number = 0.05

Default percentage of content to tween by in move methods.

MOVE_TIMEconstant 
protected static const MOVE_TIME:Number = 0.2

Default tween duration, in second, in move methods.