Brad
Brad

Reputation: 10660

jQuery - Detect scroll amount

On mobile devices, if there is a list of items and the user touches one, it is highlighted to indicate the user is touching it. However once the user begins to scroll (swipe up or down), the highlight disappears so the user knows they are not going to activate the button anymore when they release their finger.

I want to do something similar on a mobile, so I need to detect when the element is scrolled so I remove the highlight on the list item. However, the jquery scroll event seems to be fired at the same time as the touchbegin, not when the element is actually scrolled. So in order for this to work, I'll need to detect a few pixels of scrolling before removing the highlighting. What is the best way for me to achieve this?

Upvotes: 1

Views: 186

Answers (1)

Brad
Brad

Reputation: 10660

I found a solution, the touchcancel event works perfectly since it is fired when scrolling begins.

Upvotes: 2

Related Questions