Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

victory-zoom-container

Package Overview
Dependencies
Maintainers
2
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

victory-zoom-container - npm Package Compare versions

Comparing version 31.0.2 to 31.1.0

4

es/victory-zoom-container.js

@@ -253,4 +253,4 @@ import _isFunction from "lodash/isFunction";

},
// eslint-disable-next-line max-params
onMouseMove: function (evt, targetProps, eventKey, ctx) {
// eslint-disable-line max-params
if (props.disable) {

@@ -262,4 +262,4 @@ return {};

},
// eslint-disable-next-line max-params
onTouchMove: function (evt, targetProps, eventKey, ctx) {
// eslint-disable-line max-params
if (props.disable) {

@@ -266,0 +266,0 @@ return {};

@@ -44,4 +44,4 @@ import _defaults from "lodash/defaults";

*/
// eslint-disable-next-line max-params
scale: function (currentDomain, evt, props, axis) {
// eslint-disable-line max-params
var _currentDomain = _slicedToArray(currentDomain, 2),

@@ -301,4 +301,4 @@ from = _currentDomain[0],

},
// eslint-disable-next-line max-params, max-statements
onMouseMove: function (evt, targetProps, eventKey, ctx) {
// eslint-disable-line max-params, max-statements
if (targetProps.panning && targetProps.allowPan) {

@@ -354,4 +354,4 @@ var scale = targetProps.scale,

},
// eslint-disable-next-line max-params
onWheel: function (evt, targetProps, eventKey, ctx) {
// eslint-disable-line max-params
if (!targetProps.allowZoom) {

@@ -373,5 +373,5 @@ return undefined;

var resumeAnimation = this.handleAnimation(ctx);
var zoomActive = !this.zoommingOut(evt) // if zoomming in or
var zoomActive = !this.zoommingOut(evt) || // if zoomming in or
// if zoomActive is already set AND user hasn't zoommed out all the way
|| targetProps.zoomActive && !this.checkDomainEquality(originalDomain, lastDomain);
targetProps.zoomActive && !this.checkDomainEquality(originalDomain, lastDomain);
var mutatedProps = {

@@ -378,0 +378,0 @@ domain: currentDomain,

@@ -269,4 +269,4 @@ "use strict";

},
// eslint-disable-next-line max-params
onMouseMove: function (evt, targetProps, eventKey, ctx) {
// eslint-disable-line max-params
if (props.disable) {

@@ -278,4 +278,4 @@ return {};

},
// eslint-disable-next-line max-params
onTouchMove: function (evt, targetProps, eventKey, ctx) {
// eslint-disable-line max-params
if (props.disable) {

@@ -282,0 +282,0 @@ return {};

@@ -56,4 +56,4 @@ "use strict";

*/
// eslint-disable-next-line max-params
scale: function (currentDomain, evt, props, axis) {
// eslint-disable-line max-params
var _currentDomain = _slicedToArray(currentDomain, 2),

@@ -314,4 +314,4 @@ from = _currentDomain[0],

},
// eslint-disable-next-line max-params, max-statements
onMouseMove: function (evt, targetProps, eventKey, ctx) {
// eslint-disable-line max-params, max-statements
if (targetProps.panning && targetProps.allowPan) {

@@ -368,4 +368,4 @@ var scale = targetProps.scale,

},
// eslint-disable-next-line max-params
onWheel: function (evt, targetProps, eventKey, ctx) {
// eslint-disable-line max-params
if (!targetProps.allowZoom) {

@@ -387,5 +387,5 @@ return undefined;

var resumeAnimation = this.handleAnimation(ctx);
var zoomActive = !this.zoommingOut(evt) // if zoomming in or
var zoomActive = !this.zoommingOut(evt) || // if zoomming in or
// if zoomActive is already set AND user hasn't zoommed out all the way
|| targetProps.zoomActive && !this.checkDomainEquality(originalDomain, lastDomain);
targetProps.zoomActive && !this.checkDomainEquality(originalDomain, lastDomain);
var mutatedProps = {

@@ -392,0 +392,0 @@ domain: currentDomain,

{
"name": "victory-zoom-container",
"version": "31.0.2",
"version": "31.1.0",
"description": "Interactive Zoom Component for Victory",

@@ -24,3 +24,3 @@ "keywords": [

"prop-types": "^15.5.8",
"victory-core": "^31.0.2"
"victory-core": "^31.1.0"
},

@@ -27,0 +27,0 @@ "scripts": {

@@ -37,3 +37,3 @@ # VictoryZoomContainer

*default:* `allowPan={true}`
_default:_ `allowPan={true}`

@@ -46,3 +46,3 @@ ### allowZoom

*default:* `allowZoom={true}`
_default:_ `allowZoom={true}`

@@ -55,3 +55,3 @@ ### clipContainerComponent

*example:* `clipContainerComponent={<VictoryClipContainer clipPadding={{top: 10, right: 10}}}/>}`
_example:_ `clipContainerComponent={<VictoryClipContainer clipPadding={{top: 10, right: 10}}}/>}`

@@ -81,3 +81,3 @@ ### disable

*example:* `minimumZoom={{x: 1, y: 0.01}}`
_example:_ `minimumZoom={{x: 1, y: 0.01}}`

@@ -90,3 +90,3 @@ ### onZoomDomainChange

*example:* `onZoomDomainChange={(domain, props) => handleDomainChange(domain, props)}`
_example:_ `onZoomDomainChange={(domain, props) => handleDomainChange(domain, props)}`

@@ -103,7 +103,7 @@ ### zoomDomain

*example:* `zoomDomain={{x: [0, 100]}}`
_example:_ `zoomDomain={{x: [0, 100]}}`
### zoomDimension
`type: "x" || "y" `
`type: "x" || "y"`

@@ -114,5 +114,5 @@ When the `zoomDimension` prop is set, panning and zooming will be restricted to the given dimension

*example:* `zoomDimension="x"`
_example:_ `zoomDimension="x"`
[VictoryContainer]: https://formidable.com/open-source/victory/docs/victory-container
[See an example of a zoomable chart]: https://formidable.com/open-source/victory/guides/brush-and-zoom
[victorycontainer]: https://formidable.com/open-source/victory/docs/victory-container
[see an example of a zoomable chart]: https://formidable.com/open-source/victory/guides/brush-and-zoom

@@ -1,5 +0,2 @@

export {
zoomContainerMixin,
default as VictoryZoomContainer
} from "./victory-zoom-container";
export { zoomContainerMixin, default as VictoryZoomContainer } from "./victory-zoom-container";
export { default as ZoomHelpers, RawZoomHelpers } from "./zoom-helpers";

@@ -6,3 +6,6 @@ import PropTypes from "prop-types";

import {
VictoryContainer, VictoryClipContainer, Data, PropTypes as CustomPropTypes
VictoryContainer,
VictoryClipContainer,
Data,
PropTypes as CustomPropTypes
} from "victory-core";

@@ -12,192 +15,204 @@

export const zoomContainerMixin = (base) => class VictoryZoomContainer extends base {
static displayName = "VictoryZoomContainer";
export const zoomContainerMixin = (base) =>
class VictoryZoomContainer extends base {
static displayName = "VictoryZoomContainer";
static propTypes = {
...VictoryContainer.propTypes,
allowPan: PropTypes.bool,
allowZoom: PropTypes.bool,
clipContainerComponent: PropTypes.element.isRequired,
disable: PropTypes.bool,
downsample: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.number
]),
minimumZoom: PropTypes.shape({
x: PropTypes.number,
y: PropTypes.number
}),
onZoomDomainChange: PropTypes.func,
zoomDimension: PropTypes.oneOf(["x", "y"]),
zoomDomain: PropTypes.shape({
x: CustomPropTypes.domain,
y: CustomPropTypes.domain
})
};
static propTypes = {
...VictoryContainer.propTypes,
allowPan: PropTypes.bool,
allowZoom: PropTypes.bool,
clipContainerComponent: PropTypes.element.isRequired,
disable: PropTypes.bool,
downsample: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]),
minimumZoom: PropTypes.shape({
x: PropTypes.number,
y: PropTypes.number
}),
onZoomDomainChange: PropTypes.func,
zoomDimension: PropTypes.oneOf(["x", "y"]),
zoomDomain: PropTypes.shape({
x: CustomPropTypes.domain,
y: CustomPropTypes.domain
})
};
static defaultProps = {
...VictoryContainer.defaultProps,
clipContainerComponent: <VictoryClipContainer/>,
allowPan: true,
allowZoom: true,
zoomActive: false
};
static defaultProps = {
...VictoryContainer.defaultProps,
clipContainerComponent: <VictoryClipContainer />,
allowPan: true,
allowZoom: true,
zoomActive: false
};
static defaultEvents = (props) => {
return [{
target: "parent",
eventHandlers: {
onMouseDown: (evt, targetProps) => {
return props.disable ? {} : ZoomHelpers.onMouseDown(evt, targetProps);
},
onTouchStart: (evt, targetProps) => {
return props.disable ? {} : ZoomHelpers.onMouseDown(evt, targetProps);
},
onMouseUp: (evt, targetProps) => {
return props.disable ? {} : ZoomHelpers.onMouseUp(evt, targetProps);
},
onTouchEnd: (evt, targetProps) => {
return props.disable ? {} : ZoomHelpers.onMouseUp(evt, targetProps);
},
onMouseLeave: (evt, targetProps) => {
return props.disable ? {} : ZoomHelpers.onMouseLeave(evt, targetProps);
},
onTouchCancel: (evt, targetProps) => {
return props.disable ? {} : ZoomHelpers.onMouseLeave(evt, targetProps);
},
onMouseMove: (evt, targetProps, eventKey, ctx) => { // eslint-disable-line max-params
if (props.disable) {
return {};
static defaultEvents = (props) => {
return [
{
target: "parent",
eventHandlers: {
onMouseDown: (evt, targetProps) => {
return props.disable ? {} : ZoomHelpers.onMouseDown(evt, targetProps);
},
onTouchStart: (evt, targetProps) => {
return props.disable ? {} : ZoomHelpers.onMouseDown(evt, targetProps);
},
onMouseUp: (evt, targetProps) => {
return props.disable ? {} : ZoomHelpers.onMouseUp(evt, targetProps);
},
onTouchEnd: (evt, targetProps) => {
return props.disable ? {} : ZoomHelpers.onMouseUp(evt, targetProps);
},
onMouseLeave: (evt, targetProps) => {
return props.disable ? {} : ZoomHelpers.onMouseLeave(evt, targetProps);
},
onTouchCancel: (evt, targetProps) => {
return props.disable ? {} : ZoomHelpers.onMouseLeave(evt, targetProps);
},
// eslint-disable-next-line max-params
onMouseMove: (evt, targetProps, eventKey, ctx) => {
if (props.disable) {
return {};
}
return ZoomHelpers.onMouseMove(evt, targetProps, eventKey, ctx);
},
// eslint-disable-next-line max-params
onTouchMove: (evt, targetProps, eventKey, ctx) => {
if (props.disable) {
return {};
}
evt.preventDefault();
return ZoomHelpers.onMouseMove(evt, targetProps, eventKey, ctx);
},
// eslint-disable-next-line max-params
onWheel: (evt, targetProps, eventKey, ctx) => {
if (targetProps.allowZoom && !props.disable) {
evt.preventDefault();
}
return props.disable ? {} : ZoomHelpers.onWheel(evt, targetProps, eventKey, ctx);
}
}
return ZoomHelpers.onMouseMove(evt, targetProps, eventKey, ctx);
},
onTouchMove: (evt, targetProps, eventKey, ctx) => { // eslint-disable-line max-params
if (props.disable) {
return {};
}
evt.preventDefault();
return ZoomHelpers.onMouseMove(evt, targetProps, eventKey, ctx);
},
// eslint-disable-next-line max-params
onWheel: (evt, targetProps, eventKey, ctx) => {
if (targetProps.allowZoom && !props.disable) {
evt.preventDefault();
}
return props.disable ? {} : ZoomHelpers.onWheel(evt, targetProps, eventKey, ctx);
}
}
}];
};
];
};
clipDataComponents(children, props) {
const { scale, clipContainerComponent, polar, origin } = props;
const rangeX = scale.x.range();
const rangeY = scale.y.range();
const plottableWidth = Math.abs(rangeX[0] - rangeX[1]);
const plottableHeight = Math.abs(rangeY[0] - rangeY[1]);
const radius = Math.max(...rangeY);
const groupComponent = React.cloneElement(clipContainerComponent, {
clipWidth: plottableWidth,
clipHeight: plottableHeight,
translateX: Math.min(...rangeX),
translateY: Math.min(...rangeY),
polar,
origin: polar ? origin : undefined,
radius: polar ? radius : undefined,
...clipContainerComponent.props
});
return React.Children.toArray(children).map((child) => {
if (!Data.isDataComponent(child)) {
return child;
} else {
return React.cloneElement(child, { groupComponent });
}
});
}
clipDataComponents(children, props) {
const { scale, clipContainerComponent, polar, origin } = props;
const rangeX = scale.x.range();
const rangeY = scale.y.range();
const plottableWidth = Math.abs(rangeX[0] - rangeX[1]);
const plottableHeight = Math.abs(rangeY[0] - rangeY[1]);
const radius = Math.max(...rangeY);
const groupComponent = React.cloneElement(clipContainerComponent, {
clipWidth: plottableWidth,
clipHeight: plottableHeight,
translateX: Math.min(...rangeX),
translateY: Math.min(...rangeY),
polar,
origin: polar ? origin : undefined,
radius: polar ? radius : undefined,
...clipContainerComponent.props
});
return React.Children.toArray(children).map((child) => {
if (!Data.isDataComponent(child)) {
return child;
} else {
return React.cloneElement(child, { groupComponent });
}
});
}
modifyPolarDomain(domain, originalDomain) {
// Only zoom the radius of polar charts. Zooming angles is very confusing
return {
x: originalDomain.x,
y: [0, domain.y[1]]
};
}
modifyPolarDomain(domain, originalDomain) {
// Only zoom the radius of polar charts. Zooming angles is very confusing
return {
x: originalDomain.x,
y: [0, domain.y[1]]
};
}
downsampleZoomData(props, child, domain) {
const { downsample } = props;
downsampleZoomData(props, child, domain) {
const { downsample } = props;
const getData = (childProps) => {
const { data, x, y } = childProps;
const defaultGetData = child.type && isFunction(child.type.getData) ?
child.type.getData : () => undefined;
// skip costly data formatting if x and y accessors are not present
return Array.isArray(data) && !x && !y ? data : defaultGetData(childProps);
};
const getData = (childProps) => {
const { data, x, y } = childProps;
const defaultGetData =
child.type && isFunction(child.type.getData) ? child.type.getData : () => undefined;
// skip costly data formatting if x and y accessors are not present
return Array.isArray(data) && !x && !y ? data : defaultGetData(childProps);
};
const data = getData(child.props);
const data = getData(child.props);
// return undefined if downsample is not run, then default() will replace with child.props.data
if (!downsample || !domain || !data) { return undefined; }
// return undefined if downsample is not run, then default() will replace with child.props.data
if (!downsample || !domain || !data) {
return undefined;
}
const maxPoints = (downsample === true) ? DEFAULT_DOWNSAMPLE : downsample;
const dimension = props.zoomDimension || "x";
const maxPoints = downsample === true ? DEFAULT_DOWNSAMPLE : downsample;
const dimension = props.zoomDimension || "x";
// important: assumes data is ordered by dimension
// get the start and end of the data that is in the current visible domain
let startIndex = data.findIndex((d) => d[dimension] >= domain[dimension][0]);
let endIndex = data.findIndex((d) => d[dimension] > domain[dimension][1]);
// pick one more point (if available) at each end so that VictoryLine, VictoryArea connect
if (startIndex !== 0) { startIndex -= 1; }
if (endIndex !== -1) { endIndex += 1; }
// important: assumes data is ordered by dimension
// get the start and end of the data that is in the current visible domain
let startIndex = data.findIndex((d) => d[dimension] >= domain[dimension][0]);
let endIndex = data.findIndex((d) => d[dimension] > domain[dimension][1]);
// pick one more point (if available) at each end so that VictoryLine, VictoryArea connect
if (startIndex !== 0) {
startIndex -= 1;
}
if (endIndex !== -1) {
endIndex += 1;
}
const visibleData = data.slice(startIndex, endIndex);
const visibleData = data.slice(startIndex, endIndex);
return Data.downsample(visibleData, maxPoints, startIndex);
}
return Data.downsample(visibleData, maxPoints, startIndex);
}
modifyChildren(props) {
const childComponents = React.Children.toArray(props.children);
// eslint-disable-next-line max-statements
return childComponents.map((child) => {
const role = child.type && child.type.role;
const isDataComponent = Data.isDataComponent(child);
const { currentDomain, zoomActive, allowZoom } = props;
const originalDomain = defaults({}, props.originalDomain, props.domain);
const zoomDomain = defaults({}, props.zoomDomain, props.domain);
const cachedZoomDomain = defaults({}, props.cachedZoomDomain, props.domain);
let domain;
if (!ZoomHelpers.checkDomainEquality(zoomDomain, cachedZoomDomain)) {
// if zoomDomain has been changed, use it
domain = zoomDomain;
} else if (allowZoom && !zoomActive) {
// if user has zoomed all the way out, use the child domain
domain = child.props.domain;
} else {
// default: use currentDomain, set by the event handlers
domain = defaults({}, currentDomain, originalDomain);
}
modifyChildren(props) {
const childComponents = React.Children.toArray(props.children);
// eslint-disable-next-line max-statements
return childComponents.map((child) => {
const role = child.type && child.type.role;
const isDataComponent = Data.isDataComponent(child);
const { currentDomain, zoomActive, allowZoom } = props;
const originalDomain = defaults({}, props.originalDomain, props.domain);
const zoomDomain = defaults({}, props.zoomDomain, props.domain);
const cachedZoomDomain = defaults({}, props.cachedZoomDomain, props.domain);
let domain;
if (!ZoomHelpers.checkDomainEquality(zoomDomain, cachedZoomDomain)) {
// if zoomDomain has been changed, use it
domain = zoomDomain;
} else if (allowZoom && !zoomActive) {
// if user has zoomed all the way out, use the child domain
domain = child.props.domain;
} else {
// default: use currentDomain, set by the event handlers
domain = defaults({}, currentDomain, originalDomain);
}
let newDomain = props.polar ? this.modifyPolarDomain(domain, originalDomain) : domain;
if (newDomain && props.zoomDimension) {
// if zooming is restricted to a dimension, don't squash changes to zoomDomain in other dim
newDomain = {
...zoomDomain,
[props.zoomDimension]: newDomain[props.zoomDimension]
};
}
// don't downsample stacked data
const newProps = isDataComponent && role !== "stack" ?
{ domain: newDomain, data: this.downsampleZoomData(props, child, newDomain) } :
{ domain: newDomain };
return React.cloneElement(child, defaults(newProps, child.props));
});
}
let newDomain = props.polar ? this.modifyPolarDomain(domain, originalDomain) : domain;
if (newDomain && props.zoomDimension) {
// if zooming is restricted to a dimension, don't squash changes to zoomDomain in other dim
newDomain = {
...zoomDomain,
[props.zoomDimension]: newDomain[props.zoomDimension]
};
}
// don't downsample stacked data
const newProps =
isDataComponent && role !== "stack"
? {
domain: newDomain,
data: this.downsampleZoomData(props, child, newDomain)
}
: { domain: newDomain };
return React.cloneElement(child, defaults(newProps, child.props));
});
}
// Overrides method in VictoryContainer
getChildren(props) {
const children = this.modifyChildren(props);
return this.clipDataComponents(children, props);
}
};
// Overrides method in VictoryContainer
getChildren(props) {
const children = this.modifyChildren(props);
return this.clipDataComponents(children, props);
}
};
export default zoomContainerMixin(VictoryContainer);

@@ -28,3 +28,4 @@ /*eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2, 1000] }]*/

*/
scale(currentDomain, evt, props, axis) { // eslint-disable-line max-params
// eslint-disable-next-line max-params
scale(currentDomain, evt, props, axis) {
const [from, to] = currentDomain;

@@ -39,3 +40,3 @@ const range = Math.abs(to - from);

const percent = this.getScalePercent(evt, props, axis);
const point = (factor * from) + percent * (factor * range);
const point = factor * from + percent * (factor * range);
const minDomain = this.getMinimumDomain(point, props, axis);

@@ -47,6 +48,9 @@ const [newMin, newMax] = this.getScaledDomain(currentDomain, factor, percent);

];
const domain = Math.abs(minDomain[1] - minDomain[0]) > Math.abs(newDomain[1] - newDomain[0]) ?
minDomain : newDomain;
return Collection.containsDates([fromBound, toBound]) ?
[ new Date(domain[0]), new Date(domain[1]) ] : domain;
const domain =
Math.abs(minDomain[1] - minDomain[0]) > Math.abs(newDomain[1] - newDomain[0])
? minDomain
: newDomain;
return Collection.containsDates([fromBound, toBound])
? [new Date(domain[0]), new Date(domain[1])]
: domain;
},

@@ -57,6 +61,6 @@

const range = Math.abs(to - from);
const diff = range - (range * factor);
const newMin = +from + (diff * percent);
const newMax = +to - (diff * (1 - percent));
return [ Math.min(newMin, newMax), Math.max(newMin, newMax) ];
const diff = range - range * factor;
const newMin = +from + diff * percent;
const newMax = +to - diff * (1 - percent);
return [Math.min(newMin, newMax), Math.max(newMin, newMax)];
},

@@ -70,4 +74,4 @@

const extent = minimumZoom ? minimumZoom[axis] || defaultMin : defaultMin;
const minExtent = point - (extent / 2);
const maxExtent = point + (extent / 2);
const minExtent = point - extent / 2;
const maxExtent = point + extent / 2;
return [

@@ -85,3 +89,3 @@ minExtent > from && minExtent < to ? minExtent : from,

const sign = this.zoommingOut(evt) ? 1 : -1;
// eslint-disable-next-line no-magic-numbers
// eslint-disable-next-line no-magic-numbers
const delta = Math.min(Math.abs(evt.deltaY / 300), 0.5); // TODO: Check scale factor

@@ -122,6 +126,8 @@ return Math.abs(1 + sign * delta);

newDomain = [lowerBound, upperBound];
} else if (lowerBound < fromOriginal) { // Clamp to lower limit
} else if (lowerBound < fromOriginal) {
// Clamp to lower limit
const dx = toCurrent - fromCurrent;
newDomain = [fromOriginal, fromOriginal + dx];
} else if (upperBound > toOriginal) { // Clamp to upper limit
} else if (upperBound > toOriginal) {
// Clamp to upper limit
const dx = toCurrent - fromCurrent;

@@ -132,4 +138,5 @@ newDomain = [toOriginal - dx, toOriginal];

}
return Collection.containsDates(currentDomain) || Collection.containsDates(originalDomain) ?
newDomain.map((val) => new Date(val)) : newDomain;
return Collection.containsDates(currentDomain) || Collection.containsDates(originalDomain)
? newDomain.map((val) => new Date(val))
: newDomain;
},

@@ -149,4 +156,5 @@

getTimer().bypassAnimation();
return isFunction(getTimer().resumeAnimation) ?
() => getTimer().resumeAnimation() : undefined;
return isFunction(getTimer().resumeAnimation)
? () => getTimer().resumeAnimation()
: undefined;
}

@@ -159,9 +167,5 @@ return undefined;

if (zoomDomain && !this.checkDomainEquality(zoomDomain, cachedZoomDomain)) {
return defaults(
{}, zoomDomain, domain
);
return defaults({}, zoomDomain, domain);
}
return defaults(
{}, currentDomain || zoomDomain || originalDomain, domain
);
return defaults({}, currentDomain || zoomDomain || originalDomain, domain);
},

@@ -184,8 +188,10 @@

if (childComponents.length) {
childrenDomain = zoomDimension ?
{ [zoomDimension]: Wrapper.getDomainFromChildren(props, zoomAxis, childComponents) }
: ({
childrenDomain = zoomDimension
? {
[zoomDimension]: Wrapper.getDomainFromChildren(props, zoomAxis, childComponents)
}
: {
x: Wrapper.getDomainFromChildren(props, xAxis, childComponents),
y: Wrapper.getDomainFromChildren(props, yAxis, childComponents)
});
};
}

@@ -202,11 +208,16 @@ return defaults({}, childrenDomain, originalDomain, domain);

const { x, y } = Selection.getSVGEventCoordinates(evt, parentSVG);
return [{
target: "parent",
mutation: () => {
return {
startX: x, startY: y, panning: true, parentSVG,
parentControlledProps: ["domain"]
};
return [
{
target: "parent",
mutation: () => {
return {
startX: x,
startY: y,
panning: true,
parentSVG,
parentControlledProps: ["domain"]
};
}
}
}];
];
},

@@ -218,8 +229,10 @@

}
return [{
target: "parent",
mutation: () => {
return { panning: false };
return [
{
target: "parent",
mutation: () => {
return { panning: false };
}
}
}];
];
},

@@ -231,11 +244,14 @@

}
return [{
target: "parent",
mutation: () => {
return { panning: false };
return [
{
target: "parent",
mutation: () => {
return { panning: false };
}
}
}];
];
},
onMouseMove(evt, targetProps, eventKey, ctx) { // eslint-disable-line max-params, max-statements
// eslint-disable-next-line max-params, max-statements
onMouseMove(evt, targetProps, eventKey, ctx) {
if (targetProps.panning && targetProps.allowPan) {

@@ -258,4 +274,10 @@ const { scale, startX, startY, onZoomDomainChange, zoomDimension, zoomDomain } = targetProps;

const mutatedProps = {
parentControlledProps: ["domain"], startX: x, startY: y, parentSVG,
domain: currentDomain, currentDomain, originalDomain, cachedZoomDomain: zoomDomain,
parentControlledProps: ["domain"],
startX: x,
startY: y,
parentSVG,
domain: currentDomain,
currentDomain,
originalDomain,
cachedZoomDomain: zoomDomain,
zoomActive

@@ -267,7 +289,9 @@ };

}
return [{
target: "parent",
callback: resumeAnimation,
mutation: () => mutatedProps
}];
return [
{
target: "parent",
callback: resumeAnimation,
mutation: () => mutatedProps
}
];
}

@@ -277,3 +301,4 @@ return undefined;

onWheel(evt, targetProps, eventKey, ctx) { // eslint-disable-line max-params
// eslint-disable-next-line max-params
onWheel(evt, targetProps, eventKey, ctx) {
if (!targetProps.allowZoom) {

@@ -292,9 +317,15 @@ return undefined;

const zoomActive = !this.zoommingOut(evt) // if zoomming in or
// if zoomActive is already set AND user hasn't zoommed out all the way
|| (targetProps.zoomActive && !this.checkDomainEquality(originalDomain, lastDomain));
const zoomActive =
!this.zoommingOut(evt) || // if zoomming in or
// if zoomActive is already set AND user hasn't zoommed out all the way
(targetProps.zoomActive && !this.checkDomainEquality(originalDomain, lastDomain));
const mutatedProps = {
domain: currentDomain, currentDomain, originalDomain, cachedZoomDomain: zoomDomain,
parentControlledProps: ["domain"], panning: false, zoomActive
domain: currentDomain,
currentDomain,
originalDomain,
cachedZoomDomain: zoomDomain,
parentControlledProps: ["domain"],
panning: false,
zoomActive
};

@@ -306,7 +337,9 @@

return [{
target: "parent",
callback: resumeAnimation,
mutation: () => mutatedProps
}];
return [
{
target: "parent",
callback: resumeAnimation,
mutation: () => mutatedProps
}
];
}

@@ -313,0 +346,0 @@ };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc