0

I've been trying to find a way to keep track of which page the scrollview is on. Here's my scrollview:

var scrollview = new Scrollview({
    direction:1,
    paginated:true
});

scrollview.sequenceFrom(surfaces);

I couldn't find anything, so as a last resort, I was thinking of calculating the index with getPosition :

scrollview.sync.on('end', function() {

    var position = scrollview.getPosition();
    ...

});

But the values returned are strange:

135.99973778400908
127.17900173310437
79.18730021387734
119.25586098115863
119.13859297279127
142.1383322620501
81.44664852586043
95.12230013491089 

There's no sequence to them, even if I set the index of an item to track getPosition(0). So I can't really use this.

Is there any way to get the index of the current "page" of the scrollview when paginated is true?

jamwise
  • 165
  • 1
  • 1
  • 10

2 Answers2

0

I hadn't realized famo.us is still under so much development. Apparently the scrollview was all kinds of broken and is a lot of it is getting fixed in v0.3.0 which is due soon:

link to changelog here

So the indexing feature is added in this version and won't need any kind of workaround.

jamwise
  • 165
  • 1
  • 1
  • 10
0

In the current release candidate v0.3.0-rc, you can get the current (node) page index. The code below shows how this can be done at the settling of transition to the page in the scrollview. This may change, because Famo.us is in beta at the time of this writing.

Here is the example code

scrollview.on('settle', function() {
  var pageIndex = scrollview.getCurrentIndex();
  page.setContent('Page ' + (pageIndex+1));
});
talves
  • 13,993
  • 5
  • 40
  • 63