Skip to content

Allow breakpoints based on viewport or window#40

Closed
andr3 wants to merge 1 commit intodinbror:masterfrom
andr3:allow-viewport-based-breakpoints
Closed

Allow breakpoints based on viewport or window#40
andr3 wants to merge 1 commit intodinbror:masterfrom
andr3:allow-viewport-based-breakpoints

Conversation

@andr3
Copy link

@andr3 andr3 commented Jan 9, 2015

Summary: Even though the documentation mentions widths are provided as max-width, in reality, they are (using the same property as media-queries) max-device-width.


It is reasonable for authors to need to specify breakpoints in terms of viewport.

To offer backwards compatibility, I added an optional parameter for the breakpoints:

  • mode: 'window'(default) or viewport

Tested with these breakpoints configuration:

new Blazy({
    selector: '.responsive-image',
    breakpoints: [{
      width: 600, // max-width
      src: 'data-src-small',
      mode: 'viewport'
    }, {
      width: 99999, // perhaps it should allow max-width to be specified as well, but maybe a future PR for this.
      src: 'data-src-large',
      mode: 'viewport'
    }]
   });

@andr3 andr3 force-pushed the allow-viewport-based-breakpoints branch 4 times, most recently from 1b7b229 to 02703f4 Compare January 9, 2015 17:31
@andr3
Copy link
Author

andr3 commented Jan 12, 2015

@dinbror...? Any feedback?

@cscd98
Copy link

cscd98 commented Feb 5, 2015

@dinbror @andr3pt We need this please 👍

@dinbror
Copy link
Owner

dinbror commented Feb 9, 2015

@andr3pt: I like the idea. Only concern is that bLazy doesn't update an image on resize so if your browser window is something small when you open it, it'll load the small image and it'll be up-scaled if you resize the browser window to something bigger.

@andr3 andr3 force-pushed the allow-viewport-based-breakpoints branch from 02703f4 to ff1242c Compare March 25, 2015 15:39
@andr3
Copy link
Author

andr3 commented Mar 25, 2015

@dinbror check #50, I just opened a PR that I think does just that. I also rebased this with the latest master. I'm not sure if you want the minified version committed too, but it's incl in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants