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

Use fallback configration for scale types #454

Merged
merged 1 commit into from
Apr 16, 2021
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
6 changes: 4 additions & 2 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ function storeOriginalOptions(chart) {
}

function zoomScale(scale, zoom, center, zoomOptions) {
call(zoomFunctions[scale.type], [scale, zoom, center, zoomOptions]);
const fn = zoomFunctions[scale.type] || zoomFunctions.default;
call(fn, [scale, zoom, center, zoomOptions]);
}

/**
Expand Down Expand Up @@ -89,7 +90,8 @@ export function resetZoom(chart) {
}

function panScale(scale, delta, panOptions) {
call(panFunctions[scale.type], [scale, delta, panOptions]);
const fn = panFunctions[scale.type] || panFunctions.default;
call(fn, [scale, delta, panOptions]);
}

export function doPan(chart, deltaX, deltaY, panOptions, panningScales) {
Expand Down
8 changes: 2 additions & 6 deletions src/scale.types.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,10 @@ function panNumericalScale(scale, delta, panOptions) {

export const zoomFunctions = {
category: zoomCategoryScale,
time: zoomNumericalScale,
linear: zoomNumericalScale,
logarithmic: zoomNumericalScale,
default: zoomNumericalScale,
};

export const panFunctions = {
category: panCategoryScale,
time: panNumericalScale,
linear: panNumericalScale,
logarithmic: panNumericalScale,
default: panNumericalScale,
};