Escalator
DOM
Grid
DataSource
Column
Scrolled to row15
Show data for row 15
in these DOM elements
Get data for row 15
Extract cell value from row object
and show it in this element
Renderer
Show value in element
lördag 24 januari 15
public void onTouchStart(TouchStartEventevent) {
if (onlyOneFinger(event)) {
cancelMomentumScrolling();
saveStartCoordinates(event);
}
}
public void onTouchMove(TouchMoveEvent event) {
if (onlyOneFinger(event))
moveByEvent(event);
}
public void onTouchEnd(TouchEndEvent event) {
if (onlyOneFinger(event))
startFlickScroll(event);
}
Manual scrolling
lördag 24 januari 15
23.
AnimationScheduler scheduler =AnimationScheduler.get();
public void moveByEvent(TouchMoveEvent event) {
lastMoveEvent = event;
scheduler.requestAnimationFrame(mover, element);
}
AnimationCallback mover = new AnimationCallback() {
public void execute(double timestamp) {
lastMoveTimestamp = timestamp;
actuallyMoveByEvent(lastMoveEvent);
}
}
Frame by frame
lördag 24 januari 15
24.
public void startFlickScroll(TouchEndEventevent) {
scheduler.requestAnimationFrame(flick, element);
}
AnimationCallback flick = new AnimationCallback() {
public void execute(double timestamp) {
double time = timestamp - lastMoveTimestamp;
if (startSpeed = -1)
startSpeed = lastMovementDelta / time;
if (moveByTime(startSpeed, time))
scheduler.requestAnimationFrame(this, element);
}
}
Flick scrolling
lördag 24 januari 15
public abstract classAbstractRemoteDataSource {
public abstract void getRow(int rowIndex,
RequestRowCallback callback);
}
Get a row
lördag 24 januari 15
27.
public abstract classAbstractRemoteDataSource {
public Row getRow(int index) { … };
protected abstract void requestRows(int start, int count,
RequestRowsCallback callback);
}
Cache rows
lördag 24 januari 15
28.
public abstract classAbstractRemoteDataSource {
public Row getRow(int index) { … };
protected abstract void requestRows(int start, int count,
RequestRowsCallback callback);
public void ensureAvailability(int start, int count) { … };
}
What to cache?
lördag 24 januari 15