Git Product home page Git Product logo

unveil2's Introduction

Travis Code Climate npm Bower jsdelivr cdnjs

unveil2.js

A very lightweight plugin to lazy load images for jQuery
Based on luis-almeida/unveil.

Getting started

Install unveil2.js by downloading a copy of jquery.unveil2.min.js and add it to your page after jQuery:

<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="jquery.unveil2.min.js"></script>

And call the unveil plugin on the images you want to be lazily loaded:

$('img').unveil();

Note: If you load scripts at the bottom of the page, you don't have to wait for $.ready.

That's all folks!

More examples

CSS background, retina images, breakpoints and more: see online examples.

More configuration options

For a complete list of options, see API section.

Cross-browser tests

Sauce Labs

License

MIT

unveil2's People

Contributors

hongaar avatar luis-almeida avatar vogdb avatar stephengroat avatar alexgorbatchev avatar froog avatar benschwarz avatar jaunesarmiento avatar backstrap avatar

Stargazers

Gaëtan avatar Wouter Samaey avatar Jiri Melcak avatar Hassan Sabbahi  avatar  avatar mnmlize avatar antiden avatar Marcus avatar Marc avatar Chun-Sheng, Li avatar  avatar  avatar Martijn van Laar avatar Jo avatar Rob Garrison avatar Jürgen Hörmann avatar Volker Otto avatar Frank avatar  avatar Alex Norton avatar Michal Svatos avatar Wouter Beugelsdijk avatar Victor Simao avatar Greg Price avatar atb avatar Kody avatar Joel Glovacki avatar Michael VanDyke avatar Jari Ketola avatar Michael Xander avatar Ferdinand avatar Ted avatar Baby Steps avatar Stephan avatar Ralf avatar  avatar  avatar Dick de Leeuw avatar

Watchers

Martijn van Laar avatar  avatar James Cloos avatar Ralf avatar  avatar Andrii Iv. (@digitalandyeu) avatar

unveil2's Issues

package.json needs "main" property

In order for unveil2 to work well as an NPM package, your package.json file ought to specify

 "main": "src/jquery.unveil2.js"

As it stands, I can't, for instance, use it with WebPack, because WebPack doesn't know which file to load when I require "unveil2" in my code. (The default value for main is "index.js", but you don't have a file by that name in your build.)

Can't make it work with webpack

HI!

Trying to get this, and its predecessor, to work with webpack but to no avail.

I get: Uncaught TypeError: $ is not a function.

I also tried with the imports-loader module, but still not working.
I also tried to use the unveil2 npm package, same result.

This library is the only one preventing me from moving to Webpack...

Thanks.

width/height markup attributes

I´m wondering about the best method to add a preloader indicator for each image. I though that adding a width & height for each element would be enough, but it seems that even if I add the sizes the images are scaled somehow from 0 to width (if you add css transforms you can check this better).

Then, which should be the best method to preserve the layout sizes before unveil images? Could you please suggest a good method to add a preloader indicator vertically/horizontally centered within the item area?

Thanks!

Unveil never or unreliably triggers inside carousels, dropdowns.

I've been using unveil successfully across an entire site, however when using an img tag inside a carousel, (specifically nivoslider) unveil loads the placeholder pixel and only switches to the src if a scroll is triggered while the image is displayed in the carousel.

If I use a div it will set the background image from data-src or breakpoint-src immediately, this issue seems to be specific to img tags.

Could unveil instead more reliably check that a parent element is visible? Even better if we could set the trigger element via a data attribute, that way I could get unveil to load the entire carousel as soon as it appears on screen, ensuring transitions animate correctly.

Add srcset support

Since Wordpress implements this feature natively, it would be awesome seeing the plugin to handle images sets :)

Responsive image jump

When i.e. Bootstraps img-reponsive class is used, a image jump can be seen after loading the placeholder image, and after loading the final image.

Related: #15 (comment)

Preserve original img size/space while loading

Hi Joram!

I´m wondering how the best to prevent the 'jump' when loading images. I have set up width/height via img attributes for each element, but they still are jumping when unveil loads because the plugins removes the original picture.

Do you have any guideline in order to fix this issue?

Thanks!

src images download on page load

Hi,

first of all, thanks for continuing/forking and improving this great plugin!

I have done a quick approach in a website I´m working on and I have realized that images are downloading once the document is loaded, then, as you scroll the page, the images are downloading on demand, but they are twice loaded. First time when the page load (all images with lazy class are downloaded) and again when you scroll ('on demand').

An approach without need to add script tags would be great, but I´m not sure if this is correctly controlled or if I´m missing something.

In my implementation I´m using the same image path within the src attribute and within data.

Hope you can send some light on this! Thanks! 👍

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.