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

scrollwatch

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scrollwatch - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

bower.json

4

package.json
{
"name": "scrollwatch",
"version": "1.0.0",
"version": "1.1.0",
"author": "Evan Dull <evandull@gmail.com>",
"description": "Easily add lazy loading, infinite scrolling, or any other dynamic interaction based on scroll position (with no dependencies).",
"main": "./dist/ScrollWatch-1.0.0.min.js",
"main": "./dist/ScrollWatch-1.1.0.min.js",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

@@ -18,2 +18,6 @@ 'use strict';

inViewClass: 'scroll-watch-in-view',
debounce: false,
debounceTriggerLeading: false,
scrollDebounce: 250,
resizeDebounce: 250,
scrollThrottle: 250,

@@ -103,2 +107,66 @@ resizeThrottle: 250,

// http://underscorejs.org/#debounce
var debounce = function(func, wait, immediate) {
var timeout;
var args;
var context;
var timestamp;
var result;
var later = function() {
var last = new Date().getTime() - timestamp;
if (last < wait && last >= 0) {
timeout = setTimeout(later, wait - last);
} else {
timeout = null;
if (!immediate) {
result = func.apply(context, args);
if (!timeout) {
context = args = null;
}
}
}
};
return function() {
var callNow = immediate && !timeout;
context = this;
args = arguments;
timestamp = new Date().getTime();
if (!timeout) {
timeout = setTimeout(later, wait);
}
if (callNow) {
result = func.apply(context, args);
context = args = null;
}
return result;
};
};
// Get the scrolling container element to watch if it's not the default window/documentElement.

@@ -517,5 +585,14 @@ var saveContainerElement = function() {

// to 'this', give each instance it's own event handler.
data.scrollHandler = throttle(handler.bind(this), data.config.scrollThrottle, this);
data.resizeHandler = throttle(handler.bind(this), data.config.resizeThrottle, this);
if (data.config.debounce) {
data.scrollHandler = debounce(handler.bind(this), data.config.scrollDebounce, data.config.debounceTriggerLeading);
data.resizeHandler = debounce(handler.bind(this), data.config.resizeDebounce, data.config.debounceTriggerLeading);
} else {
data.scrollHandler = throttle(handler.bind(this), data.config.scrollThrottle, this);
data.resizeHandler = throttle(handler.bind(this), data.config.resizeThrottle, this);
}
saveContainerElement.call(this);

@@ -522,0 +599,0 @@ addListeners.call(this);

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