question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improvement of b-img-lazy component

See original GitHub issue

@victorhramos, @KonradDeskiewicz Let’s continue the conversation here. Initial issue #1619

There is an initial check which is executed when <b-img-lazy> is mounted and activated but due to the missing getBoundingClientRect of the html element nothing happens.

I would like to improve this component because it is very useful. Currently lazy loading does only work when the page scrolls. Not optimal when you have dynamic content and want to lazy load, but there is not enough content for the page to scroll. See my codesandbox below. https://codesandbox.io/s/z5pkrx89m

In addition it would be nice to have state classes like <router-link> has, e.g.

  • img-lazy-blank when blank image is shown. Could be used to apply opacity or other css filters
  • img-lazy-src when src image is shown.

And a last improvement that comes to my mind is async loading of src images e.g.

const prefetchImage = src => new Promise((resolve, reject) => {
    const img = new Image();
    eventOn(img, 'load', () => {
        resolve();
    });
    eventOn(img, 'error', () => {
        reject();
    });
    img.src = src;
});

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
tmorehousecommented, Jan 3, 2019

PR #2382 should fix this issue, as well as adds in a new show prop to force show the image.

Also, bubbled transitonend events are now monitored, so b-img-lazy should work inside elements with transitions that show/slide/scroll the content (on browsers that support the transitionend event).

2reactions
tmorehousecommented, Jan 3, 2019

Yeah, let me check the code and see if we can make an adjustment to the mounted() hook.

Read more comments on GitHub >

github_iconTop Results From Across the Web

<Lazy> rendering in Vue to improve performance - Medium
In this article, I'll focus on the 3rd category and I'll try to do it via introducing a universal <Lazy> component.
Read more >
bootstrap-vue - UNPKG
src/components/button-toolbar/button-toolbar.js",". ... default: THROTTLE\n }\n}\n\n// @vue/component\nexport const BImgLazy = /*#__PURE__*/ Vue.extend({\n ...
Read more >
Image | Components - BootstrapVue
Create responsive images, optionally adding lightweight styles to them — all via props. Support for rounded images, thumbnail styling, alignment, ...
Read more >
Improving performance in your Vue 3 application by Lazy ...
Vue 3 has introduced several new features to help you achieve this easily through the improvements to the async component API Fast loading ......
Read more >
Building an effective Image Component - Chrome Developers
Lighthouse lists multiple opportunities to optimize images and improve web vitals as part of its best practices audit. Some of the common ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found