scroll-watcher
Advanced tools
Comparing version 0.1.0 to 0.2.0
{ | ||
"name": "scroll-watcher", | ||
"version": "0.1.0", | ||
"description": "A (yet another) cross-browser, event-based, scroll watcher.", | ||
"version": "0.2.0", | ||
"description": "A lightweight, blazing fast, rAF based, scroll watcher.", | ||
"author": "Jonatas Walker", | ||
@@ -10,3 +10,3 @@ "homepage": "https://github.com/jonataswalker/scroll-watcher", | ||
"rollup": { | ||
"entry": "src/js/main.js", | ||
"entry": "src/main.js", | ||
"dest": "build/scroll-watcher.js", | ||
@@ -23,22 +23,32 @@ "moduleName": "ScrollWatcher" | ||
"devDependencies": { | ||
"autoprefixer": "^6.4.1", | ||
"clean-css": "^3.4.19", | ||
"eslint": "^3.5.0", | ||
"eslint-config-jwalker": "^1.9.0", | ||
"node-sass": "^3.9.3", | ||
"node-sass-json-importer": "^2.1.1", | ||
"casperjs": "^1.1.3", | ||
"eslint": "^3.6.0", | ||
"eslint-config-jwalker": "^1.10.0", | ||
"nodemon": "^1.10.2", | ||
"parallelshell": "^2.0.0", | ||
"postcss-cli": "^2.6.0", | ||
"rollup": "^0.35.7", | ||
"rollup-plugin-buble": "^0.13.0", | ||
"rollup": "^0.36.0", | ||
"rollup-plugin-buble": "^0.14.0", | ||
"rollup-plugin-commonjs": "^5.0.4", | ||
"rollup-plugin-json": "^2.0.2", | ||
"rollup-plugin-node-resolve": "^2.0.0", | ||
"uglify-js": "^2.7.3" | ||
}, | ||
"eslintConfig": { | ||
"extends": "jwalker" | ||
"extends": "jwalker", | ||
"rules": { | ||
"no-console": 0, | ||
"no-use-before-define": 1, | ||
"vars-on-top": 0 | ||
}, | ||
"globals": { | ||
"casper": true, | ||
"patchRequire": true, | ||
"phantom": true | ||
} | ||
}, | ||
"scripts": { | ||
"test": "make test" | ||
}, | ||
"dependencies": { | ||
"tiny-emitter": "^1.1.0" | ||
} | ||
} |
# scroll-watcher | ||
A (yet another) cross-browser, event-based, scroll watcher. | ||
A lightweight, blazing fast, [rAF](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame) based, scroll watcher. | ||
A more up-to-date approach to this **_scrolling watchers_** stuff. Slightly inspired by [scrollMonitor](https://github.com/stutrek/scrollMonitor). | ||
### Demos | ||
→ [Scrolling, Moving and Recalculating](https://jonataswalker.github.io/scroll-watcher/examples/example.html) | ||
→ [Static Website Menu](https://jonataswalker.github.io/scroll-watcher/examples/example2.html) | ||
## How to use it? | ||
##### → CDN Hosted - [jsDelivr](http://www.jsdelivr.com/projects/scroll-watcher) | ||
```HTML | ||
<script src="//cdn.jsdelivr.net/scroll-watcher/latest/scroll-watcher.min.js"></script> | ||
``` | ||
##### → Self hosted | ||
Download [latest release](https://github.com/jonataswalker/scroll-watcher/releases/latest). | ||
##### → [NPM](https://www.npmjs.com/package/scroll-watcher) | ||
``` | ||
npm install scroll-watcher | ||
``` | ||
##### Instantiate and watch for a specific (or a list) DOM element | ||
```javascript | ||
var scroll = new ScrollWatcher(); | ||
scroll.watch('my-element') | ||
.on('enter', function (evt) { | ||
console.log('I'm partially inside viewport'); | ||
}) | ||
.on('exit', function (evt) { | ||
console.log('I'm out of viewport'); | ||
}) | ||
.on('enter:full', function (evt) { | ||
console.log('I'm entirely within the viewport'); | ||
}) | ||
.on('exit:partial', function (evt) { | ||
console.log('I'm partially out of viewport'); | ||
}); | ||
``` | ||
## Events `on/once/off` | ||
You can simply watch for scrolling action: | ||
```javascript | ||
var watcher = new ScrollWatcher(); | ||
watcher.on('scrolling', function(evt) { | ||
console.log(evt); | ||
}); | ||
// or just once | ||
watcher.once('scrolling', function(evt) { | ||
console.log(evt); | ||
}); | ||
// and turn it off (later) | ||
watcher.off('scrolling'); | ||
``` | ||
## Credits | ||
Thanks to [@scottcorgan](https://github.com/scottcorgan) for his great [tiny-emitter](https://github.com/scottcorgan/tiny-emitter). | ||
## License | ||
[Unlicense](https://github.com/jonataswalker/scroll-watcher/blob/master/LICENSE) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
60402
10
25
1178
65
1
1
+ Addedtiny-emitter@^1.1.0
+ Addedtiny-emitter@1.2.0(transitive)