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

Pinch zoom: allow fractional zoom #6224

Merged
merged 3 commits into from Dec 9, 2016

Conversation

aAXEe
Copy link
Contributor

@aAXEe aAXEe commented Dec 8, 2016

This adda a parameter keepFractionalZoomLevel to the ol.interaction.PinchZoom constructor so that the user can choose whether to keep the fractional zoom or not.

See #6223

@ahocevar
Copy link
Member

ahocevar commented Dec 8, 2016

Nice! In the spirit of #6113 I'd even say that unconstrained zooming should become the default, and the option to constrain resolutions should be named constrainResolution.

@tschaub
Copy link
Member

tschaub commented Dec 9, 2016

I agree with @ahocevar on the name and the default behavior.

@marcjansen
Copy link
Member

And maybe add a note in the upgrade notes about the changed behaviour and how to reestablish the old one?

@aAXEe aAXEe force-pushed the pinZoom-allowFractionalZoom branch from 42094f6 to 34fb89d Compare December 9, 2016 13:14
@aAXEe
Copy link
Contributor Author

aAXEe commented Dec 9, 2016

I changed the parameter to constrainResolution and the default behavior to keep fractional zooms.

The example now shows how to establish the old behavior with a constrained zoom.

Can I already add a note to the upgrade notes?

@ahocevar
Copy link
Member

ahocevar commented Dec 9, 2016

Thanks @aAXEe. Yes, you can add a note to changelog/upgrade-notes.md, under the ### Next release heading. The release manager will take these notes and copy them to their own file when the release is being cut.

/**
* `true` to zoom to next whole-number zoom after the pinch completes;
* `false` to keep the zoom at an fractional number.
* Default is `false`.
Copy link
Member

Choose a reason for hiding this comment

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

When documenting booleans, just describe the behavior when true (and then identify the default). For example, this could be:

Zoom to the closest integer zoom level after the pinch gesture ends. Default is false.

* @type {boolean}
*/
this.constrainResolution_ = options.constrainResolution ?
options.constrainResolution : false;
Copy link
Member

Choose a reason for hiding this comment

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

I'll see about updating our linter config to catch this. There should be two indents in a multi-line conditional expression. E.g.

var foo = bar ?
    bam : baz;

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, to avoid repeating the variable as the conditional and consequent, this could be:

this.constrainResolution_ = options.constrainResolution || false;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The second one is not only simpler and easier to read .. it also solves the indention problem ;)
Thanks for the notes!

@aAXEe aAXEe force-pushed the pinZoom-allowFractionalZoom branch from f2ec4a3 to 24c7e8f Compare December 9, 2016 16:51
Changes the default behavior of ol.interaction.PinchZoom to keep
the fractional zoom level after the gesture.
The old behavior of zooming to the next whole-number level can be
enforced with the new parameter `constrainResolution`.
@aAXEe aAXEe force-pushed the pinZoom-allowFractionalZoom branch from 24c7e8f to 61ac0c4 Compare December 9, 2016 17:03
@tschaub tschaub merged commit 4ff87a0 into openlayers:master Dec 9, 2016
@tschaub
Copy link
Member

tschaub commented Dec 9, 2016

Thanks for the great contribution @aAXEe!

@aAXEe aAXEe deleted the pinZoom-allowFractionalZoom branch December 9, 2016 17:24
@I-Maps
Copy link

I-Maps commented Apr 11, 2017

This really made a mess out of all my zoom level dependent functions and layer changes. I had to add the new PinchZoom code with constrainResolution set to true to fix it. My comment is that it would probably be better to leave old functionality the as the default on new additions like this. It would be better to let everyone choose to add new code to get new functionality rather than requiring everyone to add code to fix things that get broken if they don't add the new code.

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.

None yet

5 participants