ApoorvSaxena / ApoorvSaxena/lozad.js

dynamic lozad does not load data-src

未关闭
#245 0 条评论 7 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
7.5k
派生
435
PR 合并指标
30 天内没有已合并 PR

描述

Referring to similar issues raised
https://github.com/ApoorvSaxena/lozad.js/issues/50
https://github.com/ApoorvSaxena/lozad.js/issues/156
- Forcing `data-loaded` to `"false"` doesn't seem to help...

## Expected Behavior
I followed the documentation to call `observer.observer()` on adding dynamic components. This **only happens** when I navigate across pages (and yes, dynamically generating them). Reloading the page works fine.

## Current Behavior
The current/previous images loads normally, but the newly added components does not load. The new components has `src` as the placeholder (haven't been converted to `data-src`) and `data-loaded` is missing from the element.

Edit:
`data-loaded` is missing when inspecting page, but on console log element with `document.getElementById` seems to show `data-loaded` is present.

## Possible Solution
Was playing around and found a temporary and unstable fix which worked if i did this:
(Doesn't work half the time)
```
setTimeout(() => {
observer.observe();
}, 2000);
```

## Context
I'm working with lozad on VueJs

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。