Skip to content

Commit

Permalink
Merge pull request #1090 from mjschock/STENCIL-3105
Browse files Browse the repository at this point in the history
STENCIL-3105 - Lazy load carousel images
  • Loading branch information
mjschock authored Oct 6, 2017
2 parents f88c676 + 5ba3ea8 commit 13532c7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Style optimized checkout new checklist radio buttons [#1088](https://github.com/bigcommerce/cornerstone/pull/1088)
- Update product UPC when options with different UPC are selected [#1089](https://github.com/bigcommerce/cornerstone/pull/1089)
- Do not scale product thumbnail images [#1094](https://github.com/bigcommerce/cornerstone/pull/1094)
- Lazy load carousel images [#1090](https://github.com/bigcommerce/cornerstone/pull/1090)

## 1.9.3 (2017-09-19)
- Fixes image overlapping details on product page and Quick View on small viewports [#1067](https://github.com/bigcommerce/cornerstone/pull/1067)
Expand Down
6 changes: 3 additions & 3 deletions assets/modernizr-custom.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion assets/scss/components/stencil/heroCarousel/_heroCarousel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
// 1. Hide the actual image element to allow background-size: cover treatment on
// large screens to scale image. Use visibility because the JS uses the height
// to set the slide size.
// to set the slide size. (For browsers with object-fit only)
//
// 2. With JS on, minimise the jump in content as you progressively enhance the
// slider. Slowly fade and slide the height, instead of a jump in collapsing
Expand Down Expand Up @@ -90,13 +90,26 @@
}
}

.objectfit .heroCarousel-slide {
// scss-lint:disable ImportantRule
background-image: none !important;
}

.heroCarousel-slide--stretch {
@include breakpoint("large") { // 4
background-size: 100% 100%;
}
}

.heroCarousel-image {
@include breakpoint("medium") {
max-height: remCalc(600px);
object-fit: cover;
width: 100%;
}
}

.no-objectfit .heroCarousel-image {
@include breakpoint("medium") { // 1
visibility: hidden;
}
Expand Down
5 changes: 3 additions & 2 deletions templates/components/carousel.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
"slidesToShow": 1,
"slidesToScroll": 1,
"autoplay": true,
"autoplaySpeed": {{carousel.swap_frequency}}
"autoplaySpeed": {{carousel.swap_frequency}},
"lazyLoad": "ondemand"
}'>
{{#each carousel.slides}}
<div class="heroCarousel-slide {{#if ../theme_settings.homepage_stretch_carousel_images}}heroCarousel-slide--stretch{{/if}}"
style="background-image: url({{image}})">
<a href="{{url}}">
<img class="heroCarousel-image" src="{{image}}" alt="{{alt_text}}" title="{{alt_text}}"/>
<img class="heroCarousel-image" data-lazy="{{image}}" alt="{{alt_text}}" title="{{alt_text}}"/>
{{#if heading}}
{{> components/carousel-content show_background=true}}
{{else}}
Expand Down

0 comments on commit 13532c7

Please sign in to comment.