svelte-lazy
Advanced tools
+30
-30
@@ -774,33 +774,33 @@ (function (global, factory) { | ||
| function throttle(func, wait, options) { | ||
| let context, args, result; | ||
| let timeout = null; | ||
| let previous = 0; | ||
| if (!options) options = {}; | ||
| const later = function() { | ||
| previous = options.leading === false ? 0 : new Date(); | ||
| timeout = null; | ||
| result = func.apply(context, args); | ||
| if (!timeout) context = args = null; | ||
| }; | ||
| let context, args, result; | ||
| let timeout = null; | ||
| let previous = 0; | ||
| if (!options) options = {}; | ||
| const later = function() { | ||
| previous = options.leading === false ? 0 : new Date(); | ||
| timeout = null; | ||
| result = func.apply(context, args); | ||
| if (!timeout) context = args = null; | ||
| }; | ||
| return function(event) { | ||
| const now = new Date(); | ||
| if (!previous && options.leading === false) previous = now; | ||
| const remaining = wait - (now - previous); | ||
| context = this; | ||
| args = arguments; | ||
| if (remaining <= 0 || remaining > wait) { | ||
| if (timeout) { | ||
| clearTimeout(timeout); | ||
| timeout = null; | ||
| } | ||
| previous = now; | ||
| result = func.apply(context, args); | ||
| if (!timeout) context = args = null; | ||
| } else if (!timeout && options.trailing !== false) { | ||
| timeout = setTimeout(later, remaining); | ||
| } | ||
| return result; | ||
| }; | ||
| } | ||
| return function(event) { | ||
| const now = new Date(); | ||
| if (!previous && options.leading === false) previous = now; | ||
| const remaining = wait - (now - previous); | ||
| context = this; | ||
| args = arguments; | ||
| if (remaining <= 0 || remaining > wait) { | ||
| if (timeout) { | ||
| clearTimeout(timeout); | ||
| timeout = null; | ||
| } | ||
| previous = now; | ||
| result = func.apply(context, args); | ||
| if (!timeout) context = args = null; | ||
| } else if (!timeout && options.trailing !== false) { | ||
| timeout = setTimeout(later, remaining); | ||
| } | ||
| return result; | ||
| }; | ||
| } | ||
@@ -807,0 +807,0 @@ function instance($$self, $$props, $$invalidate) { |
+30
-30
@@ -768,33 +768,33 @@ function noop() { } | ||
| function throttle(func, wait, options) { | ||
| let context, args, result; | ||
| let timeout = null; | ||
| let previous = 0; | ||
| if (!options) options = {}; | ||
| const later = function() { | ||
| previous = options.leading === false ? 0 : new Date(); | ||
| timeout = null; | ||
| result = func.apply(context, args); | ||
| if (!timeout) context = args = null; | ||
| }; | ||
| let context, args, result; | ||
| let timeout = null; | ||
| let previous = 0; | ||
| if (!options) options = {}; | ||
| const later = function() { | ||
| previous = options.leading === false ? 0 : new Date(); | ||
| timeout = null; | ||
| result = func.apply(context, args); | ||
| if (!timeout) context = args = null; | ||
| }; | ||
| return function(event) { | ||
| const now = new Date(); | ||
| if (!previous && options.leading === false) previous = now; | ||
| const remaining = wait - (now - previous); | ||
| context = this; | ||
| args = arguments; | ||
| if (remaining <= 0 || remaining > wait) { | ||
| if (timeout) { | ||
| clearTimeout(timeout); | ||
| timeout = null; | ||
| } | ||
| previous = now; | ||
| result = func.apply(context, args); | ||
| if (!timeout) context = args = null; | ||
| } else if (!timeout && options.trailing !== false) { | ||
| timeout = setTimeout(later, remaining); | ||
| } | ||
| return result; | ||
| }; | ||
| } | ||
| return function(event) { | ||
| const now = new Date(); | ||
| if (!previous && options.leading === false) previous = now; | ||
| const remaining = wait - (now - previous); | ||
| context = this; | ||
| args = arguments; | ||
| if (remaining <= 0 || remaining > wait) { | ||
| if (timeout) { | ||
| clearTimeout(timeout); | ||
| timeout = null; | ||
| } | ||
| previous = now; | ||
| result = func.apply(context, args); | ||
| if (!timeout) context = args = null; | ||
| } else if (!timeout && options.trailing !== false) { | ||
| timeout = setTimeout(later, remaining); | ||
| } | ||
| return result; | ||
| }; | ||
| } | ||
@@ -801,0 +801,0 @@ function instance($$self, $$props, $$invalidate) { |
+2
-1
@@ -6,3 +6,4 @@ { | ||
| "main": "index.js", | ||
| "version": "0.1.8", | ||
| "version": "0.1.9", | ||
| "repository": "leafOfTree/svelte-lazy", | ||
| "scripts": { | ||
@@ -9,0 +10,0 @@ "test": "rollup -c ./test/rollup.config.js -w", |
+7
-4
| # svelte-lazy | ||
| <p align="center"> | ||
| <img alt="demo image" src="https://raw.githubusercontent.com/leafOfTree/leafOfTree.github.io/HEAD/svelte-lazy.gif" width="300" height="300" /> | ||
| </p> | ||
| A svelte component to lazyload any content including images. | ||
@@ -28,3 +32,3 @@ | ||
| > The Number value use `px` as unit. | ||
| > The Number value use `px` as unit. | ||
@@ -37,5 +41,4 @@ - `fadeOption: Object` Default: `{ delay: 0, duration: 400 }`. Option for the fade transition. Set `null` to disable. | ||
| See [demo](https://svelte.dev/repl/6d7714fa3cce4909af6c6d187271e0a1?version=3.6.10) here. | ||
| See [demo on svelte.dev/repl](https://svelte.dev/repl/6d7714fa3cce4909af6c6d187271e0a1?version=3.6.10). | ||
| <img alt="demo image" src="https://raw.githubusercontent.com/leafOfTree/leafOfTree.github.io/HEAD/svelte-lazy.gif" width="300" height="300" /> | ||
@@ -47,3 +50,3 @@ ## Development | ||
| # Open test/index.html or open a local server | ||
| # Open test/index.html or start a local server | ||
| serve test | ||
@@ -50,0 +53,0 @@ |
+31
-31
@@ -68,34 +68,34 @@ <div use:load> | ||
| // from underscore souce code | ||
| function throttle(func, wait, options) { | ||
| let context, args, result; | ||
| let timeout = null; | ||
| let previous = 0; | ||
| if (!options) options = {}; | ||
| const later = function() { | ||
| previous = options.leading === false ? 0 : new Date(); | ||
| timeout = null; | ||
| result = func.apply(context, args); | ||
| if (!timeout) context = args = null; | ||
| }; | ||
| function throttle(func, wait, options) { | ||
| let context, args, result; | ||
| let timeout = null; | ||
| let previous = 0; | ||
| if (!options) options = {}; | ||
| const later = function() { | ||
| previous = options.leading === false ? 0 : new Date(); | ||
| timeout = null; | ||
| result = func.apply(context, args); | ||
| if (!timeout) context = args = null; | ||
| }; | ||
| return function(event) { | ||
| const now = new Date(); | ||
| if (!previous && options.leading === false) previous = now; | ||
| const remaining = wait - (now - previous); | ||
| context = this; | ||
| args = arguments; | ||
| if (remaining <= 0 || remaining > wait) { | ||
| if (timeout) { | ||
| clearTimeout(timeout); | ||
| timeout = null; | ||
| } | ||
| previous = now; | ||
| result = func.apply(context, args); | ||
| if (!timeout) context = args = null; | ||
| } else if (!timeout && options.trailing !== false) { | ||
| timeout = setTimeout(later, remaining); | ||
| } | ||
| return result; | ||
| }; | ||
| }; | ||
| return function(event) { | ||
| const now = new Date(); | ||
| if (!previous && options.leading === false) previous = now; | ||
| const remaining = wait - (now - previous); | ||
| context = this; | ||
| args = arguments; | ||
| if (remaining <= 0 || remaining > wait) { | ||
| if (timeout) { | ||
| clearTimeout(timeout); | ||
| timeout = null; | ||
| } | ||
| previous = now; | ||
| result = func.apply(context, args); | ||
| if (!timeout) context = args = null; | ||
| } else if (!timeout && options.trailing !== false) { | ||
| timeout = setTimeout(later, remaining); | ||
| } | ||
| return result; | ||
| }; | ||
| }; | ||
| </script> |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
53951
0.44%54
5.88%