Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
Some fixes and update to docts
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Kos committed Sep 10, 2014
1 parent d56d068 commit 1d97099
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ With all this internet going around, sometimes you just want to experience the t
});
```
4. Switch up parameters to change your experience:
* **elements** list of DOM elements to limit comcastification to.
* **boxColor** Hex color for the box placed over images.
* **loadMaxPercent** Max percentage of image to load.
* **loadSpeed** Speed to load your images to their max in ms.
Expand Down
15 changes: 6 additions & 9 deletions comcastify.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var comcastifyjs = (function () {

// calculate new height
var newTopClip = slowloadDiv.slothifyData.imageTopClip + args.loadIncrement;
var img = slowloadDiv.previousSibling;
var img = slowloadDiv.slothifyData.img;
slowloadDiv.style.width = img.offsetWidth + 'px';
slowloadDiv.style.height = img.offsetHeight + 'px';
slowloadDiv.style.top = img.offsetTop + 'px';
Expand All @@ -15,18 +15,14 @@ var comcastifyjs = (function () {
// update slowload div
slowloadDiv.style.clip = 'rect(' + newTopClip + 'px auto auto auto)';

// check stopping conditions
var maxImageHeight = img.height * args.loadMaxPercent;

if (!img.complete) {
setTimeout(slowloadModiferCallback(slowloadDiv, args), args.loadSpeed);
}
if (typeof img.naturalHeight !== "undefined" && img.naturalWidth === 0) {
} else if (typeof img.naturalHeight !== "undefined" && img.naturalWidth === 0) {
setTimeout(slowloadModiferCallback(slowloadDiv, args), args.loadSpeed);
}

// check stopping conditions
var maxImageHeight = img.height * args.loadMaxPercent;

if (!maxImageHeight || maxImageHeight === 0 || newTopClip < maxImageHeight) {
} else if (!maxImageHeight || maxImageHeight === 0 || newTopClip < maxImageHeight) {
// create new update timeout
slowloadDiv.slothifyData.imageTopClip = newTopClip;
setTimeout(slowloadModiferCallback(slowloadDiv, args), args.loadSpeed);
Expand Down Expand Up @@ -72,6 +68,7 @@ var comcastifyjs = (function () {

// remember what the max height should be for later calculation
slowload.slothifyData = {
img: img,
imageTopClip: 0,
maxImageHeight: img.height * params.loadMaxPercent
};
Expand Down

0 comments on commit 1d97099

Please sign in to comment.