Added hijack scroll function by alex-e-leon · Pull Request #197 · google-map-react/google-map-react
@istarkov I've added a hijack scroll function that allows you to manipulate the scroll event
I couldn't find any PR instructions so please let me know if there's any issues or if you'd like me for example to write tests.
Example uses:
- You'd like to zoom only multiples of 2 on scroll
- Implement a custom info-window (see Info Windows #180) or any other component that has a scroll bar. This is my use-case - I use this function to hijack the scroll event and then zoom only if I'm not inside a scrollable component.
Also note that I've added some example functions into the demo files to show how it works, but because the demo maps call setMapParams on onChange events you don't get a smooth zoom change but instead get a slightly slower zoom change from changing the zoom props.
I can remove these from the demo if you like but thought it might be useful for you to test.
alex-e-leon
changed the title
Added hijack zoom function
Added hijack scroll function
Thank you for contribution, IMO this must be done in the other not so hackable way.
You'd like to zoom only multiples of 2 on scroll
Why? Im sure no one need this.
Implement a custom info-window ...
It is the case, and it is almost the same case as for draggable map propery.
When I create draggable markers, I need to disable map drag when I hover over the marker.
Here when I create info window with scroll, all I need is just disable scroll on the map.
I think all I need is just to allow options property to be dynamic (now options are readed at the start), so this be enough to solve your case.
PS: I'm on vacation now for next week or two, so I can answer fast only on simple issues and PRs as most time I use mobile phone for reading this.
@istarkov Ah yeap, I agree, that's a better solution in some respects, though I think it has the implication of requiring one to move the logic to mouseEnter + mouseLeave (since otherwise by the time you try to catch the scroll event, it will have already propogated to gMaps so turning it off does nothing)
The frustrating thing about this, is that googleMaps has no support for mouseOver/mouseOut, just mouseEnter/mouseLeave which means these events trigger will trigger frequently as you move over a popup
Enjoy your vacation!
@istarkov is the dynamic options something you're currently working on already? Otherwise, I might have a go at implementing it and submitting a new PR.
@alex-e-leon It will be great if you make such PR. Thank you!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
lock
bot
locked as resolved and limited conversation to collaborators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters