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

@designbycosmic/cosmic-react-scroll-hook

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@designbycosmic/cosmic-react-scroll-hook - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

10

dist/index.js

@@ -49,4 +49,6 @@ "use strict";

var scrollingDown = el[scrollX] > lastKnownScrollY.current;
var scrollingDown = el[scrollY] > lastKnownScrollY.current;
var scrollingUp = el[scrollY] < lastKnownScrollY.current;
var scrollingRight = el[scrollX] > lastKnownScrollX.current;
var scrollingLeft = el[scrollX] < lastKnownScrollX.current;
lastKnownScrollX.current = el[scrollX];

@@ -61,3 +63,5 @@ lastKnownScrollY.current = el[scrollY];

scrollingUp: scrollingUp,
scrollingDown: scrollingDown
scrollingDown: scrollingDown,
scrollingRight: scrollingRight,
scrollingLeft: scrollingLeft
});

@@ -87,2 +91,2 @@ ticking.current = false;

exports["default"] = _default;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJoYXNXaW5kb3ciLCJ3aW5kb3ciLCJ1c2VTY3JvbGxQb3NpdGlvbiIsImVsUmVmIiwid2luIiwiZWwiLCJzY3JvbGxZIiwic2Nyb2xsWCIsInNjcm9sbGluZ1VwIiwic2Nyb2xsaW5nRG93biIsInBvc2l0aW9uIiwic2V0UG9zaXRpb24iLCJsYXN0S25vd25TY3JvbGxYIiwibGFzdEtub3duU2Nyb2xsWSIsInRpY2tpbmciLCJoYW5kbGVTY3JvbGwiLCJjdXJyZW50IiwicmVxdWVzdEFuaW1hdGlvbkZyYW1lIiwidW5kZWZpbmVkIiwiYWRkRXZlbnRMaXN0ZW5lciIsInN1cHBvcnRzUGFzc2l2ZSIsInBhc3NpdmUiLCJyZW1vd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bGxpbmdSaWdodCxcbiAgICAgICAgICBzY3JvbGxpbmdMZWZ0LFxuICAgICAgICB9KTtcbiAgICAgICAgdGlja2luZy5jdXJyZW50ID0gZmFsc2U7XG4gICAgICB9KTtcblxuICAgICAgdGlja2luZy5jdXJyZW50ID0gdHJ1ZTtcbiAgICB9XG4gIH07XG5cbiAgdXNlRWZmZWN0KCgpID0+IHtcbiAgICBpZiAoIWhhc1dpbmRvdyB8fCAoIWVsUmVmICYmIHR5cGVvZiBlbFJlZiAhPT0gXCJ1bmRlZmluZWRcIikpIHtcbiAgICAgIHJldHVybiB1bmRlZmluZWQ7XG4gICAgfVxuXG4gICAgZWwuYWRkRXZlbnRMaXN0ZW5lcihcbiAgICAgIFwic2Nyb2xsXCIsXG4gICAgICBoYW5kbGVTY3JvbGwsXG4gICAgICBzdXBwb3J0c1Bhc3NpdmUgPyB7IHBhc3NpdmU6IHRydWUgfSA6IGZhbHNlXG4gICAgKTtcblxuICAgIHJldHVybiAoKSA9PiBlbC5yZW1vdmVFdmVudExpc3RlbmVyKFwic2Nyb2xsXCIsIGhhbmRsZVNjcm9sbCk7XG4gIH0sIFtlbFJlZl0pO1xuXG4gIHJldHVybiBwb3NpdGlvbjtcbn07XG5cbmV4cG9ydCBkZWZhdWx0IHVzZVNjcm9sbFBvc2l0aW9uO1xuIl19
{
"name": "@designbycosmic/cosmic-react-scroll-hook",
"version": "1.0.2",
"version": "1.1.0",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "source": "src/index.js",

# cosmic-react-scroll-hook
React hook for listening to window scroll position
## How to use
## Typical use: getting scroll position of window

@@ -20,2 +20,38 @@ ```

export default ScrollWatcher;
```
## You can also get the scroll position of scrollable elements other than the window
```
// from any functional component
import { useScrollPosition } from "cosmic-react-scroll-hook";
const ScrollWatcher = () => {
const scrollableDiv = useRef({}); // Make sure to initialize ref with empty object
const { scrollX, scrollY } = useScrollPosition(scrollableDiv.current);
return (
<div ref={scrollableDiv}>
...
</div>
);
}
export default ScrollWatcher;
```
## You can also get direction of the scroll
```
// from any functional component
import { useScrollPosition } from "cosmic-react-scroll-hook";
const ScrollWatcher = () => {
const scrollableDiv = useRef();
const { scrollingUp, scrollingDown, scrollingRight, scrollingLeft } = useScrollPosition();
...
}
export default ScrollWatcher;
```
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