API Reference 0.7.1rikulo_gestureScrollerState

ScrollerState class

The state in a scolling process, provided by Scroller in ScrollerStart and ScrollerMove callback.

class ScrollerState extends GestureState {
 final AsSize _fnViewPortSize, _fnContentSize;
 bool _hor, _ver;
 Point _pos, _ppos;
 int _time, _ptime;
 Size _contentSizeCache, _viewPortSizeCache;
 Rect _dragRangeCache;

 ScrollerState._(Scroller scroller, this.eventTarget, 
 this._fnViewPortSize, this._fnContentSize, this._time) :
 this.scroller = scroller,
 startPosition = DomUtil.position(scroller.owner) * -1 {
   _pos = startPosition;
   Size cs = contentSize, vs = viewPortSize;
   _hor = scroller._hasHor && cs.width > vs.width;
   _ver = scroller._hasVer && cs.height > vs.height;
 }

 @override
 final EventTarget eventTarget;
 @override
 int get time => _time;
 /** Returns the associated [Scroller].
  */
 final Scroller scroller;
 
 /** Returns the current scroll offset.
  */
 Point get position => _pos;
 /** The starting position.
  */
 final Point startPosition;
 
 /** Returns the current scrolling velocity.
  */
 Point get velocity => _ppos == null || _pos == null || _time == null || _ptime == null ? 
     new Point(0, 0) : Points.divide(_pos - _ppos, _time - _ptime);
 /** Returns the size of view port.
  */
 Size get viewPortSize {
   if (_viewPortSizeCache == null)
     _viewPortSizeCache = _fnViewPortSize();
   return _viewPortSizeCache;
 }
 /** Returns the content size.
  */
 Size get contentSize {
   if (_contentSizeCache == null)
     _contentSizeCache = _fnContentSize();
   return _contentSizeCache;
 }
 
 /** Tell scroller state to re-determine view port and content sizes.
  */
 void resize() {
   _viewPortSizeCache = _contentSizeCache = null;
   _dragRangeCache = null;
 }
 
 Rect get dragRange {
   if (_dragRangeCache == null) {
     Size vsize = viewPortSize, csize = contentSize;
     num left = vsize.width - csize.width,
         top = vsize.height - csize.height;
     _dragRangeCache = new Rect(left, top, -left, -top);
   }
   return _dragRangeCache;
 }

 void snapshot(Point pos, int time) {
   if (_time == null || time > _time) {
     _ppos = _pos;
     _ptime = _time;
     _pos = pos * -1;
     _time = time;
   }
 }
}

Extends

GestureState > ScrollerState

Properties

final Size contentSize #

Returns the content size.

Size get contentSize {
 if (_contentSizeCache == null)
   _contentSizeCache = _fnContentSize();
 return _contentSizeCache;
}

var data #

inherited from GestureState

Custom data. It is useful if you'd like to store something that will be cleaned up automatically when the gesture is finished.

var data

final Rect dragRange #

Rect get dragRange {
 if (_dragRangeCache == null) {
   Size vsize = viewPortSize, csize = contentSize;
   num left = vsize.width - csize.width,
       top = vsize.height - csize.height;
   _dragRangeCache = new Rect(left, top, -left, -top);
 }
 return _dragRangeCache;
}

final EventTarget eventTarget #

The element which receives the event.

docs inherited from GestureState
final EventTarget eventTarget

final Point position #

Returns the current scroll offset.

Point get position => _pos;

final Scroller scroller #

Returns the associated Scroller.

final Scroller scroller

final Point startPosition #

The starting position.

final Point startPosition

final int time #

The latest timestamp of gesture.

docs inherited from GestureState
@override
int get time => _time;

final Point velocity #

Returns the current scrolling velocity.

Point get velocity => _ppos == null || _pos == null || _time == null || _ptime == null ? 
   new Point(0, 0) : Points.divide(_pos - _ppos, _time - _ptime);

final Size viewPortSize #

Returns the size of view port.

Size get viewPortSize {
 if (_viewPortSizeCache == null)
   _viewPortSizeCache = _fnViewPortSize();
 return _viewPortSizeCache;
}

Methods

void resize() #

Tell scroller state to re-determine view port and content sizes.

void resize() {
 _viewPortSizeCache = _contentSizeCache = null;
 _dragRangeCache = null;
}

void snapshot(Point pos, int time) #

void snapshot(Point pos, int time) {
 if (_time == null || time > _time) {
   _ppos = _pos;
   _ptime = _time;
   _pos = pos * -1;
   _time = time;
 }
}