ApoorvSaxena / ApoorvSaxena/lozad.js

dynamic lozad does not load data-src

Offen
#245 0 Kommentare 7 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
7.5k
Forks
435
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.