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 0.1.0 to 0.2.0

31

dist/index.js

@@ -23,5 +23,2 @@ "use strict";

var hasWindow = typeof window !== "undefined";
var lastKnownScrollX = 0;
var lastKnownScrollY = 0;
var ticking = false;

@@ -31,3 +28,5 @@ var getPosition = function getPosition() {

scrollX: hasWindow ? window.pageXOffset : 0,
scrollY: hasWindow ? window.pageYOffset : 0
scrollY: hasWindow ? window.pageYOffset : 0,
scrollingUp: false,
scrollingDown: false
};

@@ -42,2 +41,6 @@ };

var lastKnownScrollX = (0, _react.useRef)(0);
var lastKnownScrollY = (0, _react.useRef)(0);
var ticking = (0, _react.useRef)(false);
var handleScroll = function handleScroll(e) {

@@ -48,18 +51,18 @@ if (!hasWindow) {

var scrollingUp = window.pageYOffset < lastKnownScrollY;
var scrollingDown = window.pageYOffset > lastKnownScrollY;
lastKnownScrollX = window.pageXOffset;
lastKnownScrollY = window.pageYOffset;
var scrollingUp = window.pageYOffset < lastKnownScrollY.current;
var scrollingDown = window.pageYOffset > lastKnownScrollY.current;
lastKnownScrollX.current = window.pageXOffset;
lastKnownScrollY.current = window.pageYOffset;
if (!ticking) {
if (!ticking.current) {
window.requestAnimationFrame(function () {
setPosition({
scrollX: lastKnownScrollX,
scrollY: lastKnownScrollY,
scrollX: lastKnownScrollX.current,
scrollY: lastKnownScrollY.current,
scrollingUp: scrollingUp,
scrollingDown: scrollingDown
});
ticking = false;
ticking.current = false;
});
ticking = true;
ticking.current = true;
}

@@ -85,2 +88,2 @@ };

exports["default"] = _default;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy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YWdlWU9mZnNldCA+IGxhc3RLbm93blNjcm9sbFk7XG4gICAgXG4gICAgbGFzdEtub3duU2Nyb2xsWCA9IHdpbmRvdy5wYWdlWE9mZnNldDtcbiAgICBsYXN0S25vd25TY3JvbGxZID0gd2luZG93LnBhZ2VZT2Zmc2V0O1xuICBcbiAgICBpZiAoIXRpY2tpbmcpIHtcbiAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoZnVuY3Rpb24oKSB7XG4gICAgICAgIHNldFBvc2l0aW9uKHtcbiAgICAgICAgICBzY3JvbGxYOiBsYXN0S25vd25TY3JvbGxYLFxuICAgICAgICAgIHNjcm9sbFk6IGxhc3RLbm93blNjcm9sbFksXG4gICAgICAgICAgc2Nyb2xsaW5nVXAsXG4gICAgICAgICAgc2Nyb2xsaW5nRG93biwgXG4gICAgICAgIH0pO1xuICAgICAgICB0aWNraW5nID0gZmFsc2U7XG4gICAgICB9KTtcbiAgXG4gICAgICB0aWNraW5nID0gdHJ1ZTtcbiAgICB9XG4gIH07XG5cbiAgdXNlRWZmZWN0KCgpID0+IHtcbiAgICBpZiAoIWhhc1dpbmRvdykge1xuICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cblxuICAgIHdpbmRvdy5hZGRFdmVudExpc3RlbmVyKFxuICAgICAgXCJzY3JvbGxcIixcbiAgICAgIGhhbmRsZVNjcm9sbCxcbiAgICAgIHN1cHBvcnRzUGFzc2l2ZSA/IHsgcGFzc2l2ZTogdHJ1ZSB9IDogZmFsc2VcbiAgICApO1xuXG4gICAgcmV0dXJuICgpID0+IHdpbmRvdy5yZW1vdmVFdmVudExpc3RlbmVyKFwic2Nyb2xsXCIsIGhhbmRsZVNjcm9sbCk7XG4gIH0sIFtdKTtcblxuICByZXR1cm4gcG9zaXRpb247XG59XG5cbmV4cG9ydCBkZWZhdWx0IHVzZVNjcm9sbFBvc2l0aW9uOyJdfQ==
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZX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ycmVudCA9IHRydWU7XG4gICAgfVxuICB9O1xuXG4gIHVzZUVmZmVjdCgoKSA9PiB7XG4gICAgaWYgKCFoYXNXaW5kb3cpIHtcbiAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG5cbiAgICB3aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcihcbiAgICAgIFwic2Nyb2xsXCIsXG4gICAgICBoYW5kbGVTY3JvbGwsXG4gICAgICBzdXBwb3J0c1Bhc3NpdmUgPyB7IHBhc3NpdmU6IHRydWUgfSA6IGZhbHNlXG4gICAgKTtcblxuICAgIHJldHVybiAoKSA9PiB3aW5kb3cucmVtb3ZlRXZlbnRMaXN0ZW5lcihcInNjcm9sbFwiLCBoYW5kbGVTY3JvbGwpO1xuICB9LCBbXSk7XG5cbiAgcmV0dXJuIHBvc2l0aW9uO1xufVxuXG5leHBvcnQgZGVmYXVsdCB1c2VTY3JvbGxQb3NpdGlvbjsiXX0=
{
"name": "@designbycosmic/cosmic-react-scroll-hook",
"version": "0.1.0",
"version": "0.2.0",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "source": "src/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