darsain / sly

JavaScript library for one-directional scrolling with item based navigation support.
http://darsa.in/sly
2.87k stars 497 forks source link

iPhone-like scroll-tick event #215

Closed kluplau closed 9 years ago

kluplau commented 9 years ago

I was wondering if it is possible to get an event each time an item is passed? Think of the iPhone calendar scroll-list, where it fires a tick-sound each time an item is centered.

I thought that the cycle-event was what I was looking for, but I guess it's not.

darsain commented 9 years ago

There isn't an event that does this, and I don't think I'll be adding it. Things like this are I think in a definition of feature creep :) which Sly is already very guilty of.

But! you can implement it with existing API.

Listen for move event, which fires every time a movement frame is rendered (synced with requestAnimationFrame), and inside it, check sly.rel object, which has useful properties like firstItem (first visible item in a frame), lastItem (last visible), etc.

Than just cache the index of a desired property, and fire an event when it changes.

kluplau commented 9 years ago

Okay, totally understand you... Great, I will look into that... thanks! :+1: