summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-05-10 17:15:14 +0200
committerJules Laplace <julescarbon@gmail.com>2018-05-10 17:15:14 +0200
commit2fb2e09bb24340a7cc33ae30037f45125791131c (patch)
tree45afccf7b9455ab48f7725a24bae5c28ad02ca9e /StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js
parent6196541cf993d5a1a4b8b7f511bf7daf8f849608 (diff)
androidz
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js')
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js b/StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js
new file mode 100755
index 00000000..7f90929a
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js
@@ -0,0 +1,44 @@
+var ScrollableView = View.extend({
+
+ events: {
+ "load img": "deferRefresh",
+ },
+
+ deferScrollToTop: function(){
+ this.scrollPosition = 0
+ setTimeout(this.scrollToTop.bind(this), 0)
+ },
+
+ scrollPosition: 0,
+
+ resetScroll: function(){
+ this.scrollPosition = 0
+ },
+
+ saveScroll: function(){
+ this.scrollPosition = this.scroller.y
+ },
+
+ restoreScroll: function(){
+ setTimeout(function(){
+ this.scroller.scrollTo(0, this.scrollPosition)
+ }.bind(this), 0)
+ },
+
+ refreshScroller: function(){
+ this.scroller.refresh()
+ clearTimeout( this.scrollerRefreshTimeout )
+ },
+
+ scrollerRefreshTimeout: null,
+ deferRefresh: function(){
+ clearTimeout( this.scrollerRefreshTimeout )
+ this.scrollerRefreshTimeout = setTimeout(this.refreshScroller.bind(this))
+ },
+
+ scrollToTop: function(){
+ this.scroller.refresh()
+ this.scroller.scrollTo(0, 0)
+ },
+
+}) \ No newline at end of file