2

How should I do to get the scrolling direction using onScrollStart and not onScrollEnd?

For now, here is the code I found for onScrollEnd :

var current_page = 1; 
var old_page = 0; 

funnction load() {
    myScrollH = new iScroll('wrapper', {
        onScrollEnd: function () {
            current_page = this.currPageX+1 
            if(old_page<current_page) { 
                console.log('right');
            } 
            else if (old_page>current_page) { 
                console.log('left');
            };
            old_page=current_page; 
        }
    })
};

load();

If someone has the answer... Tchuss ! V.

Jeremy D
  • 4,787
  • 1
  • 31
  • 38

1 Answers1

0

During onScrollStart, the event Scroll is not fired. So its not possible (i think) to implement the same.

Only on onScrollEnd, the Scroll Event is fired which has the direction.

Vijay Sarin
  • 1,326
  • 1
  • 11
  • 31
  • Can you Tell me why you need it on start event? – Vijay Sarin Mar 15 '12 at 07:18
  • To find out where someone is scrolling to. If there are for example 3 blocks on the page called A,B, and C, and you want to turn B red before it enters the screen, you want to know if someone is on block C and scrolling up, or on block A and scrolling down. – commonpike May 19 '16 at 23:07