Socket
Socket
Sign inDemoInstall

@visx/drag

Package Overview
Dependencies
11
Maintainers
4
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.10.0 to 2.17.0-alpha.0

35

esm/Drag.js
import _pt from "prop-types";
/* eslint-disable react/jsx-handler-names */

@@ -8,19 +7,19 @@ import React from 'react';

var _ref$captureDragArea = _ref.captureDragArea,
captureDragArea = _ref$captureDragArea === void 0 ? true : _ref$captureDragArea,
_ref$snapToPointer = _ref.snapToPointer,
snapToPointer = _ref$snapToPointer === void 0 ? true : _ref$snapToPointer,
children = _ref.children,
dx = _ref.dx,
dy = _ref.dy,
height = _ref.height,
onDragEnd = _ref.onDragEnd,
onDragMove = _ref.onDragMove,
onDragStart = _ref.onDragStart,
resetOnStart = _ref.resetOnStart,
width = _ref.width,
x = _ref.x,
y = _ref.y,
isDragging = _ref.isDragging,
restrict = _ref.restrict,
restrictToPath = _ref.restrictToPath;
captureDragArea = _ref$captureDragArea === void 0 ? true : _ref$captureDragArea,
_ref$snapToPointer = _ref.snapToPointer,
snapToPointer = _ref$snapToPointer === void 0 ? true : _ref$snapToPointer,
children = _ref.children,
dx = _ref.dx,
dy = _ref.dy,
height = _ref.height,
onDragEnd = _ref.onDragEnd,
onDragMove = _ref.onDragMove,
onDragStart = _ref.onDragStart,
resetOnStart = _ref.resetOnStart,
width = _ref.width,
x = _ref.x,
y = _ref.y,
isDragging = _ref.isDragging,
restrict = _ref.restrict,
restrictToPath = _ref.restrictToPath;
var drag = useDrag({

@@ -27,0 +26,0 @@ resetOnStart: resetOnStart,

@@ -1,3 +0,2 @@

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import { useCallback, useEffect, useRef, useState } from 'react';

@@ -9,22 +8,20 @@ import { Point, subtractPoints, sumPoints } from '@visx/point';

import useSamplesAlongPath from './util/useSamplesAlongPath';
/** Hook for dragging, returns a `UseDrag` object. */
export default function useDrag(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$resetOnStart = _ref.resetOnStart,
resetOnStart = _ref$resetOnStart === void 0 ? false : _ref$resetOnStart,
_ref$snapToPointer = _ref.snapToPointer,
snapToPointer = _ref$snapToPointer === void 0 ? true : _ref$snapToPointer,
onDragEnd = _ref.onDragEnd,
onDragMove = _ref.onDragMove,
onDragStart = _ref.onDragStart,
x = _ref.x,
y = _ref.y,
dx = _ref.dx,
dy = _ref.dy,
isDragging = _ref.isDragging,
_ref$restrict = _ref.restrict,
restrict = _ref$restrict === void 0 ? {} : _ref$restrict,
restrictToPath = _ref.restrictToPath;
_ref$resetOnStart = _ref.resetOnStart,
resetOnStart = _ref$resetOnStart === void 0 ? false : _ref$resetOnStart,
_ref$snapToPointer = _ref.snapToPointer,
snapToPointer = _ref$snapToPointer === void 0 ? true : _ref$snapToPointer,
onDragEnd = _ref.onDragEnd,
onDragMove = _ref.onDragMove,
onDragStart = _ref.onDragStart,
x = _ref.x,
y = _ref.y,
dx = _ref.dx,
dy = _ref.dy,
isDragging = _ref.isDragging,
_ref$restrict = _ref.restrict,
restrict = _ref$restrict === void 0 ? {} : _ref$restrict,
restrictToPath = _ref.restrictToPath;
// use ref to detect prop changes

@@ -37,22 +34,21 @@ var positionPropsRef = useRef({

});
var _useStateWithCallback = useStateWithCallback({
x: x,
y: y,
dx: dx != null ? dx : 0,
dy: dy != null ? dy : 0,
isDragging: false
}),
dragState = _useStateWithCallback[0],
setDragStateWithCallback = _useStateWithCallback[1]; // Track distance between pointer on dragStart and position of element being dragged
x: x,
y: y,
dx: dx != null ? dx : 0,
dy: dy != null ? dy : 0,
isDragging: false
}),
dragState = _useStateWithCallback[0],
setDragStateWithCallback = _useStateWithCallback[1];
// Track distance between pointer on dragStart and position of element being dragged
var _useState = useState(new Point({
x: 0,
y: 0
})),
dragStartPointerOffset = _useState[0],
setDragStartPointerOffset = _useState[1]; // if prop position changes, update state
x: 0,
y: 0
})),
dragStartPointerOffset = _useState[0],
setDragStartPointerOffset = _useState[1];
// if prop position changes, update state
useEffect(function () {

@@ -91,7 +87,7 @@ if (positionPropsRef.current.x !== x || positionPropsRef.current.y !== y || positionPropsRef.current.dx !== dx || positionPropsRef.current.dy !== dy) {

var _currState$x = currState.x,
x = _currState$x === void 0 ? 0 : _currState$x,
_currState$y = currState.y,
y = _currState$y === void 0 ? 0 : _currState$y,
dx = currState.dx,
dy = currState.dy;
x = _currState$x === void 0 ? 0 : _currState$x,
_currState$y = currState.y,
y = _currState$y === void 0 ? 0 : _currState$y,
dx = currState.dx,
dy = currState.dy;
var currentPoint = new Point({

@@ -124,8 +120,8 @@ x: (x || 0) + dx,

setDragStateWithCallback(function (currState) {
if (!currState.isDragging) return currState; // eslint-disable-next-line no-shadow
if (!currState.isDragging) return currState;
// eslint-disable-next-line no-shadow
var _currState$x2 = currState.x,
x = _currState$x2 === void 0 ? 0 : _currState$x2,
_currState$y2 = currState.y,
y = _currState$y2 === void 0 ? 0 : _currState$y2;
x = _currState$x2 === void 0 ? 0 : _currState$x2,
_currState$y2 = currState.y,
y = _currState$y2 === void 0 ? 0 : _currState$y2;
var pointerPoint = localPoint(event) || new Point({

@@ -132,0 +128,0 @@ x: 0,

function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
/** Gets closest point from list of points */

@@ -11,7 +8,5 @@ export default function getClosestPoint(point, samples) {

var minDistance = Infinity;
for (var _iterator = _createForOfIteratorHelperLoose(samples), _step; !(_step = _iterator()).done;) {
var sample = _step.value;
var distance = Math.sqrt(Math.pow(sample.x - point.x, 2) + Math.pow(sample.y - point.y, 2));
if (distance < minDistance) {

@@ -25,4 +20,3 @@ minDistance = distance;

}
return closestPoint;
}

@@ -5,8 +5,6 @@ /** Given at an array of items, moves the item at the specified index to the end of the array. */

var lastIndex = array.length - 1;
var _array$splice = array.splice(raiseIndex, 1),
raiseItem = _array$splice[0];
raiseItem = _array$splice[0];
array.splice(lastIndex, 0, raiseItem);
return array;
}
import clampNumber from './clampNumber';
import getClosestPoint from './getClosestPoint';
/** Restrict a point to an area, or samples along a path. */
export default function restrictPoint(point, samples, restrict) {
var _restrict$xMin, _restrict$xMax, _restrict$yMin, _restrict$yMax;
if (restrict === void 0) {
restrict = {};
}
if (samples.length > 0) {
return getClosestPoint(point, samples);
}
return {

@@ -17,0 +14,0 @@ x: clampNumber(point.x, (_restrict$xMin = restrict.xMin) != null ? _restrict$xMin : -Infinity, (_restrict$xMax = restrict.xMax) != null ? _restrict$xMax : Infinity),

@@ -1,3 +0,2 @@

import React, { useMemo } from 'react';
import { useMemo } from 'react';
function getSamples(restrictToPath, transform, precision) {

@@ -7,7 +6,5 @@ if (precision === void 0) {

}
if (!restrictToPath) return [];
var samples = [];
var pathLength = restrictToPath.getTotalLength();
for (var sampleLength = 0; sampleLength <= pathLength; sampleLength += precision) {

@@ -18,8 +15,6 @@ var sample = restrictToPath.getPointAtLength(sampleLength);

}
return samples;
}
/** Return samples along a path, relative to the parent SVG */
export default function useSamplesAlongPath(restrictToPath) {

@@ -29,3 +24,4 @@ var samples = useMemo(function () {

var transform = restrictToPath.getCTM() || new DOMMatrix();
return getSamples(restrictToPath, transform); // The path can transform without triggering a re-render,
return getSamples(restrictToPath, transform);
// The path can transform without triggering a re-render,
// so we need to update the samples whenever the length changes.

@@ -32,0 +28,0 @@ // eslint-disable-next-line react-hooks/exhaustive-deps

@@ -1,9 +0,7 @@

import React, { useCallback, useLayoutEffect, useRef, useState } from 'react';
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
/** A hook that exposes a setState(state, callback) API similar to a component class. */
export default function useStateWithCallback(initialState) {
var _useState = useState(initialState),
state = _useState[0],
setState = _useState[1];
state = _useState[0],
setState = _useState[1];
var callbackRef = useRef(null);

@@ -13,4 +11,5 @@ var setStateCallback = useCallback(function (nextState, callback) {

setState(nextState);
}, [setState]); // if we use useEffect, some callback invocations are skipped
}, [setState]);
// if we use useEffect, some callback invocations are skipped
useLayoutEffect(function () {

@@ -17,0 +16,0 @@ // `null` on initial render, so we only execute callback on state *updates*

@@ -5,31 +5,27 @@ "use strict";

exports.default = Drag;
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _useDrag = _interopRequireDefault(require("./useDrag"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* eslint-disable react/jsx-handler-names */
/* eslint-disable react/jsx-handler-names */
function Drag(_ref) {
var _ref$captureDragArea = _ref.captureDragArea,
captureDragArea = _ref$captureDragArea === void 0 ? true : _ref$captureDragArea,
_ref$snapToPointer = _ref.snapToPointer,
snapToPointer = _ref$snapToPointer === void 0 ? true : _ref$snapToPointer,
children = _ref.children,
dx = _ref.dx,
dy = _ref.dy,
height = _ref.height,
onDragEnd = _ref.onDragEnd,
onDragMove = _ref.onDragMove,
onDragStart = _ref.onDragStart,
resetOnStart = _ref.resetOnStart,
width = _ref.width,
x = _ref.x,
y = _ref.y,
isDragging = _ref.isDragging,
restrict = _ref.restrict,
restrictToPath = _ref.restrictToPath;
captureDragArea = _ref$captureDragArea === void 0 ? true : _ref$captureDragArea,
_ref$snapToPointer = _ref.snapToPointer,
snapToPointer = _ref$snapToPointer === void 0 ? true : _ref$snapToPointer,
children = _ref.children,
dx = _ref.dx,
dy = _ref.dy,
height = _ref.height,
onDragEnd = _ref.onDragEnd,
onDragMove = _ref.onDragMove,
onDragStart = _ref.onDragStart,
resetOnStart = _ref.resetOnStart,
width = _ref.width,
x = _ref.x,
y = _ref.y,
isDragging = _ref.isDragging,
restrict = _ref.restrict,
restrictToPath = _ref.restrictToPath;
var drag = (0, _useDrag.default)({

@@ -58,3 +54,2 @@ resetOnStart: resetOnStart,

}
Drag.propTypes = {

@@ -61,0 +56,0 @@ children: _propTypes.default.func.isRequired,

"use strict";
exports.__esModule = true;
exports.raise = exports.useDrag = exports.Drag = void 0;
exports.useDrag = exports.raise = exports.Drag = void 0;
var _Drag = _interopRequireDefault(require("./Drag"));
exports.Drag = _Drag.default;
var _useDrag = _interopRequireDefault(require("./useDrag"));
exports.useDrag = _useDrag.default;
var _raise = _interopRequireDefault(require("./util/raise"));
exports.raise = _raise.default;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -5,38 +5,28 @@ "use strict";

exports.default = useDrag;
var _react = require("react");
var _point = require("@visx/point");
var _event = require("@visx/event");
var _useStateWithCallback2 = _interopRequireDefault(require("./util/useStateWithCallback"));
var _restrictPoint = _interopRequireDefault(require("./util/restrictPoint"));
var _useSamplesAlongPath = _interopRequireDefault(require("./util/useSamplesAlongPath"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
/** Hook for dragging, returns a `UseDrag` object. */
function useDrag(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$resetOnStart = _ref.resetOnStart,
resetOnStart = _ref$resetOnStart === void 0 ? false : _ref$resetOnStart,
_ref$snapToPointer = _ref.snapToPointer,
snapToPointer = _ref$snapToPointer === void 0 ? true : _ref$snapToPointer,
onDragEnd = _ref.onDragEnd,
onDragMove = _ref.onDragMove,
onDragStart = _ref.onDragStart,
x = _ref.x,
y = _ref.y,
dx = _ref.dx,
dy = _ref.dy,
isDragging = _ref.isDragging,
_ref$restrict = _ref.restrict,
restrict = _ref$restrict === void 0 ? {} : _ref$restrict,
restrictToPath = _ref.restrictToPath;
_ref$resetOnStart = _ref.resetOnStart,
resetOnStart = _ref$resetOnStart === void 0 ? false : _ref$resetOnStart,
_ref$snapToPointer = _ref.snapToPointer,
snapToPointer = _ref$snapToPointer === void 0 ? true : _ref$snapToPointer,
onDragEnd = _ref.onDragEnd,
onDragMove = _ref.onDragMove,
onDragStart = _ref.onDragStart,
x = _ref.x,
y = _ref.y,
dx = _ref.dx,
dy = _ref.dy,
isDragging = _ref.isDragging,
_ref$restrict = _ref.restrict,
restrict = _ref$restrict === void 0 ? {} : _ref$restrict,
restrictToPath = _ref.restrictToPath;
// use ref to detect prop changes

@@ -49,22 +39,21 @@ var positionPropsRef = (0, _react.useRef)({

});
var _useStateWithCallback = (0, _useStateWithCallback2.default)({
x: x,
y: y,
dx: dx != null ? dx : 0,
dy: dy != null ? dy : 0,
isDragging: false
}),
dragState = _useStateWithCallback[0],
setDragStateWithCallback = _useStateWithCallback[1]; // Track distance between pointer on dragStart and position of element being dragged
x: x,
y: y,
dx: dx != null ? dx : 0,
dy: dy != null ? dy : 0,
isDragging: false
}),
dragState = _useStateWithCallback[0],
setDragStateWithCallback = _useStateWithCallback[1];
// Track distance between pointer on dragStart and position of element being dragged
var _useState = (0, _react.useState)(new _point.Point({
x: 0,
y: 0
})),
dragStartPointerOffset = _useState[0],
setDragStartPointerOffset = _useState[1]; // if prop position changes, update state
x: 0,
y: 0
})),
dragStartPointerOffset = _useState[0],
setDragStartPointerOffset = _useState[1];
// if prop position changes, update state
(0, _react.useEffect)(function () {

@@ -103,7 +92,7 @@ if (positionPropsRef.current.x !== x || positionPropsRef.current.y !== y || positionPropsRef.current.dx !== dx || positionPropsRef.current.dy !== dy) {

var _currState$x = currState.x,
x = _currState$x === void 0 ? 0 : _currState$x,
_currState$y = currState.y,
y = _currState$y === void 0 ? 0 : _currState$y,
dx = currState.dx,
dy = currState.dy;
x = _currState$x === void 0 ? 0 : _currState$x,
_currState$y = currState.y,
y = _currState$y === void 0 ? 0 : _currState$y,
dx = currState.dx,
dy = currState.dy;
var currentPoint = new _point.Point({

@@ -136,8 +125,8 @@ x: (x || 0) + dx,

setDragStateWithCallback(function (currState) {
if (!currState.isDragging) return currState; // eslint-disable-next-line no-shadow
if (!currState.isDragging) return currState;
// eslint-disable-next-line no-shadow
var _currState$x2 = currState.x,
x = _currState$x2 === void 0 ? 0 : _currState$x2,
_currState$y2 = currState.y,
y = _currState$y2 === void 0 ? 0 : _currState$y2;
x = _currState$x2 === void 0 ? 0 : _currState$x2,
_currState$y2 = currState.y,
y = _currState$y2 === void 0 ? 0 : _currState$y2;
var pointerPoint = (0, _event.localPoint)(event) || new _point.Point({

@@ -144,0 +133,0 @@ x: 0,

@@ -5,3 +5,2 @@ "use strict";

exports.default = clampNumber;
/** Clamps number within the inclusive lower and upper bounds. */

@@ -8,0 +7,0 @@ function clampNumber(number, lower, upper) {

@@ -5,9 +5,5 @@ "use strict";

exports.default = getClosestPoint;
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
/** Gets closest point from list of points */

@@ -17,7 +13,5 @@ function getClosestPoint(point, samples) {

var minDistance = Infinity;
for (var _iterator = _createForOfIteratorHelperLoose(samples), _step; !(_step = _iterator()).done;) {
var sample = _step.value;
var distance = Math.sqrt(Math.pow(sample.x - point.x, 2) + Math.pow(sample.y - point.y, 2));
if (distance < minDistance) {

@@ -31,4 +25,3 @@ minDistance = distance;

}
return closestPoint;
}

@@ -5,3 +5,2 @@ "use strict";

exports.default = raise;
/** Given at an array of items, moves the item at the specified index to the end of the array. */

@@ -11,8 +10,6 @@ function raise(items, raiseIndex) {

var lastIndex = array.length - 1;
var _array$splice = array.splice(raiseIndex, 1),
raiseItem = _array$splice[0];
raiseItem = _array$splice[0];
array.splice(lastIndex, 0, raiseItem);
return array;
}

@@ -5,21 +5,14 @@ "use strict";

exports.default = restrictPoint;
var _clampNumber = _interopRequireDefault(require("./clampNumber"));
var _getClosestPoint = _interopRequireDefault(require("./getClosestPoint"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/** Restrict a point to an area, or samples along a path. */
function restrictPoint(point, samples, restrict) {
var _restrict$xMin, _restrict$xMax, _restrict$yMin, _restrict$yMax;
if (restrict === void 0) {
restrict = {};
}
if (samples.length > 0) {
return (0, _getClosestPoint.default)(point, samples);
}
return {

@@ -26,0 +19,0 @@ x: (0, _clampNumber.default)(point.x, (_restrict$xMin = restrict.xMin) != null ? _restrict$xMin : -Infinity, (_restrict$xMax = restrict.xMax) != null ? _restrict$xMax : Infinity),

@@ -5,9 +5,3 @@ "use strict";

exports.default = useSamplesAlongPath;
var _react = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var _react = require("react");
function getSamples(restrictToPath, transform, precision) {

@@ -17,7 +11,5 @@ if (precision === void 0) {

}
if (!restrictToPath) return [];
var samples = [];
var pathLength = restrictToPath.getTotalLength();
for (var sampleLength = 0; sampleLength <= pathLength; sampleLength += precision) {

@@ -28,8 +20,6 @@ var sample = restrictToPath.getPointAtLength(sampleLength);

}
return samples;
}
/** Return samples along a path, relative to the parent SVG */
function useSamplesAlongPath(restrictToPath) {

@@ -39,3 +29,4 @@ var samples = (0, _react.useMemo)(function () {

var transform = restrictToPath.getCTM() || new DOMMatrix();
return getSamples(restrictToPath, transform); // The path can transform without triggering a re-render,
return getSamples(restrictToPath, transform);
// The path can transform without triggering a re-render,
// so we need to update the samples whenever the length changes.

@@ -42,0 +33,0 @@ // eslint-disable-next-line react-hooks/exhaustive-deps

@@ -5,15 +5,8 @@ "use strict";

exports.default = useStateWithCallback;
var _react = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var _react = require("react");
/** A hook that exposes a setState(state, callback) API similar to a component class. */
function useStateWithCallback(initialState) {
var _useState = (0, _react.useState)(initialState),
state = _useState[0],
setState = _useState[1];
state = _useState[0],
setState = _useState[1];
var callbackRef = (0, _react.useRef)(null);

@@ -23,4 +16,5 @@ var setStateCallback = (0, _react.useCallback)(function (nextState, callback) {

setState(nextState);
}, [setState]); // if we use useEffect, some callback invocations are skipped
}, [setState]);
// if we use useEffect, some callback invocations are skipped
(0, _react.useLayoutEffect)(function () {

@@ -27,0 +21,0 @@ // `null` on initial render, so we only execute callback on state *updates*

{
"name": "@visx/drag",
"version": "2.10.0",
"version": "2.17.0-alpha.0",
"description": "visx drag",

@@ -38,7 +38,7 @@ "sideEffects": false,

"@types/react": "*",
"@visx/event": "2.6.0",
"@visx/point": "2.6.0",
"@visx/event": "2.17.0-alpha.0",
"@visx/point": "2.17.0-alpha.0",
"prop-types": "^15.5.10"
},
"gitHead": "3d655a8b100d862c91d4b5655e221259357a094d"
"gitHead": "77292e262dfe082b554b64839eb3ee141439a95f"
}

@@ -7,3 +7,4 @@ # @visx/drag

`@visx/drag` provides `react` components and hooks for making items within an interface (or chart) draggable.
`@visx/drag` provides `react` components and hooks for making items within an interface (or chart)
draggable.

@@ -10,0 +11,0 @@ ## Installation

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc