Code Monkey home page Code Monkey logo

lazyload's Introduction

LazyLoad

LazyLoad allows you to defer image loading until the user scrolls down to each image. Using LazyLoad can easily save you bandwidth and allow the page to load faster for the user. This plugin takes only a minute to implement so using LazyLoad is a must.

Screenshot

How to Use

LazyLoad should be initialized during the DOMReady event. There are no required arguments -- only options.

#JS
/* LazyLoad instance */
var lazyloader = new LazyLoad({
	range: 200,
	realSrcAttribute: "data-src",
	useFade: true,
	elements: 'img',
	container: window
});

#HTML
<img src="http://davidwalsh.name/dw-content/blank.gif" data-src="http://davidwalsh.name/dw-content/mexico-2009/small/102_1152.jpg" />
<!-- or -->
<img data-src="http://davidwalsh.name/dw-content/mexico-2009/small/102_1152.jpg" />

For specific usage and options, please read the documentation or visit http://davidwalsh.name/js/lazyload

lazyload's People

Contributors

daankroese avatar darkwing avatar sitependavidwalsh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lazyload's Issues

Display issue with chrome

It's work well under IE/firefox/opera but under chrome 23.0.1271.97 i can see the first images but the next images aren't displayed. I have set when i call the lazyload : elements: '.mylazyload'

[FF3.5.5 & IE7] On refresh, loader img stays on refresh

To recreate this problem, start the demo > scroll to the middle of the page > hit F5. The loader image stays and the cached images that were there before the refresh don't come up.
Maybe this issue is there in other browsers as well, but I didn't got the chance to check that.

LazyLoad 2.1 - Unable to get value of the property 'defaultView'

Mootools: 1.3.2 ( http://mootools.net/core/7c56cfef9dddcf170a5d68e3fb61cfd7 )
LazyLoad: 2.1 ( http://mootools.net/forge/download/lazyload/2.1 )

Load code:

[head]

    <script language="javascript" type="text/javascript" src="mootools.js"></script>
    <script language="javascript" type="text/javascript" src="LazyLoad.js"></script>
    <script language="javascript" type="text/javascript">
        window.addEvent('domready', function() {
            var lazyloader = new LazyLoad({
                range: 200,
                realSrcAttribute: "data-src",
                useFade: true,
                elements: 'img',
                container: window
            });
        });
    </script>

[body]

<img width="100" height="100" src="blank.gif" data-src="testimage.png" />

LazyLoad wouldn't work for me with that set up (only tested in FF6 and IE9). IE9 was throwing this error:

Unable to get value of the property 'defaultView': object is null or undefined mootools.js, line 333 character 2

Which is this code in mootools.js:

var g=Element.getDocument(this).defaultView,

I'm not sure if I'm doing something wrong but after downgrading to LazyLoad 2.0 (I nabbed your code from http://davidwalsh.name/dw-content/lazyload-2.0.php) everything started working without issue.

lazyload for internet explorer

I have used lazyload in my website. Lazyload works at google chroom , firefox mozilla and internet explorer 8 but it didn't work at internet explorer 9. How can solve this problem??

LazyLoad for horizontal scrolling

I needed the lazy loading for horizontal scrolling containers and changed your class a little bit. Now the LazyLoad-Class has the option "mode" which can be either "vertical" or "horizontal" (default is "vertical"). In "vertical"-mode the class checks the y-value of the scrolling (same behaviour as before) in "horizontal"-mode the class checks the x-value. Everything else stays the same.

The code:
http://gist.github.com/255921

Plugin does not consider resizing

If your viewport is large enough to only display one of ten images then scrolling half way will load half of them. However, if you then resize the viewport so that all can be viewed, the remaining half will never load. This is because the plugin assumes the scroll extent never changes. Of course, when the window is resized the scroll extent does change and in fact it can never reach the same position as when the window was smaller so the filter action never triggers for the remaining images.

The solution should be to consider window resizing and trigger the filter action as well as reset the largestPosition property if the scroll extent has decreased (because the window size has increased).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.