Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Stabalized container/elements relationship

  • Loading branch information...
commit b25d23dc8800cf1da5e0841e3e36fc523024a765 1 parent 09353c3
@SitePenDavidWalsh SitePenDavidWalsh authored
Showing with 7 additions and 6 deletions.
  1. +2 −1  README.md
  2. +4 −4 Source/LazyLoad.js
  3. +1 −1  package.yml
View
3  README.md
@@ -17,7 +17,8 @@ LazyLoad should be initialized during the DOMReady event. There are no required
range: 200,
realSrcAttribute: "data-src",
useFade: true,
- elements: 'img'
+ elements: 'img',
+ container: window
});
#HTML
View
8 Source/LazyLoad.js
@@ -23,7 +23,7 @@ var LazyLoad = new Class({
options: {
range: 200,
elements: "img",
- container: document,
+ container: window,
mode: "vertical",
realSrcAttribute: "data-src",
useFade: true
@@ -37,7 +37,7 @@ var LazyLoad = new Class({
// Elementize items passed in
this.container = document.id(this.options.container);
- this.elements = this.container.getElements(this.options.elements);
+ this.elements = document.id(this.container == window ? document.body : this.container).getElements(this.options.elements);
// Set a variable for the "highest" value this has been
this.largestPosition = 0;
@@ -46,12 +46,12 @@ var LazyLoad = new Class({
var axis = (this.options.mode == "vertical" ? "y": "x");
// Calculate the offset
- var offset = (this.container != window && this.container != document.body ? this.container : "");
+ var offset = (this.container != document.body && this.container != document.body ? this.container : "");
// Find elements remember and hold on to
this.elements = this.elements.filter(function(el) {
// Make opacity 0 if fadeIn should be done
- if(this.options.useFade) el.setStyle("opacity",0);
+ if(this.options.useFade) el.setStyle("opacity", 0);
// Get the image position
var elPos = el.getPosition(offset)[axis];
// If the element position is within range, load it
View
2  package.yml
@@ -1,6 +1,6 @@
name: LazyLoad
author: davidwalsh
-current: 2.04
+current: 2.1
category: Media
tags: [lazyload,images,media,load]
docs: http://davidwalsh.name/js/lazyload
Please sign in to comment.
Something went wrong with that request. Please try again.