Open rodneyrehm opened 10 years ago
thanks for the heads-up. I'll fix the docs and try to find a solution for the others.
b) actually is how it was at the beginning but I had to remove event loading/unloading because Android really doesn't like it. It was the 2.x time so I don't know if we should still care and honestly I haven't done tests recently. But anyway, that is by design.
I'd much prefer a solution that did the right thing by default and changed behavior when necessary. It doesn't make your code any simpler, but it segments "bad behavior". I don't like polluting modern browsers who get things right with crap we have to throw at old browsers that barely deserve the name.
cheers :)
I just lost a couple of hours figuring out why scrolling a non-IScroll panel would trigger a
click
where it shouldn't have. It turns out IScroll binds listeners towindow
unless told to contain itself to a specific region usingbindToWrapper: true
.The docs specifically talk about the
move
event being bound to thedocument
. In reality much many more events (mousemove, mousecancel, mouseup, MSPointerMove, MSPointerCancel, MSPointerUp, touchmove, touchcancel, touchend) are bound towindow
.I have multiple IScroll instances in off-viewport elements. The main document scrolls natively. because I use
click: true
in my IScroll instances, anytouchcancel
is caught by one of the IScrolls and aclick
event is fired. Right now the only solution is to either not useclick: true
, or make sure all IScrolls havebindToWrapper: true
. The former is impossible, the latter annoying because scrolling stops once you leave the wrapper element.a) the docs should reflect the reality of IScroll's event binding b) I think the
*move
,*cancel
,*up
event handlers should be bound onmousedown
,MSPointerDown
,touchstart
respectively (and cleaned up after move/cancel/up) to make sure that IScroll cannot mess with the page's content outside its domain. c) If persistent global events (liketouchcancel
onwindow
) are used, think about binding one listener and have it delegate to the proper IScroll instance instead of binding a listener for each instance. That would also prevent accidental handling of events