Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
react-scrollbar-size
Advanced tools
React-Scrollbar-Size is a React component designed to calculate the size of the user agent's horizontal and vertical scrollbars. It will also detect when the size of the scrollbars change, such as when the user agent's zoom factor changes.
React-Scrollbar-Size is available as an npm package:
$ npm install react-scrollbar-size
Name | Description |
---|---|
onChange | Callback which will fire when the scrollbar sizes change. |
The callback accepts an object which will be updated with the following properties:
Name | Description |
---|---|
width | The current width of the vertical scrollbar. |
height | The current height of the horizontal scrollbar. |
To see a live example, follow these instructions.
import React, { CSSProperties, FunctionComponent, useState } from 'react';
import ScrollbarSize from 'react-scrollbar-size';
const styles: CSSProperties = {
margin: '1rem',
textAlign: 'center',
};
const ScrollbarSizeDemo: FunctionComponent = () => {
const [currentHeight, setHeight] = useState(0);
const [currentWidth, setWidth] = useState(0);
const scrollbarSizeChange = ({ height, width }: ScrollbarSizeChangeHandlerParams) => {
if (height !== currentHeight) {
setHeight(height);
}
if (width !== currentWidth) {
setWidth(width);
}
};
return (
<div style={styles}>
<h2>React Scrollbar Size Demo</h2>
<h4>Tip: Change browser zoom level to see scrollbar sizes change.</h4>
<ScrollbarSize onChange={scrollbarSizeChange} />
<p>
{`The current height of the scrollbar is ${currentHeight}px.`}
<br />
{`The current width of the scrollbar is ${currentWidth}px.`}
</p>
</div>
);
};
import React, { useState } from 'react';
import ScrollbarSize from 'react-scrollbar-size';
const styles = {
margin: '1rem',
textAlign: 'center',
};
const ScrollbarSizeDemo = () => {
const [currentHeight, setHeight] = useState(0);
const [currentWidth, setWidth] = useState(0);
const scrollbarSizeChange = ({ height, width }) => {
if (height !== currentHeight) {
setHeight(height);
}
if (width !== currentWidth) {
setWidth(width);
}
};
return (
<div style={styles}>
<h2>React Scrollbar Size Demo</h2>
<h4>Tip: Change browser zoom level to see scrollbar sizes change.</h4>
<ScrollbarSize onChange={scrollbarSizeChange} />
<p>
{`The current height of the scrollbar is ${currentHeight}px.`}
<br />
{`The current width of the scrollbar is ${currentWidth}px.`}
</p>
</div>
);
};
This project is licensed under the terms of the MIT license.
[3.1.1] - 2021-03-06
master
branch to main
branchFAQs
React hook to calculate the size of browser scrollbars
The npm package react-scrollbar-size receives a total of 9,231 weekly downloads. As such, react-scrollbar-size popularity was classified as popular.
We found that react-scrollbar-size demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.