Skip to content

Commit

Permalink
fix: remove blendIn class when image is loaded (#390)
Browse files Browse the repository at this point in the history
* remove blendIn class when image is loaded

* tweak transition

* tweak transition

* use data-lazy-loaded again
  • Loading branch information
egoist authored Aug 29, 2019
1 parent 0d5a936 commit 72ccc7d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
18 changes: 12 additions & 6 deletions packages/saber-plugin-image/lib/saber-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@ export default ({ Vue }) => {

if ($el.dataset.src || $el.dataset.srcset) {
lozad($el, {
loaded(el) {
el.addEventListener(
'load',
() => el.setAttribute('data-lazy-loaded', ''),
{ once: true }
)
loaded: el => {
el.addEventListener('load', () => {
el.setAttribute('data-lazy-loaded', '')
this.removeBlendIn = setTimeout(() => {
el.classList.remove(styles.blendIn)
}, 300)
})
}
}).observe()
}
},
beforeDestroy() {
if (this.removeBlendIn) {
clearTimeout(this.removeBlendIn)
}
},
render(h) {
const lazy = Object.assign(
options,
Expand Down
12 changes: 1 addition & 11 deletions packages/saber-plugin-image/lib/styles.module.css
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
.enter-active-class,
.leave-active-class {
transition: opacity 0.5s;
}

.enter-class,
.leave-to-class {
opacity: 0;
}

.blendIn[data-src],
.blendIn[data-srcset] {
transition: filter 0.5s;
transition: filter 0.3s;
filter: blur(5px);
}

Expand Down

0 comments on commit 72ccc7d

Please sign in to comment.