Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/2573 pictures after comming back to online #2821

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Orders with invalid address don't stack anymore in the queue and have proper notification popup - @AndreiBelokopytov, @lukeromanowicz (#2663)
- Offline orders with out of stock products don't stack anymore and get canceled after going back to online - @lukeromanowicz (#2740)
- Build ServiceWorker on Docker - @patzick (#2793)
- Product image load after comming back to online - @patzick (#2573)

## [1.9.0-rc.2] - 2019.04.10

Expand Down
26 changes: 19 additions & 7 deletions src/themes/default/components/core/ProductGalleryCarousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,25 @@
:alt="productName | htmlDecode"
>
<img
v-if="!lowerQualityImagesErrorsMap[index] || isOnline"
v-show="lowerQualityImagesMap[index]"
key="lowQualityImage"
class="product-image inline-flex mw-100"
:src="images.loading"
@load="lowerQualityImageLoaded(index)"
@load="lowerQualityImageLoaded(index, true)"
@error="lowerQualityImageLoaded(index, false)"
ref="images"
:alt="productName | htmlDecode"
data-testid="productGalleryImage"
itemprop="image"
>
<img
v-if="!highQualityImagesErrorsMap[index] || isOnline"
v-show="highQualityImagesLoadedMap[index]"
key="highQualityImage"
:src="images.src"
@load="highQualityImageLoaded(index)"
@load="highQualityImageLoaded(index, true)"
@error="highQualityImageLoaded(index, false)"
class="product-image inline-flex pointer mw-100"
ref="images"
@dblclick="openOverlay"
Expand All @@ -66,6 +70,7 @@
import store from '@vue-storefront/core/store'
import { Carousel, Slide } from 'vue-carousel'
import ProductVideo from './ProductVideo'
import { onlineHelper } from '@vue-storefront/core/helpers'

export default {
name: 'ProductGalleryCarousel',
Expand Down Expand Up @@ -94,7 +99,9 @@ export default {
currentPage: 0,
hideImageAtIndex: null,
lowerQualityImagesLoadedMap: {},
highQualityImagesLoadedMap: {}
highQualityImagesLoadedMap: {},
lowerQualityImagesErrorsMap: {},
highQualityImagesErrorsMap: {}
}
},
computed: {
Expand All @@ -118,6 +125,9 @@ export default {
visibilityMap[index] = !!this.highQualityImagesLoadedMap[index] && this.hideImageAtIndex !== index
})
return visibilityMap
},
isOnline () {
return onlineHelper.isOnline
}
},
beforeMount () {
Expand Down Expand Up @@ -171,11 +181,13 @@ export default {
onVideoStarted (index) {
this.hideImageAtIndex = index
},
lowerQualityImageLoaded (index) {
this.$set(this.lowerQualityImagesLoadedMap, index, true)
lowerQualityImageLoaded (index, success = true) {
this.$set(this.lowerQualityImagesLoadedMap, index, success)
this.$set(this.lowerQualityImagesErrorsMap, index, !success)
},
highQualityImageLoaded (index) {
this.$set(this.highQualityImagesLoadedMap, index, true)
highQualityImageLoaded (index, success = true) {
this.$set(this.highQualityImagesLoadedMap, index, success)
this.$set(this.highQualityImagesErrorsMap, index, !success)
}
}
}
Expand Down