New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

scrolldir

Package Overview
Dependencies
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scrolldir - npm Package Compare versions

Comparing version 1.2.18 to 1.2.23

.nvmrc

13

.eslintrc.json
{
"extends": [ "airbnb/base"],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"env": {

@@ -9,8 +13,11 @@ "browser": true,

"document": true,
"foo": true,
"window": true
},
"rules": {
"indent": 2
"indent": [2, 2],
"no-console": [
"error", { "allow": ["warn", "error"] }
],
"semi": [2, "never"]
}
}

@@ -7,12 +7,6 @@ (function (global, factory) {

var defaults = {
el: document.documentElement,
win: window,
attribute: 'data-scrolldir',
dir: 'down'
};
var el = void 0;
var win = void 0;
var attribute = void 0;
var dir = void 0; // 'up' or 'down'
var attribute = 'data-scrolldir';
var dir = 'down'; // 'up' or 'down'
var el = document.documentElement;
var win = window;
var body = document.body;

@@ -75,13 +69,14 @@ var historyLength = 32; // Ticks to keep in history.

function scrollDir(opts) {
el = opts && opts.el || defaults.el;
win = opts && opts.win || defaults.win;
attribute = opts && opts.attribute || defaults.attribute;
dir = opts && opts.direction || defaults.dir;
// If opts.off, turn it off
// - set html[data-scrolldir="off"]
// - remove the event listener
if (opts && opts.off === true) {
el.setAttribute(attribute, 'off');
return win.removeEventListener('scroll', handler);
if (opts) {
if (opts.attribute) attribute = opts.attribute;
if (opts.el) el = opts.el;
if (opts.win) win = opts.win;
if (opts.dir) dir = opts.dir;
// If opts.off, turn it off
// - set html[data-scrolldir="off"]
// - remove the event listener
if (opts.off === true) {
el.setAttribute(attribute, 'off');
return win.removeEventListener('scroll', handler);
}
}

@@ -88,0 +83,0 @@

/**
* scrolldir - Vertical scroll direction in CSS
* @version v1.2.17
* @version v1.2.23
* @link https://github.com/dollarshaveclub/scrolldir.git

@@ -8,2 +8,2 @@ * @author Patrick Fisher <patrick@pwfisher.com>

**/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e():"function"==typeof define&&define.amd?define(e):e()}(0,function(){"use strict";function t(){var t=o.scrollY||o.pageYOffset,e=l.timeStamp,i="down"===d?Math.max:Math.min,p=f.offsetHeight-o.innerHeight;if(t=Math.max(0,t),t=Math.min(p,t),c.unshift({y:t,t:e}),c.pop(),t===i(m,t))return v=e,void(m=t);var b=e-u;if(b>v){m=t;for(var w=0;w<a&&(c[w]&&!(c[w].t<b));w+=1)m=i(m,c[w].y)}Math.abs(t-m)>s&&(m=t,v=e,d="down"===d?"up":"down",n.setAttribute(r,d))}function e(e){return l=e,o.requestAnimationFrame(t)}var i={el:document.documentElement,win:window,attribute:"data-scrolldir",dir:"down"},n=void 0,o=void 0,r=void 0,d=void 0,f=document.body,a=32,u=512,s=64,c=Array(a),l=void 0,m=void 0,v=0;!function(t){n=t&&t.el||i.el,o=t&&t.win||i.win,r=t&&t.attribute||i.attribute,d=t&&t.direction||i.dir,t&&!0===t.off?(n.setAttribute(r,"off"),o.removeEventListener("scroll",e)):(m=o.scrollY||o.pageYOffset,n.setAttribute(r,d),o.addEventListener("scroll",e))}()});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e():"function"==typeof define&&define.amd?define(e):e()}(0,function(){"use strict";function t(){var t=r.scrollY||r.pageYOffset,e=c.timeStamp,p="down"===i?Math.max:Math.min,v=f.offsetHeight-r.innerHeight;if(t=Math.max(0,t),t=Math.min(v,t),s.unshift({y:t,t:e}),s.pop(),t===p(m,t))return l=e,void(m=t);var b=e-a;if(b>l){m=t;for(var h=0;h<d&&(s[h]&&!(s[h].t<b));h+=1)m=p(m,s[h].y)}Math.abs(t-m)>u&&(m=t,l=e,i="down"===i?"up":"down",o.setAttribute(n,i))}function e(e){return c=e,r.requestAnimationFrame(t)}var n="data-scrolldir",i="down",o=document.documentElement,r=window,f=document.body,d=32,a=512,u=64,s=Array(d),c=void 0,m=void 0,l=0;!function(t){t&&(t.attribute&&(n=t.attribute),t.el&&(o=t.el),t.win&&(r=t.win),t.dir&&(i=t.dir),!0===t.off)?(o.setAttribute(n,"off"),r.removeEventListener("scroll",e)):(m=r.scrollY||r.pageYOffset,o.setAttribute(n,i),r.addEventListener("scroll",e))}()});

@@ -7,12 +7,6 @@ (function (global, factory) {

var defaults = {
el: document.documentElement,
win: window,
attribute: 'data-scrolldir',
dir: 'down'
};
var el = void 0;
var win = void 0;
var attribute = void 0;
var dir = void 0; // 'up' or 'down'
var attribute = 'data-scrolldir';
var dir = 'down'; // 'up' or 'down'
var el = document.documentElement;
var win = window;
var body = document.body;

@@ -75,13 +69,14 @@ var historyLength = 32; // Ticks to keep in history.

function scrollDir(opts) {
el = opts && opts.el || defaults.el;
win = opts && opts.win || defaults.win;
attribute = opts && opts.attribute || defaults.attribute;
dir = opts && opts.direction || defaults.dir;
// If opts.off, turn it off
// - set html[data-scrolldir="off"]
// - remove the event listener
if (opts && opts.off === true) {
el.setAttribute(attribute, 'off');
return win.removeEventListener('scroll', handler);
if (opts) {
if (opts.attribute) attribute = opts.attribute;
if (opts.el) el = opts.el;
if (opts.win) win = opts.win;
if (opts.dir) dir = opts.dir;
// If opts.off, turn it off
// - set html[data-scrolldir="off"]
// - remove the event listener
if (opts.off === true) {
el.setAttribute(attribute, 'off');
return win.removeEventListener('scroll', handler);
}
}

@@ -88,0 +83,0 @@

/**
* scrolldir - Vertical scroll direction in CSS
* @version v1.2.17
* @version v1.2.23
* @link https://github.com/dollarshaveclub/scrolldir.git

@@ -8,2 +8,2 @@ * @author Patrick Fisher <patrick@pwfisher.com>

**/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.scrollDir=e()}(this,function(){"use strict";function t(){var t=o.scrollY||o.pageYOffset,e=l.timeStamp,i="down"===d?Math.max:Math.min,p=f.offsetHeight-o.innerHeight;if(t=Math.max(0,t),t=Math.min(p,t),c.unshift({y:t,t:e}),c.pop(),t===i(m,t))return v=e,void(m=t);var b=e-a;if(b>v){m=t;for(var h=0;h<u&&(c[h]&&!(c[h].t<b));h+=1)m=i(m,c[h].y)}Math.abs(t-m)>s&&(m=t,v=e,d="down"===d?"up":"down",n.setAttribute(r,d))}function e(e){return l=e,o.requestAnimationFrame(t)}var i={el:document.documentElement,win:window,attribute:"data-scrolldir",dir:"down"},n=void 0,o=void 0,r=void 0,d=void 0,f=document.body,u=32,a=512,s=64,c=Array(u),l=void 0,m=void 0,v=0;return function(t){return n=t&&t.el||i.el,o=t&&t.win||i.win,r=t&&t.attribute||i.attribute,d=t&&t.direction||i.dir,t&&!0===t.off?(n.setAttribute(r,"off"),o.removeEventListener("scroll",e)):(m=o.scrollY||o.pageYOffset,n.setAttribute(r,d),o.addEventListener("scroll",e))}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.scrollDir=e()}(this,function(){"use strict";function t(){var t=r.scrollY||r.pageYOffset,e=c.timeStamp,p="down"===i?Math.max:Math.min,v=f.offsetHeight-r.innerHeight;if(t=Math.max(0,t),t=Math.min(v,t),s.unshift({y:t,t:e}),s.pop(),t===p(l,t))return m=e,void(l=t);var h=e-u;if(h>m){l=t;for(var b=0;b<d&&(s[b]&&!(s[b].t<h));b+=1)l=p(l,s[b].y)}Math.abs(t-l)>a&&(l=t,m=e,i="down"===i?"up":"down",o.setAttribute(n,i))}function e(e){return c=e,r.requestAnimationFrame(t)}var n="data-scrolldir",i="down",o=document.documentElement,r=window,f=document.body,d=32,u=512,a=64,s=Array(d),c=void 0,l=void 0,m=0;return function(t){return t&&(t.attribute&&(n=t.attribute),t.el&&(o=t.el),t.win&&(r=t.win),t.dir&&(i=t.dir),!0===t.off)?(o.setAttribute(n,"off"),r.removeEventListener("scroll",e)):(l=r.scrollY||r.pageYOffset,o.setAttribute(n,i),r.addEventListener("scroll",e))}});
{
"name": "scrolldir",
"version": "1.2.18",
"version": "1.2.23",
"description": "Vertical scroll direction in CSS",
"main": "dist/scrolldir.js",
"scripts": {
"test": "gulp test",
"test:es-check": "es-check check es5 dist/scrolldir.auto.js dist/scrolldir.js dist/scrolldir.min.js dist/scrolldir.auto.min.js",
"build": "npm run lint && rollup -c && rollup -c --environment entry:.auto && gulp",
"lint": "./node_modules/.bin/eslint .src/*.js",
"test": "gulp test && npm run test:es-check",
"test:es-check": "es-check es5 dist/scrolldir.auto.js dist/scrolldir.js dist/scrolldir.min.js dist/scrolldir.auto.min.js",
"build": "npm run lint && rollup -c && rollup -c --environment entry:.auto && gulp minify && npm test",
"lint": "eslint src/*.js --fix",
"postpublish": "git tag $npm_package_version && git push origin --tags"

@@ -34,20 +34,20 @@ },

"babel-core": "^6.26.0",
"babel-eslint": "^8.0.1",
"babel-preset-es2015-rollup": "^3.0.0",
"bower": "^1.7.9",
"es-check": "^1.0.0",
"es-check": "^2.0.0",
"eslint": "^4.1.0",
"eslint-config-airbnb": "^16.0.0",
"eslint-plugin-import": "^2.3.0",
"gulp": "^3.9.1",
"gulp-header": "^1.8.8",
"gulp-header": "^2.0.1",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^3.0.0",
"node-qunit-phantomjs": "^1.4.0",
"rollup": "^0.50.0",
"node-qunit-phantomjs": "^2.0.0",
"rollup": "^0.58.0",
"rollup-plugin-babel": "^3.0.0",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-eslint": "^4.0.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^2.0.0"
"rollup-plugin-commonjs": "^9.0.0",
"rollup-plugin-node-resolve": "^3.0.0"
},
"peerDependencies": {
"gulp": "5.x"
}
}

@@ -21,3 +21,3 @@ <figure align="center">

</a>
<a href="https://github.com/dollarshaveclub/scrolldir">
<a href="https://github.com/dollarshaveclub/scrolldir">
<img alt="Bower version" src="https://badge.fury.io/bo/scrolldir.svg" />

@@ -84,3 +84,3 @@ </a>

```sh
yarn add scrolldir
yarn add scrolldir
```

@@ -119,3 +119,3 @@

```javascript
scrollDir({ direction: 'up' }); // the default is 'down'
scrollDir({ dir: 'up' }); // the default is 'down'
```

@@ -122,0 +122,0 @@

@@ -5,15 +5,10 @@ // rollup bundle commands

import babel from 'rollup-plugin-babel';
import eslint from 'rollup-plugin-eslint';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel'
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
const name = process.env.entry ? '.auto' : '';
const name = process.env.entry ? '.auto' : ''
export default {
entry: `src/scrolldir${name}.js`,
dest: `dist/scrolldir${name}.js`,
format: 'umd',
moduleName: `scrollDir${name}`,
sourceMap: false, // removes the souremap at the bottom of the file
input: `src/scrolldir${name}.js`,
plugins: [

@@ -26,5 +21,2 @@ resolve({

commonjs(),
eslint({
exclude: [],
}),
babel({

@@ -34,2 +26,8 @@ exclude: 'node_modules/**',

],
};
output: {
dest: `dist/scrolldir${name}.js`,
format: 'umd',
name: `scrollDir${name}`,
sourceMap: false, // removes the souremap at the bottom of the file
}
}

@@ -1,3 +0,3 @@

import scrollDir from './scrolldir';
import scrollDir from './scrolldir'
scrollDir();
scrollDir()

@@ -1,33 +0,27 @@

const defaults = {
el: document.documentElement,
win: window,
attribute: 'data-scrolldir',
dir: 'down',
};
let el;
let win;
let attribute;
let dir; // 'up' or 'down'
const body = document.body;
const historyLength = 32; // Ticks to keep in history.
const historyMaxAge = 512; // History data time-to-live (ms).
const thresholdPixels = 64; // Ignore moves smaller than this.
const history = Array(historyLength);
let e; // last scroll event
let pivot; // "high-water mark"
let pivotTime = 0;
let attribute = 'data-scrolldir'
let dir = 'down' // 'up' or 'down'
let el = document.documentElement
let win = window
const body = document.body
const historyLength = 32 // Ticks to keep in history.
const historyMaxAge = 512 // History data time-to-live (ms).
const thresholdPixels = 64 // Ignore moves smaller than this.
const history = Array(historyLength)
let e // last scroll event
let pivot // "high-water mark"
let pivotTime = 0
function tick() {
let y = win.scrollY || win.pageYOffset;
const t = e.timeStamp;
const furthest = dir === 'down' ? Math.max : Math.min;
let y = win.scrollY || win.pageYOffset
const t = e.timeStamp
const furthest = dir === 'down' ? Math.max : Math.min
// Apply bounds to handle rubber banding
const yMax = body.offsetHeight - win.innerHeight;
y = Math.max(0, y);
y = Math.min(yMax, y);
const yMax = body.offsetHeight - win.innerHeight
y = Math.max(0, y)
y = Math.min(yMax, y)
// Update history
history.unshift({ y, t });
history.pop();
history.unshift({ y, t })
history.pop()

@@ -37,5 +31,5 @@ // Are we continuing in the same direction?

// Update "high-water mark" for current direction
pivotTime = t;
pivot = y;
return;
pivotTime = t
pivot = y
return
}

@@ -45,8 +39,8 @@ // else we have backed off high-water mark

// Apply max age to find current reference point
const cutoffTime = t - historyMaxAge;
const cutoffTime = t - historyMaxAge
if (cutoffTime > pivotTime) {
pivot = y;
pivot = y
for (let i = 0; i < historyLength; i += 1) {
if (!history[i] || history[i].t < cutoffTime) break;
pivot = furthest(pivot, history[i].y);
if (!history[i] || history[i].t < cutoffTime) break
pivot = furthest(pivot, history[i].y)
}

@@ -57,6 +51,6 @@ }

if (Math.abs(y - pivot) > thresholdPixels) {
pivot = y;
pivotTime = t;
dir = dir === 'down' ? 'up' : 'down';
el.setAttribute(attribute, dir);
pivot = y
pivotTime = t
dir = dir === 'down' ? 'up' : 'down'
el.setAttribute(attribute, dir)
}

@@ -66,18 +60,19 @@ }

function handler(event) {
e = event;
return win.requestAnimationFrame(tick);
e = event
return win.requestAnimationFrame(tick)
}
export default function scrollDir(opts) {
el = (opts && opts.el) || defaults.el;
win = (opts && opts.win) || defaults.win;
attribute = (opts && opts.attribute) || defaults.attribute;
dir = (opts && opts.direction) || defaults.dir;
// If opts.off, turn it off
// - set html[data-scrolldir="off"]
// - remove the event listener
if (opts && opts.off === true) {
el.setAttribute(attribute, 'off');
return win.removeEventListener('scroll', handler);
if (opts) {
if (opts.attribute) attribute = opts.attribute
if (opts.el) el = opts.el
if (opts.win) win = opts.win
if (opts.dir) dir = opts.dir
// If opts.off, turn it off
// - set html[data-scrolldir="off"]
// - remove the event listener
if (opts.off === true) {
el.setAttribute(attribute, 'off')
return win.removeEventListener('scroll', handler)
}
}

@@ -88,5 +83,5 @@

// - add the event listener
pivot = win.scrollY || win.pageYOffset;
el.setAttribute(attribute, dir);
return win.addEventListener('scroll', handler);
pivot = win.scrollY || win.pageYOffset
el.setAttribute(attribute, dir)
return win.addEventListener('scroll', handler)
}

Sorry, the diff of this file is not supported yet

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