BloonsTowerDefence
BloonsTowerDefence

Reputation: 1204

Scrollview that 'snaps' from view to view

The default behavior for a scroll seems to be to scroll with no resistance, i.e. if you swipe really hard then you can zoom through a lot of views. Is there a mechanism I can use so that when you swipe (no matter how hard), you will just snap to the next view? Maybe a scrollview isn't the best way to achieve this.

Here is roughly what I have: its just a regular scrollview with some surfces added in.

    var challenges = [];
    var scrollview = new Scrollview({
        direction: 0,
        properties: { overflow: 'hidden' }
    });

    scrollview.sequenceFrom(challenges);

    for (var i = 0; i < 5; i++){
        var s = new Surface());
        s.pipe(scrollview);
    }

Upvotes: 0

Views: 115

Answers (1)

johntraver
johntraver

Reputation: 3612

Yes.. check out the paginated option of scrollview. Paginated allows you to break up a scrollview in discrete chunks. Should do exactly what you need it to!

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

For a full example, check out my answer here!

How to Swipe between surfaces in Famo.us?

Good luck!

Upvotes: 1

Related Questions