Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

lazyload.js support, fix #24

  • Loading branch information...
commit 4f0d9c77efb4418c78cb0422eff73c92e5f46beb 1 parent d472810
@imsky authored
Showing with 21 additions and 2 deletions.
  1. +5 −0 README.md
  2. +16 −2 holder.js
View
5 README.md
@@ -158,6 +158,11 @@ Holder.add_theme("new",{foreground:"#ccc", background:"#000", size:10}).add_imag
The first argument in ``add_image`` is the ``src`` attribute, and the second is a CSS selector of the parent element.
+Using with ``lazyload.js``
+--------------------------
+
+Holder is compatible with ``lazyload.js`` and works with both fluid and fixed-width images. For best results, run `.lazyload({skip_invisible:false})`.
+
Browser support
---------------
View
18 holder.js
@@ -123,7 +123,10 @@ function fluid(el, holder, src) {
fluid.style.width = holder.dimensions.width + (holder.dimensions.width.indexOf("%")>0?"":"px");
fluid.style.height = holder.dimensions.height + (holder.dimensions.height.indexOf("%")>0?"":"px");
fluid.id = el.id;
-
+
+ el.style.width=0;
+ el.style.height=0;
+
if (theme.text) {
fluid.appendChild(document.createTextNode(theme.text))
} else {
@@ -132,7 +135,18 @@ function fluid(el, holder, src) {
setTimeout(fluid_update, 0);
}
- el.parentNode.replaceChild(fluid, el);
+ el.parentNode.insertBefore(fluid, el.nextSibling)
+
+ if(jQuery){
+ jQuery(function($){
+ $(el).on("load", function(){
+ el.style.width = fluid.style.width;
+ el.style.height = fluid.style.height;
+ $(el).show();
+ $(fluid).remove();
+ });
+ })
+ }
}
function fluid_update() {
Please sign in to comment.
Something went wrong with that request. Please try again.