jetmartin / responsive-lazy-loader

A responsive lazy loader. Load image rendition according to CSS display & breakpoint.
Other
23 stars 11 forks source link

Set different options for different image sets #1

Closed vishnun closed 10 years ago

vishnun commented 10 years ago

If for a set of img tags, say set-A, i want settings settings-A to be passed in the initialization:

$("img.classA").responsivelazyloader({ mediaQueries : { // The mediaqueries used for image set A 'phone' : "(max-width: 767px)", 'tablet' : "(min-width: 768px) and (max-width: 991px)", 'desktop' : "(min-width: 992px)" }, displays : { // The displays to combine grid system & mediaqueries 'defaults' : { 'display' : { 'desktop' : 'b', //1024 'tablet' : 'z', //640 'phone' : 'm', //320 'defaults' : 'b' //1024 } } } });

AND

If for another set of img tags, say set-B, i want settings settings-B to be passed in the initialization:

$("img.classB").responsivelazyloader({ mediaQueries : { // The mediaqueries used for image set A 'phone' : "(max-width: 767px)", 'desktop' : "(min-width: 992px)" }, displays : { // The displays to combine grid system & mediaqueries 'defaults' : { 'display' : { 'desktop' : 'b', //1024 'phone' : 'm' //320 } } } });

THE ISSUE: The initialization for Images in setB overrides the settings for the set of images in set-A.

Would want to be able to initiate different configurations for lazy loader for different images on the same page.

P.S: If this is already possible, its not so obvious how to do it.

jetmartin commented 10 years ago

Hi.

Thanks a lots for your feedback and for the pull request. Be sure i will test it with all the available configurations, callback and so on (after the new year party).

Just, in you'r case i guess it is not the best way to do so. Sorry if my documentation is not clear enough. If you can suggest how to improve i will be glad.

So, in you'r case you have to create two displays in the config element. So the custom event "onAllImagesLoad" is still available. using two separate call make it unusefull.

Alqo, always use a "defaults" for each display for old browsers as IE7 or 8.

So the way to do it is the following one :

displays : { // The displays to combine grid system & mediaqueries 'classA' : { // The display name (what you want). 'gridClass' : 'classA', // the class use to recognize the display. 'display' : { 'desktop' : 'b', //1024 'phone' : 'm' //320 'defaults' : 'b' //1024 Always use a default. } }, 'defaults' : { / Default, use for classB and all images who are not classA. 'display' : { 'desktop' : 'b', //1024 'phone' : 'm' //320 'defaults' : 'b' //1024 Always use a default. } } }

For advanced config (if you'r not using a grid system) you can also use a "parent" argument for the display detection.

Please see the demo and the update i've made fiew days ago (0.1.4 release) : http://jetmartin.github.io/responsive-lazy-loader jetmartin.github.io/responsive-lazy-loader/demo.html

jetmartin commented 10 years ago

Just another word, sorry.

Currently the plugiin can not detect the display class on the image herself as you did on your example but on a parent element (such as in most of the grid system).

It's easy to do so I will improve this feature when reviewing your pull request.

happy new year to you ;)

vishnun commented 10 years ago

Hey,

Thanks a lot for the info. Will try it out and get back to you if this works. And i guess this is one of the most asked question about this plugin or for that matter other plugins as well, that how can we have two instances. If you could add this question to your documentation and perhaps give an answer, that would be great.

Thanks a lot Mr. Martin. Happy New Year to you too.

On Tue, Dec 31, 2013 at 1:19 PM, J-Et. MARTIN notifications@github.comwrote:

Just another word, sorry.

Currently the plugiin can not detect the display class on the image herself as you did on your example but on a parent element (such as in most of the grid system).

It's easy to do so I will improve this feature when reviewing your pull request.

happy new year to you ;)

— Reply to this email directly or view it on GitHubhttps://github.com/jetmartin/responsive-lazy-loader/issues/1#issuecomment-31386845 .

Yours Sincerely,

Vishnu Narang, (Developer) ThoughtWorks. Inc.

jetmartin commented 10 years ago

I've updated the doc yesterday on jetmartin.github.io/responsive-lazy-loader/ I hope it's more clear. I also take in considerations you'r feedback on a new plugin release.