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

Fix zoom-function #5028

Merged
merged 3 commits into from
Jul 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/style-spec/function/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ function interpolationFactor(input, base, lowerValue, upperValue) {
const difference = upperValue - lowerValue;
const progress = input - lowerValue;

if (base === 1) {
if (difference === 0) {
return 0;
} else if (base === 1) {
return progress / difference;
} else {
return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);
Expand Down
6 changes: 3 additions & 3 deletions test/unit/style-spec/function.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ test('binary search', (t) => {
type: 'number',
function: 'interpolated'
});
// Nan because the interpolation will fail when given to stops with the same value.
// This is however more desirable than looping forever.
t.equal(isNaN(f(17)), true);

t.equal(f(17), 11);

t.end();
});
t.end();
Expand Down