Skip to content

Commit 301f6ed

Browse files
committed
Dev: added header to the list view
1 parent 7c410d0 commit 301f6ed

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/listviews/ListView.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export default class ListView extends BaseView {
6161
emptyText: '',
6262
delayedRender: 0,
6363
headerView: null, // view to print on the header
64-
headerSize: 0 // height of the header in a vertical listview or width in an horizontal listview
64+
headerSize: 0, // height of the header in a vertical listview or width in an horizontal listview
65+
changeDirectionPan: 50
6566
});
6667

6768
this.items = [];
@@ -84,6 +85,7 @@ export default class ListView extends BaseView {
8485
this.touchY = 0;
8586
this.direction = null;
8687
this.previousDirection = null;
88+
this.startChangeDirectionAt = null;
8789

8890
this.setCollection(this.collection);
8991

@@ -481,6 +483,12 @@ export default class ListView extends BaseView {
481483
// TODO: animate scroll
482484
this.pause();
483485
this.el.scrollTop = 0;
486+
// Trigger change:direction when user taps the status bar
487+
this.direction = DOWN_TOP;
488+
if (this.direction != this.previousDirection) {
489+
this.trigger('change:direction', this.direction);
490+
this.previousDirection = this.direction;
491+
}
484492
this.resume();
485493
}
486494

@@ -500,9 +508,15 @@ export default class ListView extends BaseView {
500508
let y = this.y = -this.el.scrollTop;
501509
this.direction = y < this.previousY ? TOP_DOWN : DOWN_TOP;
502510
if (this.direction != this.previousDirection && y < 0) {
503-
this.trigger('change:direction', this.direction);
511+
this.startChangeDirectionAt = y;
504512
this.previousDirection = this.direction;
505513
}
514+
515+
if (this.startChangeDirectionAt !== null && Math.abs(this.startChangeDirectionAt - y) > this.options.changeDirectionPan) {
516+
this.startChangeDirectionAt = null;
517+
this.trigger('change:direction', this.direction);
518+
}
519+
506520
this.previousY = y;
507521
startIndex = this.getStartIndex();
508522
endIndex = this.getEndIndex();

0 commit comments

Comments
 (0)