From 6b3efbef8bad996a6048668f723d90ee631da54c Mon Sep 17 00:00:00 2001 From: Nathan Grebowiec Date: Fri, 12 Sep 2014 14:20:40 -0500 Subject: [PATCH] add support for random increment per image --- comcastify.js | 7 ++++++- example/example-random.html | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 example/example-random.html diff --git a/comcastify.js b/comcastify.js index 54f9474..ffea8d5 100644 --- a/comcastify.js +++ b/comcastify.js @@ -80,8 +80,13 @@ var comcastifyjs = (function () { img.style.visibility = 'visible'; if (params.loadMaxPercent > 0.0) { + var passedParams = Object.create(params); + if(passedParams.loadIncrement === 'random') { + passedParams.loadIncrement = Math.floor((Math.random() * 20) + 1); + } + // slowload using timeout since this is nicer to the browser :) - setTimeout(slowloadModiferCallback(slowload, params), params.loadSpeed); + setTimeout(slowloadModiferCallback(slowload, passedParams), params.loadSpeed); } } } diff --git a/example/example-random.html b/example/example-random.html new file mode 100644 index 0000000..cc36cf4 --- /dev/null +++ b/example/example-random.html @@ -0,0 +1,40 @@ + + + + comcastify.js - Sometimes images just load too damned fast! + + + + + +
+ http://violetadams.deviantart.com/art/Baby-sloth-385183627 +
+ +
+ http://mashable.com/2013/07/20/sloth-makeover/ +
+ +
+ http://mashable.com/2013/07/20/sloth-makeover/ +
+ +
+ http://www.wisegeek.com/what-are-the-main-components-of-a-sloth-diet.htm#sloth-in-tree-showing-claws +
+ + + + + + + \ No newline at end of file