UNPKG

recharts

Version:
41 lines (39 loc) • 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.zoomSettingsReducer = exports.setZoomLimits = exports.setZoomAxis = void 0; var _toolkit = require("@reduxjs/toolkit"); /** * Chart-level zoom configuration shared across zoom consumers. * * The geometric state (the viewport itself) lives in the `zoom` slice; this one holds the * configuration registered by the chart's zoom setup (`<ZoomAndPan />` or the `zoom` prop), so * window editors that come with their own defaults - Brush zoom mode, Minimap - can fall back to * the chart-wide `minZoom`/`maxZoom` instead of silently using different limits. */ var initialState = { limits: null, axis: null }; var zoomSettingsSlice = (0, _toolkit.createSlice)({ name: 'zoomSettings', initialState, reducers: { setZoomLimits(state, action) { var _state$limits, _state$limits2; var next = action.payload; if (((_state$limits = state.limits) === null || _state$limits === void 0 ? void 0 : _state$limits.minZoom) === (next === null || next === void 0 ? void 0 : next.minZoom) && ((_state$limits2 = state.limits) === null || _state$limits2 === void 0 ? void 0 : _state$limits2.maxZoom) === (next === null || next === void 0 ? void 0 : next.maxZoom)) { return; } state.limits = next; }, setZoomAxis(state, action) { state.axis = action.payload; } } }); var _zoomSettingsSlice$ac = zoomSettingsSlice.actions, setZoomAxis = exports.setZoomAxis = _zoomSettingsSlice$ac.setZoomAxis, setZoomLimits = exports.setZoomLimits = _zoomSettingsSlice$ac.setZoomLimits; var zoomSettingsReducer = exports.zoomSettingsReducer = zoomSettingsSlice.reducer;