chrisbateman / impetus

Agnostic utility for adding momentum to anything. It's like iScroll, except not for scrolling. Supports mouse and touch events.
chrisbateman.github.io/impetus
MIT License
487 stars 70 forks source link

Remove scrollbars from swiping surface #20

Open pyrsmk opened 8 years ago

pyrsmk commented 8 years ago

I don't know if it's intended, but I ran into a problem with my Horizon library. I'm listening to several events and Impetus is triggering swipe event even when the mouse is over the scrollbar. I currently fixed this by automatically measuring the scrollbar width and then listening to mousedown/mouseup to know if we're manually scrolling or not.

yckart commented 8 years ago

I think this problem comes not from impetus itself. As I can see, you just attached it to the entire document, try to use another source.

pyrsmk commented 8 years ago

That's the case for Horizon 3 but not for the upcoming Horizon 4. In the next release we'll be able to set any scene we want. So, if we have scrollbars on this scene, for any reason, the problem would be the same, isn't it?

yckart commented 8 years ago

That sounds like a really specific edgecase and is maybe better to handle it in your own library... However, I'm not the maintainer, let's wait what @chrisbateman says.

Btw. there's no need to measure the scrollbar sizes, instead you could just compare the scrollable container with the current clicked target (requires that the scollarea completely fills its parent):

scrollable.addEventListener('mousedown', function(e) {
  var isScrollbar = this === e.target
})
pyrsmk commented 8 years ago

We can't know in advance if the specified scene has scrollbars. Moreover, I just need to disable swiping when the mouse is over a scrollbar, and not a scrollable content. Because my library can listen to scroll events and swipe events at the same time (and many more). So I've got incompatibilities between scroll and swipe because both events are triggered and it shouldn't be the case.

But yeah, let's wait for @chrisbateman 's point of view. For the time, I'll put a fix in my library ^^