Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile experience improvements #169

Merged
merged 3 commits into from
Sep 5, 2017

Conversation

gregallensworth
Copy link
Contributor

This PR improves the behavior of leaflet-control-geocoder on mobile. Testing is on iOS using iPhone 6 and iPad 2nd-gen.

  • options.expand supports a new value: touch This will use touchstart instead of click for a faster response when trying to expand the control from a collapsed state.

    • This is a new option, and not a coded-in behavior of expand: 'click' if L.Browser.touch is detected. Could go either way; adding a new option seemed best for compatibility and fewest question marks.
    • Interesting note: On iOS, the touchstart needs to be stopped or else it triggers the icon to become focused. By defocusing the input, the UI immediately collapses...
  • _collapse() adds a _input.blur() so that on mobile the keyboard will be dismissed.

  • Tapping the icon when collapse: false was given, now uses touchstart if L.browser.touch was selected, so the geocoding happens with less delay.

  • Some trivial cleanups to the className editing code, to use L.DomUtil.removeClass and L.DomUtil.hasClass in a few spots.

Copy link
Owner

@perliedman perliedman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi and thanks for this!

I've looked quickly at this, and it looks great. A much needed improvement, I think.

I'm considering if this (touch) shouldn't rather be the default? Do you see any possible downsides from this, except for maybe slightly changed behavior for som apps?

I noted that you have indented using spaces, while the rest of the code use tabs for indentation. If you can just fix that, I think is good to merge from my point of view.

@gregallensworth
Copy link
Contributor Author

Right-o. A new pair of commits:

  • indentation changed from spaces to tabs
  • expand is now documented in README
  • expand defaults to touch as I agree that I can't see any downside to using it with regular clicks, especially now that it's documented in case someone doesn't like it

@perliedman perliedman merged commit f528ff1 into perliedman:master Sep 5, 2017
@perliedman
Copy link
Owner

Awesome! Thanks again.

I'll try to get a new release out soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants