react-scrollbar-size

WebJar for react-scrollbar-size

License

License

MIT
Categories

Categories

React User Interface Web Frameworks
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

react-scrollbar-size
Last Version

Last Version

2.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

react-scrollbar-size
WebJar for react-scrollbar-size
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/STORIS/react-scrollbar-size

Download react-scrollbar-size

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/react-scrollbar-size/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>react-scrollbar-size</artifactId>
    <version>2.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/react-scrollbar-size/
implementation 'org.webjars.npm:react-scrollbar-size:2.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/react-scrollbar-size/
implementation ("org.webjars.npm:react-scrollbar-size:2.1.0")
'org.webjars.npm:react-scrollbar-size:jar:2.1.0'
<dependency org="org.webjars.npm" name="react-scrollbar-size" rev="2.1.0">
  <artifact name="react-scrollbar-size" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='react-scrollbar-size', version='2.1.0')
)
libraryDependencies += "org.webjars.npm" % "react-scrollbar-size" % "2.1.0"
[org.webjars.npm/react-scrollbar-size "2.1.0"]

Dependencies

compile (4)

Group / Artifact Type Version
org.webjars.npm : babel-runtime jar [6.26.0,7)
org.webjars.npm : prop-types jar [15.6.0,16)
org.webjars.npm : react-event-listener jar [0.5.1,0.6)
org.webjars.npm : stifle jar [1.0.2,2)

Project Modules

There are no modules declared in this project.

React-Scrollbar-Size

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.

npm package npm downloads CircleCI Code Climate Code Style Code style Dependabot Status Dependencies PeerDependencies DevDependencies Percentage of issues still open License Contributor Covenant Star on Github

Installation

React-Scrollbar-Size is available as an npm package:

$ npm install react-scrollbar-size

Usage

Props

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.

Examples

To see a live example, follow these instructions.

TypeScript

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>
  );
};

JavaScript

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>
  );
};

License

This project is licensed under the terms of the MIT license.

org.webjars.npm

STORIS

Versions

Version
2.1.0
2.0.2