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

react-remove-scroll-bar

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-remove-scroll-bar - npm Package Compare versions

Comparing version 2.3.5 to 2.3.6

1

dist/es2015/component.d.ts

@@ -9,2 +9,3 @@ import * as React from 'react';

export declare const lockAttribute = "data-scroll-locked";
export declare const useLockAttribute: () => void;
/**

@@ -11,0 +12,0 @@ * Removes page scrollbar and blocks page scroll when mounted

29

dist/es2015/component.js

@@ -22,7 +22,26 @@ import * as React from 'react';

};
var getCurrentUseCounter = function () {
var counter = parseInt(document.body.getAttribute(lockAttribute) || '0', 10);
return isFinite(counter) ? counter : 0;
};
export var useLockAttribute = function () {
React.useEffect(function () {
document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
return function () {
var newCounter = getCurrentUseCounter() - 1;
if (newCounter <= 0) {
document.body.removeAttribute(lockAttribute);
}
else {
document.body.setAttribute(lockAttribute, newCounter.toString());
}
};
}, []);
};
/**
* Removes page scrollbar and blocks page scroll when mounted
*/
export var RemoveScrollBar = function (props) {
var noRelative = props.noRelative, noImportant = props.noImportant, _a = props.gapMode, gapMode = _a === void 0 ? 'margin' : _a;
export var RemoveScrollBar = function (_a) {
var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? 'margin' : _b;
useLockAttribute();
/*

@@ -34,9 +53,3 @@ gap will be measured on every component mount

var gap = React.useMemo(function () { return getGapWidth(gapMode); }, [gapMode]);
React.useEffect(function () {
document.body.setAttribute(lockAttribute, '');
return function () {
document.body.removeAttribute(lockAttribute);
};
}, []);
return React.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? '!important' : '') });
};

@@ -9,2 +9,3 @@ import * as React from 'react';

export declare const lockAttribute = "data-scroll-locked";
export declare const useLockAttribute: () => void;
/**

@@ -11,0 +12,0 @@ * Removes page scrollbar and blocks page scroll when mounted

@@ -55,7 +55,25 @@ import * as React from 'react';

`;
const getCurrentUseCounter = () => {
const counter = parseInt(document.body.getAttribute(lockAttribute) || '0', 10);
return isFinite(counter) ? counter : 0;
};
export const useLockAttribute = () => {
React.useEffect(() => {
document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
return () => {
const newCounter = getCurrentUseCounter() - 1;
if (newCounter <= 0) {
document.body.removeAttribute(lockAttribute);
}
else {
document.body.setAttribute(lockAttribute, newCounter.toString());
}
};
}, []);
};
/**
* Removes page scrollbar and blocks page scroll when mounted
*/
export const RemoveScrollBar = (props) => {
const { noRelative, noImportant, gapMode = 'margin' } = props;
export const RemoveScrollBar = ({ noRelative, noImportant, gapMode = 'margin' }) => {
useLockAttribute();
/*

@@ -67,9 +85,3 @@ gap will be measured on every component mount

const gap = React.useMemo(() => getGapWidth(gapMode), [gapMode]);
React.useEffect(() => {
document.body.setAttribute(lockAttribute, '');
return () => {
document.body.removeAttribute(lockAttribute);
};
}, []);
return React.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? '!important' : '') });
};

@@ -9,2 +9,3 @@ import * as React from 'react';

export declare const lockAttribute = "data-scroll-locked";
export declare const useLockAttribute: () => void;
/**

@@ -11,0 +12,0 @@ * Removes page scrollbar and blocks page scroll when mounted

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RemoveScrollBar = exports.lockAttribute = void 0;
exports.RemoveScrollBar = exports.useLockAttribute = exports.lockAttribute = void 0;
var tslib_1 = require("tslib");

@@ -26,7 +26,27 @@ var React = tslib_1.__importStar(require("react"));

};
var getCurrentUseCounter = function () {
var counter = parseInt(document.body.getAttribute(exports.lockAttribute) || '0', 10);
return isFinite(counter) ? counter : 0;
};
var useLockAttribute = function () {
React.useEffect(function () {
document.body.setAttribute(exports.lockAttribute, (getCurrentUseCounter() + 1).toString());
return function () {
var newCounter = getCurrentUseCounter() - 1;
if (newCounter <= 0) {
document.body.removeAttribute(exports.lockAttribute);
}
else {
document.body.setAttribute(exports.lockAttribute, newCounter.toString());
}
};
}, []);
};
exports.useLockAttribute = useLockAttribute;
/**
* Removes page scrollbar and blocks page scroll when mounted
*/
var RemoveScrollBar = function (props) {
var noRelative = props.noRelative, noImportant = props.noImportant, _a = props.gapMode, gapMode = _a === void 0 ? 'margin' : _a;
var RemoveScrollBar = function (_a) {
var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? 'margin' : _b;
(0, exports.useLockAttribute)();
/*

@@ -38,10 +58,4 @@ gap will be measured on every component mount

var gap = React.useMemo(function () { return (0, utils_1.getGapWidth)(gapMode); }, [gapMode]);
React.useEffect(function () {
document.body.setAttribute(exports.lockAttribute, '');
return function () {
document.body.removeAttribute(exports.lockAttribute);
};
}, []);
return React.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? '!important' : '') });
};
exports.RemoveScrollBar = RemoveScrollBar;
{
"name": "react-remove-scroll-bar",
"version": "2.3.5",
"version": "2.3.6",
"description": "Removes body scroll without content _shake_",

@@ -5,0 +5,0 @@ "main": "dist/es5/index.js",

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