react-remove-scroll
Advanced tools
Comparing version 2.4.3 to 2.4.4
@@ -49,4 +49,12 @@ var elementCouldBeVScrolled = function (node) { | ||
}; | ||
var getDirectionFactor = function (axis, direction) { return ( | ||
/** | ||
* If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position, | ||
* and then increasingly negative as you scroll towards the end of the content. | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft | ||
*/ | ||
axis === 'h' && direction === 'rtl' ? -1 : 1); }; | ||
export var handleScroll = function (axis, endTarget, event, sourceDelta, noOverscroll) { | ||
var delta = sourceDelta; | ||
var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction); | ||
var delta = directionFactor * sourceDelta; | ||
// find scrollable target | ||
@@ -61,3 +69,3 @@ var target = event.target; | ||
var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2]; | ||
var elementScroll = scroll_1 - capacity - position; | ||
var elementScroll = scroll_1 - capacity - directionFactor * position; | ||
if (position || elementScroll) { | ||
@@ -64,0 +72,0 @@ if (elementCouldBeScrolled(axis, target)) { |
@@ -51,4 +51,12 @@ "use strict"; | ||
}; | ||
var getDirectionFactor = function (axis, direction) { return ( | ||
/** | ||
* If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position, | ||
* and then increasingly negative as you scroll towards the end of the content. | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft | ||
*/ | ||
axis === 'h' && direction === 'rtl' ? -1 : 1); }; | ||
exports.handleScroll = function (axis, endTarget, event, sourceDelta, noOverscroll) { | ||
var delta = sourceDelta; | ||
var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction); | ||
var delta = directionFactor * sourceDelta; | ||
// find scrollable target | ||
@@ -63,3 +71,3 @@ var target = event.target; | ||
var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2]; | ||
var elementScroll = scroll_1 - capacity - position; | ||
var elementScroll = scroll_1 - capacity - directionFactor * position; | ||
if (position || elementScroll) { | ||
@@ -66,0 +74,0 @@ if (elementCouldBeScrolled(axis, target)) { |
{ | ||
"name": "react-remove-scroll", | ||
"version": "2.4.3", | ||
"version": "2.4.4", | ||
"description": "Disables scroll outside of `children` node.", | ||
@@ -49,4 +49,4 @@ "main": "dist/es5/index.js", | ||
"peerDependencies": { | ||
"react": "^16.8.0 || ^17.0.0", | ||
"@types/react": "^16.8.0 || ^17.0.0" | ||
"@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0", | ||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0" | ||
}, | ||
@@ -53,0 +53,0 @@ "peerDependenciesMeta": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50597
994