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

react-scroll

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-scroll - npm Package Compare versions

Comparing version 1.7.2 to 1.7.3

18

modules/__tests__/animate-scroll-test.js

@@ -126,3 +126,3 @@ 'use strict';

setTimeout(function () {
(0, _expect2.default)(window.scrollY).toEqual(120);
(0, _expect2.default)(window.scrollY || window.pageYOffset).toEqual(120);
done();

@@ -154,3 +154,3 @@ }, waitDuration);

setTimeout(function () {
(0, _expect2.default)(window.scrollY).toEqual(200);
(0, _expect2.default)(window.scrollY || window.pageYOffset).toEqual(200);

@@ -168,3 +168,3 @@ done();

setTimeout(function () {
(0, _expect2.default)(window.scrollY).toEqual(0);
(0, _expect2.default)(window.scrollY || window.pageYOffset).toEqual(0);
done();

@@ -181,3 +181,3 @@ }, waitDuration);

var offset = 16;
(0, _expect2.default)(window.scrollY).toEqual(node.offsetHeight - window.innerHeight + offset);
(0, _expect2.default)(window.scrollY || window.pageYOffset).toEqual(node.offsetHeight - window.innerHeight + offset);
done();

@@ -195,3 +195,3 @@ }, waitDuration);

setTimeout(function () {
(0, _expect2.default)(window.scrollY).toEqual(121);
(0, _expect2.default)(window.scrollY || window.pageYOffset).toEqual(121);

@@ -202,3 +202,3 @@ _animateScroll2.default.scrollMore(10, { duration: duration });

setTimeout(function () {
(0, _expect2.default)(window.scrollY).toEqual(131);
(0, _expect2.default)(window.scrollY || window.pageYOffset).toEqual(131);

@@ -216,3 +216,3 @@ done();

setTimeout(function () {
(0, _expect2.default)(window.scrollY).toEqual(120);
(0, _expect2.default)(window.scrollY || window.pageYOffset).toEqual(120);
done();

@@ -228,6 +228,6 @@ }, 100);

} });
(0, _expect2.default)(window.scrollY).toEqual(0);
(0, _expect2.default)(window.scrollY || window.pageYOffset).toEqual(0);
setTimeout(function () {
(0, _expect2.default)(window.scrollY).toEqual(120);
(0, _expect2.default)(window.scrollY || window.pageYOffset).toEqual(120);
done();

@@ -234,0 +234,0 @@ }, 150);

@@ -40,6 +40,4 @@ 'use strict';

/* Components to test */
var wait = function wait(ms) {
return new Promise(function (res, rej) {
setTimeout(res, ms);
});
var wait = function wait(ms, cb) {
setTimeout(cb, ms);
};

@@ -178,3 +176,3 @@ /* Test */

it('it is at top in start', function (done) {
(0, _expect2.default)(window.scrollY).toEqual(0);
(0, _expect2.default)(window.scrollY || window.pageYOffset).toEqual(0);
done();

@@ -195,3 +193,3 @@ });

var scrollStart = window.scrollY;
var scrollStart = window.scrollY || window.pageYOffset;

@@ -204,3 +202,3 @@ /* Let it scroll, duration is based on param sent to Link */

(0, _expect2.default)(window.scrollY).toEqual(scrollStop);
(0, _expect2.default)(window.scrollY || window.pageYOffset).toEqual(scrollStop);

@@ -227,3 +225,3 @@ (0, _expect2.default)(link.className).toEqual('active');

/* Let it scroll, duration is based on param sent to Link */
var scrollStart = window.scrollY;
var scrollStart = window.scrollY || window.pageYOffset;

@@ -234,3 +232,3 @@ setTimeout(function () {

(0, _expect2.default)(window.scrollY).toEqual(scrollStop);
(0, _expect2.default)(window.scrollY || window.pageYOffset).toEqual(scrollStop);

@@ -244,3 +242,3 @@ (0, _expect2.default)(link.className).toEqual('active');

it('should call onSetActive', async function () {
it('should call onSetActive', function (done) {

@@ -349,14 +347,15 @@ var onSetActive = _sinon2.default.spy();

await wait(scrollDuration + 500);
wait(scrollDuration + 500, function () {
(0, _expect2.default)(onSetActive.calledOnce).toEqual(true);
(0, _expect2.default)(onSetActive.calledOnce).toEqual(true);
link = node.querySelectorAll('a')[4];
link = node.querySelectorAll('a')[4];
_testUtils2.default.Simulate.click(link);
_testUtils2.default.Simulate.click(link);
await wait(scrollDuration + 500);
(0, _expect2.default)(onSetInactive.calledOnce).toEqual(true);
wait(scrollDuration + 500, function () {
(0, _expect2.default)(onSetInactive.calledOnce).toEqual(true);
done();
});
});
});
});

@@ -48,3 +48,3 @@ 'use strict';

describe("when scrolling is triggered by keydown handlers", function () {
it("can scroll on keydown multiple times in a row", async function () {
it("can scroll on keydown multiple times in a row", function (done) {
var duration = 100;

@@ -90,12 +90,16 @@ var distance = 100;

dispatchDOMKeydownEvent(13, node.querySelector('input'));
await wait(duration * 2);
(0, _expect2.default)(window.scrollY).toBeGreaterThanOrEqualTo(distance);
wait(duration * 2, function () {
(0, _expect2.default)(window.scrollY || window.pageYOffset).toBeGreaterThanOrEqualTo(distance);
dispatchDOMKeydownEvent(13, node.querySelector('input'));
await wait(duration * 2);
(0, _expect2.default)(window.scrollY).toBeGreaterThanOrEqualTo(distance * 2);
dispatchDOMKeydownEvent(13, node.querySelector('input'));
wait(duration * 2, function () {
(0, _expect2.default)(window.scrollY || window.pageYOffset).toBeGreaterThanOrEqualTo(distance * 2);
dispatchDOMKeydownEvent(13, node.querySelector('input'));
await wait(duration * 2);
(0, _expect2.default)(window.scrollY).toBeGreaterThanOrEqualTo(distance * 3);
dispatchDOMKeydownEvent(13, node.querySelector('input'));
wait(duration * 2, function () {
(0, _expect2.default)(window.scrollY || window.pageYOffset).toBeGreaterThanOrEqualTo(distance * 3);
done();
});
});
});
});

@@ -105,6 +109,4 @@ });

var wait = function wait(ms) {
return new Promise(function (res, rej) {
setTimeout(res, ms);
});
var wait = function wait(ms, cb) {
setTimeout(cb, ms);
};

@@ -111,0 +113,0 @@

@@ -30,3 +30,3 @@ 'use strict';

var scrollOffset = function scrollOffset(c, t) {
return c === document ? t.getBoundingClientRect().top + window.scrollY : getComputedStyle(c).position === "relative" ? t.offsetTop : t.offsetTop - c.offsetTop;
return c === document ? t.getBoundingClientRect().top + (window.scrollY || window.pageYOffset) : getComputedStyle(c).position === "relative" ? t.offsetTop : t.offsetTop - c.offsetTop;
};

@@ -33,0 +33,0 @@

{
"name": "react-scroll",
"version": "1.7.2",
"version": "1.7.3",
"description": "A scroll component for React.js",

@@ -5,0 +5,0 @@ "main": "modules",

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