Closed krnlde closed 3 years ago
I was wondering if touching the global environment might have some drawback. We did it for onWheel event, but just because it was the only available option. In general I think that React works well when you use React events avoiding to directly touch browser event. Anyway I like this feature, What if we introduce a flag to selectively subscribe on global scope (your PR) rather than Component scope (AS IS)?
Hey man! Thanks for you feedback :) Personally I have no concerns going to the global environment. In my codes I do it all the time and never had issues (as long as you don't want to support browser <IE11, because of attachEvent
vs addEventListener
). The flag you mentioned sounds great, but is the benefit worth the relatively complex logic for either putting all the events in the document vs. the viewport. Sounds like a lot of code duplication to me. Suggestions?
Hi @krnlde, thanks for your answer. I agree with you when you say that touching the global environment in personal project doesn't make issues, but here is a bit different. This is a library used by a lot of developers and we don't know what browser or spaghetti code are they managing 😄
React gives us a good abstraction from those things. In general I prefer to rely on React as much as possible, but I understand that sometimes we need to break this general rule.
For the onWheel
we did it, but it was required. For other events I prefer to allow the developer to select when use standard React events or global events.
For concerns on code duplication le me say that @TimVanMourik and I are working to provide a new React version based on hooks, so don't worry if you need to copy paste some code, it is going to be refactored as soon as the hooks version is ready.
Thought?
I moved the
mouseMove
andmouseUp
(as well as theirtouch
counterparts) upwards to thedocument
. This way you're able to continue panning even when outside the current viewport. This bugged me the most on this library and I hope to find consent with this.Cheers.