Skip to content

Added hijack scroll function#197

Closed
alex-e-leon wants to merge 1 commit intogoogle-map-react:masterfrom
alex-e-leon:hijackZoom
Closed

Added hijack scroll function#197
alex-e-leon wants to merge 1 commit intogoogle-map-react:masterfrom
alex-e-leon:hijackZoom

Conversation

@alex-e-leon
Copy link
Copy Markdown
Contributor

@alex-e-leon alex-e-leon commented Jul 18, 2016

@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 alex-e-leon changed the title Added hijack zoom function Added hijack scroll function Jul 19, 2016
@alex-e-leon
Copy link
Copy Markdown
Contributor Author

@istarkov Any thoughts on this PR?

@istarkov
Copy link
Copy Markdown
Collaborator

istarkov commented Jul 22, 2016

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.

@istarkov
Copy link
Copy Markdown
Collaborator

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.

@alex-e-leon
Copy link
Copy Markdown
Contributor Author

alex-e-leon commented Jul 26, 2016

@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!

@alex-e-leon
Copy link
Copy Markdown
Contributor Author

@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 alex-e-leon closed this Aug 2, 2016
@istarkov
Copy link
Copy Markdown
Collaborator

istarkov commented Aug 2, 2016

@alex-e-leon It will be great if you make such PR. Thank you!

@lock
Copy link
Copy Markdown

lock bot commented Dec 1, 2019

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 lock bot locked as resolved and limited conversation to collaborators Dec 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants