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

onscrolling

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onscrolling - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0-beta.1

.github/workflows/build.yml

119

package.json
{
"name": "onscrolling",
"version": "1.0.0",
"description": "A better, smoother, more performant window.onscroll event interface using requestAnimationFrame for performance and mobile-compatibility",
"main": "dist/onscrolling.js",
"jsnext:main": "src/onscrolling.js",
"scripts": {
"test": "npm run build && npm run lint-tests && mocha-chrome ./test/index.html",
"test-ghetto": "open test/index.html",
"lint-src": "jshint src/onscrolling.js",
"lint-tests": "jshint test/onscroll-test.js && jshint --extract=auto test/index.html",
"build": "npm run lint-src && rollup src/onscrolling.js --format umd --name onscrolling --file dist/onscrolling.js",
"build-babel": "babel --modules umd src/onscrolling.js -o dist/onscrolling.js"
},
"repository": {
"type": "git",
"url": "https://github.com/acusti/onscrolling.git"
},
"keywords": [
"onscroll",
"scroll",
"browser",
"requestAnimationFrame",
"raf",
"event",
"mobile"
],
"author": "Andrew Patton <andrew@acusti.ca> (http://www.acusti.ca)",
"license": "CC0-1.0",
"bugs": {
"url": "https://github.com/acusti/onscrolling/issues"
},
"homepage": "https://github.com/acusti/onscrolling",
"devDependencies": {
"jshint": "^2.6.3",
"mocha": "^6.2.1",
"mocha-chrome": "^2.1.0",
"rollup": "^1.23.1",
"should": "^13.2.3",
"sinon": "^7.5.0"
},
"dependencies": {},
"jspm": {
"directories": {
"lib": "src"
"name": "onscrolling",
"version": "2.0.0-beta.1",
"description": "A better, smoother, more performant window.onscroll event interface using requestAnimationFrame for performance and mobile-compatibility",
"type": "module",
"sideEffects": false,
"exports": "./dist/onscrolling.js",
"main": "./dist/onscrolling.js",
"types": "./dist/onscrolling.d.ts",
"scripts": {
"build": "npm run lint && tsc --build",
"format": "prettier --write .",
"lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
"test": "vitest",
"typecheck": "tsc"
},
"main": "onscroll",
"format": "es6"
}
"repository": {
"type": "git",
"url": "https://github.com/acusti/onscrolling.git"
},
"prettier": {
"arrowParens": "always",
"singleQuote": true,
"printWidth": 84,
"tabWidth": 4,
"trailingComma": "all",
"useTabs": false,
"overrides": [
{
"files": "*.css",
"options": {
"singleQuote": false
}
}
]
},
"keywords": [
"onscroll",
"scroll",
"browser",
"requestAnimationFrame",
"raf",
"event",
"mobile"
],
"author": "Andrew Patton <andrew@acusti.ca> (http://www.acusti.ca)",
"license": "CC0-1.0",
"bugs": {
"url": "https://github.com/acusti/onscrolling/issues"
},
"homepage": "https://github.com/acusti/onscrolling",
"devDependencies": {
"@testing-library/jest-dom": "^6.4.6",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@typescript-eslint/parser": "^7.13.0",
"@vitest/coverage-v8": "^1.6.0",
"eslint": "^8",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-cypress": "^3.3.0",
"eslint-plugin-deprecation": "^3.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-jest-dom": "^5.4.0",
"eslint-plugin-markdown": "^5.0.0",
"eslint-plugin-testing-library": "^6.2.2",
"eslint-plugin-typescript-sort-keys": "^3.2.0",
"happy-dom": "^14.12.0",
"prettier": "^2.8.0",
"typescript": "^5.3.3",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
},
"dependencies": {}
}

@@ -1,2 +0,2 @@

# Jank-free onscrolling&nbsp; [![Build Status](https://travis-ci.org/acusti/onscrolling.svg?branch=master)](https://travis-ci.org/acusti/onscrolling)
# Jank-free onscrolling&nbsp; [![build workflow](https://github.com/acusti/onscrolling/actions/workflows/deploy.yml/badge.svg)](https://github.com/acusti/onscrolling/actions)

@@ -9,36 +9,26 @@ A better, smoother, more performant onscroll event interface based on the concepts from [this html5rocks tutorial][html5rocks-tutorial]. It uses `requestAnimationFrame` plus debouncing for performance and mobile-compatibility (thanks to the `touchmove` event), giving you a fighting chance to achieve the hallowed 60fps of lore with your scroll-listening UI.

The module exports an `onscrolling` module if being used with a CommonJS or AMD module loader, or else exposes a global object as `window.onscrolling`.
The module is ESM-only and exports a single default `onscrolling` function:
### onscrolling( callback )
### onscrolling( listener )
#### `callback` function
#### `listener` function `(payload: { scrollX: number; scrollY: number }) => void`
The function to call on a scroll event. In this default version, the module will only call the `callback()` when the page has been scrolled vertically. It will be passed the current vertical scroll position to the callback.
The function to call on a scroll event with a `{ scrollX: number; scrollY: number }` payload object. In this default version, the module will only invoke the listener when the page has been scrolled vertically.
### onscrolling( direction, callback )
### onscrolling( listener, options )
#### `direction` string
#### `listener` function `(payload: { scrollX: number; scrollY: number }) => void`
The scroll axis to monitor. Values can be `x` or `horizontal` to trigger when the page is scrolled horizontally, `y` or `vertical` to trigger when the page is scrolled vertically (the default behavior if not direction is provided), or `any` to trigger when the page is scrolled in any direction.
The function to call on a scroll event with a `{ scrollX: number; scrollY: number }` payload object. The listener is invoked when the page is scrolled in any of the direction specified in the `options` object (only once per event).
#### `callback` function
#### `options` object `{ horizontal?: boolean; vertical?: boolean; x?: boolean; y?: boolean }`
The function to call when the page is scrolled. It will be passed the current scroll position as a number if listening to a single scroll direction, or an array `[x,y]` if callback is listening for `any` scroll direction change.
The scroll axis or axes to monitor. `x` is an alias for `horizontal`, and `y` is an alias for `vertical`. If neither horizontal nor vertical are true, `vertical` is used as the default. To listen for any scroll event in any direction, set both `horizontal` and `vertical` to `true`.
### onscrolling.remove( fn )
### onscrolling return value
#### `fn` function
#### `onscrolling` function `(listener: Listener, options?: Options) => () => void`
The function to remove from the onscroll handler. In this default version, the function will be removed from the vertical scroll queue.
The `onscrolling` function returns a cleanup function that takes no arguments and is used to remove the passed-in scroll event `listener`.
### onscrolling.remove( direction, fn )
#### `direction` string
The scroll axis that `fn` was listening for. Can be `x` or `horizontal`, `y` or `vertical`, or `any` to match how the function was originally attached. If a function was attached to multiple scroll directions, calling this method for a specific direction will only remove the listener for that direction.
#### `fn` function
The function to remove from the onscroll handler for the specified direction.
## Dependencies

@@ -54,14 +44,13 @@

Tests use Mocha + Should.js + Sinon. Using `npm test` will run the tests in headless Chrome via mocha-chrome, but you can also open `test/index.html` directly in a browser.
Tests use vitest + happy-dom, and can be run with `yarn test`.
## TODO
- [ ] Add optional param to specify an object other than `window` to monitor for scroll events
- [ ] Expose `measure` and `mutate` functions to attach handlers specifically to the measuring (read) or mutating (write) portion of each cycle to minimize layout calculations
- [ ] Add optional param to specify an object other than `window` to monitor for scroll events
- [ ] Expose `measure` and `mutate` functions to attach handlers specifically to the measuring (read) or mutating (write) portion of each cycle to minimize layout calculations
## Misc
*Note: This package was formerly known as [jank-free-onscroll][]*
_Note: This package was formerly known as [jank-free-onscroll][]_
[html5rocks-tutorial]: http://www.html5rocks.com/en/tutorials/speed/animations/#debouncing-scroll-events

@@ -68,0 +57,0 @@ [raf-caniuse]: http://caniuse.com/#feat=requestanimationframe

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