Socket
Socket
Sign inDemoInstall

@react-aria/utils

Package Overview
Dependencies
Maintainers
2
Versions
793
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-aria/utils - npm Package Compare versions

Comparing version 3.4.1 to 3.5.0

25

dist/main.js

@@ -325,2 +325,27 @@ var _clsx = $parcel$interopDefault(require("clsx"));

exports.clamp = clamp;
function snapValueToStep(value, min, max, step) {
let remainder = (value - min) % step;
let snappedValue = Math.abs(remainder) * 2 >= step ? value - Math.abs(remainder) + step : value - remainder;
if (snappedValue < min) {
snappedValue = min;
} else if (snappedValue > max) {
snappedValue = min + Math.floor((max - min) / step) * step;
} // correct floating point behavior by rounding to step precision
let string = step.toString();
let index = string.indexOf('.');
let precision = index >= 0 ? string.length - index : 0;
if (precision > 0) {
let pow = Math.pow(10, precision);
snappedValue = Math.round(snappedValue * pow) / pow;
}
return snappedValue;
}
exports.snapValueToStep = snapValueToStep;
// mapped to a set of CSS properties that are transitioning for that element.

@@ -327,0 +352,0 @@ // This is necessary rather than a simple count of transitions because of browser

@@ -284,2 +284,24 @@ import _clsx from "clsx";

}
export function snapValueToStep(value, min, max, step) {
let remainder = (value - min) % step;
let snappedValue = Math.abs(remainder) * 2 >= step ? value - Math.abs(remainder) + step : value - remainder;
if (snappedValue < min) {
snappedValue = min;
} else if (snappedValue > max) {
snappedValue = min + Math.floor((max - min) / step) * step;
} // correct floating point behavior by rounding to step precision
let string = step.toString();
let index = string.indexOf('.');
let precision = index >= 0 ? string.length - index : 0;
if (precision > 0) {
let pow = Math.pow(10, precision);
snappedValue = Math.round(snappedValue * pow) / pow;
}
return snappedValue;
}
// mapped to a set of CSS properties that are transitioning for that element.

@@ -286,0 +308,0 @@ // This is necessary rather than a simple count of transitions because of browser

1

dist/types.d.ts

@@ -60,2 +60,3 @@ import React, { HTMLAttributes, MutableRefObject, EffectCallback, RefObject } from "react";

export function clamp(value: number, min?: number, max?: number): number;
export function snapValueToStep(value: number, min: number, max: number, step: number): number;
export function runAfterTransition(fn: () => void): void;

@@ -62,0 +63,0 @@ interface UseDrag1DProps {

4

package.json
{
"name": "@react-aria/utils",
"version": "3.4.1",
"version": "3.5.0",
"description": "Spectrum UI components in React",

@@ -31,3 +31,3 @@ "license": "Apache-2.0",

},
"gitHead": "f5b429ee8615248f2e3c76754bad2ece83f1c444"
"gitHead": "0159136997a4b18166b0e660b929fd8e243410c8"
}

@@ -19,1 +19,26 @@ /*

}
export function snapValueToStep(value: number, min: number, max: number, step: number): number {
let remainder = ((value - min) % step);
let snappedValue = Math.abs(remainder) * 2 >= step
? (value - Math.abs(remainder)) + step
: value - remainder;
if (snappedValue < min) {
snappedValue = min;
} else if (snappedValue > max) {
snappedValue = min + Math.floor((max - min) / step) * step;
}
// correct floating point behavior by rounding to step precision
let string = step.toString();
let index = string.indexOf('.');
let precision = index >= 0 ? string.length - index : 0;
if (precision > 0) {
let pow = Math.pow(10, precision);
snappedValue = Math.round(snappedValue * pow) / pow;
}
return snappedValue;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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