ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject incubator-ponymail git commit: try utilizing a timeout to better scroll
Date Mon, 05 Sep 2016 09:27:13 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/coffee-and-cake 97de334cc -> 87d0f3d3c


try utilizing a timeout to better scroll

we set a timer that only fires after scrolling has stopped,
and then determines in which direction to go.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/87d0f3d3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/87d0f3d3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/87d0f3d3

Branch: refs/heads/coffee-and-cake
Commit: 87d0f3d3c6543ac226c5a0b2eaca232c9d96293a
Parents: 97de334
Author: Daniel Gruno <humbedooh@apache.org>
Authored: Mon Sep 5 11:26:59 2016 +0200
Committer: Daniel Gruno <humbedooh@apache.org>
Committed: Mon Sep 5 11:26:59 2016 +0200

----------------------------------------------------------------------
 site/js/coffee/listview_basic.coffee | 25 ++++++++++++++----------
 site/js/ponymail-coffee.js           | 32 ++++++++++++++++++-------------
 2 files changed, 34 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/87d0f3d3/site/js/coffee/listview_basic.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/listview_basic.coffee b/site/js/coffee/listview_basic.coffee
index 2e20235..d472b26 100644
--- a/site/js/coffee/listview_basic.coffee
+++ b/site/js/coffee/listview_basic.coffee
@@ -245,11 +245,11 @@ class BasicListView
     ### swipe: go to next or previous page of emails, depending on mouse wheel direction
###
     swipe: (e) ->
         @lastSwipe = @lastSwipe || 0
-        direction = ""
+        @direction = ""
         if typeof e is 'string'
-            direction = e
+            @direction = e
         else
-            direction = if ((e.wheelDelta || -e.detail) < 0) then 'down' else 'up'
+            @direction = if ((e.wheelDelta || -e.detail) < 0) then 'down' else 'up'
         style = document.body.currentStyle || window.getComputedStyle(document.body, "")
         
         ### Use the footer to determine whether scrollbar is present or not ###
@@ -260,17 +260,22 @@ class BasicListView
         if ponymail_email_open.length > 0 or scrollBar
             return
         
-        ### Make sure we don't swipe too fast! ###
-        now = new Date().getTime()
-        if (now - @lastSwipe) < 100
-            return
+        ### set scroll to happen 50ms from now ###
+        if @scrollTimer
+            clearTimeout(@scrollTimer)
+            @scrollTimer = null
+        
+        me = this
+        @scrollTimer = window.setTimeout( () ->
+            me.swipeDirection()
+        , 50)
         
-        if direction == 'down'
+    swipeDirection: () ->
+        if @direction == 'down'
             ### Next page? ###
             if @listsize > (@pos+@rpp+1)
                 @scroll(@rpp, @pos+@rpp)
-        else if direction == 'up'
+        else if @direction == 'up'
             ### Previous page? ###
             if @pos > 0
                 @scroll(@rpp, Math.max(0,@pos-@rpp))
-        @lastSwipe = now
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/87d0f3d3/site/js/ponymail-coffee.js
----------------------------------------------------------------------
diff --git a/site/js/ponymail-coffee.js b/site/js/ponymail-coffee.js
index 525ed91..d8ba39a 100644
--- a/site/js/ponymail-coffee.js
+++ b/site/js/ponymail-coffee.js
@@ -1533,13 +1533,13 @@ BasicListView = (function() {
   /* swipe: go to next or previous page of emails, depending on mouse wheel direction */
 
   BasicListView.prototype.swipe = function(e) {
-    var direction, now, obj, scrollBar, style;
+    var me, obj, scrollBar, style;
     this.lastSwipe = this.lastSwipe || 0;
-    direction = "";
+    this.direction = "";
     if (typeof e === 'string') {
-      direction = e;
+      this.direction = e;
     } else {
-      direction = (e.wheelDelta || -e.detail) < 0 ? 'down' : 'up';
+      this.direction = (e.wheelDelta || -e.detail) < 0 ? 'down' : 'up';
     }
     style = document.body.currentStyle || window.getComputedStyle(document.body, "");
 
@@ -1552,25 +1552,31 @@ BasicListView = (function() {
       return;
     }
 
-    /* Make sure we don't swipe too fast! */
-    now = new Date().getTime();
-    if ((now - this.lastSwipe) < 100) {
-      return;
+    /* set scroll to happen 50ms from now */
+    if (this.scrollTimer) {
+      clearTimeout(this.scrollTimer);
+      this.scrollTimer = null;
     }
-    if (direction === 'down') {
+    me = this;
+    return this.scrollTimer = window.setTimeout(function() {
+      return me.swipeDirection();
+    }, 50);
+  };
+
+  BasicListView.prototype.swipeDirection = function() {
+    if (this.direction === 'down') {
 
       /* Next page? */
       if (this.listsize > (this.pos + this.rpp + 1)) {
-        this.scroll(this.rpp, this.pos + this.rpp);
+        return this.scroll(this.rpp, this.pos + this.rpp);
       }
-    } else if (direction === 'up') {
+    } else if (this.direction === 'up') {
 
       /* Previous page? */
       if (this.pos > 0) {
-        this.scroll(this.rpp, Math.max(0, this.pos - this.rpp));
+        return this.scroll(this.rpp, Math.max(0, this.pos - this.rpp));
       }
     }
-    return this.lastSwipe = now;
   };
 
   return BasicListView;


Mime
View raw message