Giter VIP home page Giter VIP logo

laziestloader's People

Contributors

dwtkns avatar gka avatar sjwilliams 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

Watchers

 avatar  avatar  avatar

laziestloader's Issues

{{size}} variable doesn't work in mustache templates

The {{size}} variable in the path of a responsive image doesn't play well with mustache templates. In a mustache template:

<img src="transparent.gif" data-pattern="path/name-{{size}}.jpg" data-widths="[320, 640]" />

becomes

<img src="transparent.gif" src="path/name-.jpg" data-pattern="path/name-.jpg" data-widths="[320, 640]" />

Maybe make the syntax configurable?

flag for "in view" instead of simply on scroll

I'm imagining using this in the context of a slideshow, and it would be nice if there could be flag you could set to check for whether an element comes into the viewport from any direction, not just on vertical scroll.

Expose the bestFit method

When setSourceMode is false and a callback is being used for functionality, it would be handy to have access to the bestFit method.

sort widths

bestFit assumes widths are sorted from low to high, but nothing enforces that.

A simple sort like

widths.sort(function(a,b){
  return a - b;
});

probably won't work because of the slug/object version.

Prevent loading of smaller images on resize

Currently, on resize, the plugin will check if there's a better sized image for an already-loaded one and use it, even if that image is smaller. Given that the browser will scale down larger images, it's probably best to prevent the http request overhead of new, smaller images when an acceptable larger image is already loaded.

Inline element sizing issues

Normally I use this plugin in responsive layouts were images or other lazy loaded elements have rules that make them block elements and inherit a width from their parent:

img.mylazyimage{
  display: block;  
  width: 100%;
}

Without some style rule or content to to give the element the correct size, the sizing logic will fail because laziestloader will miscalculate the target size.

Seems like the plugin should know this case and compensate.

One possible solution could be to checkout display type and temporarily give it the above rules, calculate the width, determine the best image size and then reset the element to its previous state.

This would work in many cases but would fail -- I believe -- if the element's parent also doesn't have a size (like it's position: absolute but without a width)

Ideas to fix this?

Slug-based widths are not sorted correctly

If laziestloader is given slug-based widths, it incorrectly assumes that they're presorted from smallest to largest. So an example like this will fail to pick the correct rendition:

<img data-pattern="https://graphics8.nytimes.com/images/53rd-place-nytimestravel-1-{{size}}.jpg" data-widths="[{"size":320,"slug":"square320"},{"size":75,"slug":"thumbStandard"},{"size":151,"slug":"moth"},{"size":190,"slug":"filmstrip"},{"size":190,"slug":"articleInline"},{"size":600,"slug":"articleLarge"},{"size":163,"slug":"hpSmall"},{"size":50,"slug":"blogSmallThumb"},{"size":151,"slug":"blogSmallInline"},{"size":480,"slug":"blog480"},{"size":533,"slug":"blog533"},{"size":427,"slug":"blog427"},{"size":362,"slug":"tmagSF"},{"size":592,"slug":"tmagArticle"},{"size":500,"slug":"slide"},{"size":750,"slug":"jumbo"},{"size":750,"slug":"superJumbo"},{"size":640,"slug":"square640"},{"size":150,"slug":"thumbLarge"},{"size":225,"slug":"blog225"},{"size":177,"slug":"mediumFlexible177"},{"size":675,"slug":"master675"},{"size":495,"slug":"master495"},{"size":180,"slug":"master180"},{"size":149,"slug":"mediumSquare149"},{"size":315,"slug":"master315"},{"size":168,"slug":"smallSquare168"},{"size":252,"slug":"smallSquare252"}]" src="https://cms-service.stg.nytimes.com/data/cms/files/2015/12/27/100000004055844/53rd-place-nytimestravel-1-smallSquare252.jpg">

On quick inspection of the source, the internal bestFit() method does sort smallest to largest. The issue is likely here, where the slug/object-specific logic relates the best fit selection back to the original hash.

JQMIGRATE deprecation

Hello author,

Please fix some jquery deprecations

JQMIGRATE: jQuery.fn.resize() event
JQMIGRATE: jQuery.fn.scroll() event

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.