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

Reloaded elements are not loaded lazily #251

Open
ericstratmann opened this issue Oct 14, 2020 · 0 comments
Open

Reloaded elements are not loaded lazily #251

ericstratmann opened this issue Oct 14, 2020 · 0 comments

Comments

@ericstratmann
Copy link

Expected Behavior

When enableAutoReload=true and a data attribute changes on an element that had been previously loaded, the element should not be reloaded until it is in the viewport.

Current Behavior

When the element's data attribute changes, lozad immediately reloads the element even when not in the viewport.

Possible Solution

The mutation callback could check if the element is visible. If it is, it calls load as it does currently. Otherwise, it sets the data-loaded attribute to false.

Steps to Reproduce (for bugs)

  1. Create a new lozad observer with enableAutoReload: true
  2. Lazy load an image by moving it on screen
  3. Move the image off screen
  4. Change the data-src attribute on the element
  5. Notice that the src attribute has changed on the element despite not being in the viewport.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant