Huge News!Announcing our $40M Series B led by Abstract Ventures.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.15 to 1.2.16

.eslintignore

5

.eslintrc.json

@@ -10,7 +10,10 @@ {

"foo": true,
"QUnit": true,
"scrollDir": true,
"window": true
},
"rules": {
"indent": 2
"indent": 2,
"semi": [2, "never"]
}
}

160

dist/scrolldir.auto.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory())
}(this, (() => {
const defaults = {
el: document.documentElement,
win: window,
attribute: 'data-scrolldir',
dir: 'down',
}
let el = void 0
let win = void 0
let attribute = void 0
let dir = void 0 // '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 = void 0 // last scroll event
let pivot = void 0 // "high-water mark"
let pivotTime = 0
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 body = document.body;
var historyLength = 32; // Ticks to keep in history.
var historyMaxAge = 512; // History data time-to-live (ms).
var thresholdPixels = 64; // Ignore moves smaller than this.
var history = Array(historyLength);
var e = void 0; // last scroll event
var pivot = void 0; // "high-water mark"
var pivotTime = 0;
function tick() {
let y = win.scrollY || win.pageYOffset
const t = e.timeStamp
const furthest = dir === 'down' ? Math.max : Math.min
function tick() {
var y = win.scrollY || win.pageYOffset;
var t = e.timeStamp;
var 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)
// Apply bounds to handle rubber banding
var yMax = body.offsetHeight - win.innerHeight;
y = Math.max(0, y);
y = Math.min(yMax, y);
// Update history
history.unshift({ y, t })
history.pop()
// Update history
history.unshift({ y: y, t: t });
history.pop();
// Are we continuing in the same direction?
if (y === furthest(pivot, y)) {
// Are we continuing in the same direction?
if (y === furthest(pivot, y)) {
// Update "high-water mark" for current direction
pivotTime = t;
pivot = y;
return;
}
// else we have backed off high-water mark
pivotTime = t
pivot = y
return
}
// else we have backed off high-water mark
// Apply max age to find current reference point
var cutoffTime = t - historyMaxAge;
if (cutoffTime > pivotTime) {
pivot = y;
for (var i = 0; i < historyLength; i += 1) {
if (!history[i] || history[i].t < cutoffTime) break;
pivot = furthest(pivot, history[i].y);
// Apply max age to find current reference point
const cutoffTime = t - historyMaxAge
if (cutoffTime > pivotTime) {
pivot = y
for (let i = 0; i < historyLength; i += 1) {
if (!history[i] || history[i].t < cutoffTime) break
pivot = furthest(pivot, history[i].y)
}
}
// Have we exceeded threshold?
if (Math.abs(y - pivot) > thresholdPixels) {
pivot = y
pivotTime = t
dir = dir === 'down' ? 'up' : 'down'
el.setAttribute(attribute, dir)
}
}
// Have we exceeded threshold?
if (Math.abs(y - pivot) > thresholdPixels) {
pivot = y;
pivotTime = t;
dir = dir === 'down' ? 'up' : 'down';
el.setAttribute(attribute, dir);
function handler(event) {
e = event
return win.requestAnimationFrame(tick)
}
}
function handler(event) {
e = event;
return win.requestAnimationFrame(tick);
}
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
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.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);
// else, turn it on
// - set html[data-scrolldir="down"]
// - add the event listener
pivot = win.scrollY || win.pageYOffset
el.setAttribute(attribute, dir)
return win.addEventListener('scroll', handler)
}
// else, turn it on
// - set html[data-scrolldir="down"]
// - add the event listener
pivot = win.scrollY || win.pageYOffset;
el.setAttribute(attribute, dir);
return win.addEventListener('scroll', handler);
}
scrollDir();
})));
scrollDir()
})))

@@ -7,3 +7,22 @@ /**

* @license MIT
**/
!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) { typeof exports === 'object' && typeof module !== 'undefined' ? e() : typeof define === 'function' && define.amd ? define(e) : e() }(0, () => {
function t() {
let t = o.scrollY || o.pageYOffset,
e = l.timeStamp,
i = d === 'down' ? 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); const b = e - u; if (b > v) { m = t; for (let 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 = d === 'down' ? '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 (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.scrollDir = factory());
}(this, (function () { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.scrollDir = factory())
}(this, (() => {
const defaults = {
el: document.documentElement,
win: window,
attribute: 'data-scrolldir',
dir: 'down',
}
let el = void 0
let win = void 0
let attribute = void 0
let dir = void 0 // '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 = void 0 // last scroll event
let pivot = void 0 // "high-water mark"
let pivotTime = 0
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 body = document.body;
var historyLength = 32; // Ticks to keep in history.
var historyMaxAge = 512; // History data time-to-live (ms).
var thresholdPixels = 64; // Ignore moves smaller than this.
var history = Array(historyLength);
var e = void 0; // last scroll event
var pivot = void 0; // "high-water mark"
var pivotTime = 0;
function tick() {
let y = win.scrollY || win.pageYOffset
const t = e.timeStamp
const furthest = dir === 'down' ? Math.max : Math.min
function tick() {
var y = win.scrollY || win.pageYOffset;
var t = e.timeStamp;
var 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)
// Apply bounds to handle rubber banding
var yMax = body.offsetHeight - win.innerHeight;
y = Math.max(0, y);
y = Math.min(yMax, y);
// Update history
history.unshift({ y, t })
history.pop()
// Update history
history.unshift({ y: y, t: t });
history.pop();
// Are we continuing in the same direction?
if (y === furthest(pivot, y)) {
// Are we continuing in the same direction?
if (y === furthest(pivot, y)) {
// Update "high-water mark" for current direction
pivotTime = t;
pivot = y;
return;
}
// else we have backed off high-water mark
pivotTime = t
pivot = y
return
}
// else we have backed off high-water mark
// Apply max age to find current reference point
var cutoffTime = t - historyMaxAge;
if (cutoffTime > pivotTime) {
pivot = y;
for (var i = 0; i < historyLength; i += 1) {
if (!history[i] || history[i].t < cutoffTime) break;
pivot = furthest(pivot, history[i].y);
// Apply max age to find current reference point
const cutoffTime = t - historyMaxAge
if (cutoffTime > pivotTime) {
pivot = y
for (let i = 0; i < historyLength; i += 1) {
if (!history[i] || history[i].t < cutoffTime) break
pivot = furthest(pivot, history[i].y)
}
}
// Have we exceeded threshold?
if (Math.abs(y - pivot) > thresholdPixels) {
pivot = y
pivotTime = t
dir = dir === 'down' ? 'up' : 'down'
el.setAttribute(attribute, dir)
}
}
// Have we exceeded threshold?
if (Math.abs(y - pivot) > thresholdPixels) {
pivot = y;
pivotTime = t;
dir = dir === 'down' ? 'up' : 'down';
el.setAttribute(attribute, dir);
function handler(event) {
e = event
return win.requestAnimationFrame(tick)
}
}
function handler(event) {
e = event;
return win.requestAnimationFrame(tick);
}
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
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.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);
// else, turn it on
// - set html[data-scrolldir="down"]
// - add the event listener
pivot = win.scrollY || win.pageYOffset
el.setAttribute(attribute, dir)
return win.addEventListener('scroll', handler)
}
// else, turn it on
// - set html[data-scrolldir="down"]
// - add the event listener
pivot = win.scrollY || win.pageYOffset;
el.setAttribute(attribute, dir);
return win.addEventListener('scroll', handler);
}
return scrollDir;
})));
return scrollDir
})))

@@ -7,3 +7,22 @@ /**

* @license MIT
**/
!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) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = e() : typeof define === 'function' && define.amd ? define(e) : t.scrollDir = e() }(this, () => {
function t() {
let t = o.scrollY || o.pageYOffset,
e = l.timeStamp,
i = d === 'down' ? 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); const b = e - a; if (b > v) { m = t; for (let 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 = d === 'down' ? '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)) }
}))

@@ -1,8 +0,8 @@

const gulp = require('gulp');
const head = require('gulp-header');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const qunit = require('node-qunit-phantomjs');
const gulp = require('gulp')
const head = require('gulp-header')
const uglify = require('gulp-uglify')
const rename = require('gulp-rename')
const qunit = require('node-qunit-phantomjs')
const pkg = require('./package.json');
const pkg = require('./package.json')

@@ -18,9 +18,9 @@ const banner = [

'',
].join('\n');
].join('\n')
gulp.task('test', () => {
qunit('tests/auto/index.html');
qunit('tests/standard/index.html');
qunit('tests/off/index.html');
});
qunit('tests/auto/index.html')
qunit('tests/standard/index.html')
qunit('tests/off/index.html')
})

@@ -32,3 +32,3 @@ gulp.task('minify', () => {

.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist/'));
.pipe(gulp.dest('dist/'))
gulp.src('dist/scrolldir.auto.js')

@@ -38,5 +38,5 @@ .pipe(uglify())

.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist/'));
});
.pipe(gulp.dest('dist/'))
})
gulp.task('default', ['test', 'minify']);
gulp.task('default', ['test', 'minify'])
{
"name": "scrolldir",
"version": "1.2.15",
"version": "1.2.16",
"description": "Vertical scroll direction in CSS",
"main": "dist/scrolldir.min.js",
"scripts": {
"lint": "node_modules/eslint/bin/eslint.js . --fix",
"test": "gulp test",

@@ -8,0 +9,0 @@ "build": "rollup -c && rollup -c --environment entry:.auto && gulp",

@@ -5,8 +5,8 @@ // 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 eslint from 'rollup-plugin-eslint'
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' : ''

@@ -33,2 +33,2 @@ export default {

],
};
}

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

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

@@ -6,29 +6,29 @@ const defaults = {

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 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
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()

@@ -38,5 +38,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
}

@@ -46,8 +46,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)
}

@@ -58,6 +58,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)
}

@@ -67,11 +67,11 @@ }

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;
el = (opts && opts.el) || defaults.el
win = (opts && opts.win) || defaults.win
attribute = (opts && opts.attribute) || defaults.attribute
dir = (opts && opts.direction) || defaults.dir

@@ -82,4 +82,4 @@ // If opts.off, turn it off

if (opts && opts.off === true) {
el.setAttribute(attribute, 'off');
return win.removeEventListener('scroll', handler);
el.setAttribute(attribute, 'off')
return win.removeEventListener('scroll', handler)
}

@@ -90,5 +90,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)
}

@@ -1,6 +0,6 @@

QUnit.test( "hello test", function(assert) {
assert.ok(1 == "1", "Passed!");
});
QUnit.test( "Is scroll intent there?", function(assert) {
assert.equal(document.querySelector('[data-scrolldir]').getAttribute('data-scrolldir'), 'down', 'there should be a scroll intent');
});
QUnit.test('hello test', (assert) => {
assert.ok(1 == '1', 'Passed!')
})
QUnit.test('Is scroll intent there?', (assert) => {
assert.equal(document.querySelector('[data-scrolldir]').getAttribute('data-scrolldir'), 'down', 'there should be a scroll intent')
})

@@ -1,5 +0,5 @@

QUnit.test( "Is scrolldir there?", function(assert) {
scrollDir();
scrollDir({off: true});
assert.equal(document.querySelector('[data-scrolldir]').getAttribute('data-scrolldir'), 'off', 'there should not be scrolldir');
});
QUnit.test('Is scrolldir there?', (assert) => {
scrollDir()
scrollDir({ off: true })
assert.equal(document.querySelector('[data-scrolldir]').getAttribute('data-scrolldir'), 'off', 'there should not be scrolldir')
})

@@ -1,20 +0,20 @@

QUnit.test( "hello test", function(assert) {
scrollDir();
assert.ok(1 == "1", "Passed!");
});
QUnit.test( "Is scroll intent there?", function(assert) {
scrollDir();
assert.equal(document.querySelector('[data-scrolldir]').getAttribute('data-scrolldir'), 'down', 'there should be a scroll intent');
});
QUnit.test( "scrollDir off", function(assert) {
scrollDir({off: true});
assert.equal(document.querySelector('[data-scrolldir]').getAttribute('data-scrolldir'), 'off', 'scrolldir should read as off');
});
QUnit.test( "scrollDir has a different attribute", function(assert) {
scrollDir({attribute: 'data-scroll-direction'});
assert.equal(document.querySelector('[data-scroll-direction]').getAttribute('data-scroll-direction'), 'down', 'scrolldir attribute should be scroll-direction');
});
QUnit.test( "scrollDir has a different attribute", function(assert) {
scrollDir({el: document.body, attribute: 'data-scroll-new-attribute'});
assert.equal(document.querySelector('[data-scroll-new-attribute]').getAttribute('data-scroll-new-attribute'), 'down', 'scrolldir attribute should be on a new element');
});
QUnit.test('hello test', (assert) => {
scrollDir()
assert.ok(1 == '1', 'Passed!')
})
QUnit.test('Is scroll intent there?', (assert) => {
scrollDir()
assert.equal(document.querySelector('[data-scrolldir]').getAttribute('data-scrolldir'), 'down', 'there should be a scroll intent')
})
QUnit.test('scrollDir off', (assert) => {
scrollDir({ off: true })
assert.equal(document.querySelector('[data-scrolldir]').getAttribute('data-scrolldir'), 'off', 'scrolldir should read as off')
})
QUnit.test('scrollDir has a different attribute', (assert) => {
scrollDir({ attribute: 'data-scroll-direction' })
assert.equal(document.querySelector('[data-scroll-direction]').getAttribute('data-scroll-direction'), 'down', 'scrolldir attribute should be scroll-direction')
})
QUnit.test('scrollDir has a different attribute', (assert) => {
scrollDir({ el: document.body, attribute: 'data-scroll-new-attribute' })
assert.equal(document.querySelector('[data-scroll-new-attribute]').getAttribute('data-scroll-new-attribute'), 'down', 'scrolldir attribute should be on a new element')
})

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