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

Don`t change src when exists #267

Closed
applibs opened this issue May 4, 2023 · 4 comments
Closed

Don`t change src when exists #267

applibs opened this issue May 4, 2023 · 4 comments
Assignees
Labels

Comments

@applibs
Copy link

applibs commented May 4, 2023

How to ensure that Lazy does not change src if it already has a value?

@dkern
Copy link
Owner

dkern commented May 4, 2023

The question is, why there are elements with a source, that should not ne changed in a Lazy instance? Don't add them of they should not be handled. And of you change the elements outside of Lazy, then you need to manually remove them from the instance.

@dkern dkern self-assigned this May 4, 2023
@dkern dkern added the wontfix label May 4, 2023
@dkern dkern closed this as not planned Won't fix, can't repro, duplicate, stale May 4, 2023
@applibs
Copy link
Author

applibs commented May 4, 2023

I have another script that puts in another image from another source before Lazy and Lazy doesn't know about it.
Ideally Lazy would create a data-status attribute after inserting the image into src, saying that src has already been changed. At the same time, if I create such an attribute before Lazy, Lazy will skip that element.
And I can do it with callback like this:

afterLoad: function (element) {
    element.attr('data-status', 'done');
}

but Lazy dont know what it means, because callback beforeLoad dont know cancel loading. Am I right?
I tested some flow how to do it, but first call is made by beforeLoad, then my outside script made some changes and then afterLoad. I am unable to control Lazy.

@dkern
Copy link
Owner

dkern commented May 4, 2023

Three ways:

  • Create a custom loader for Lazy.
  • Let the other script remove the item from that Lazy instance to Lazy doesn't handle that item at all.
  • But the best idea would be to create a clean behavior. Two script changing the same attribute on one item is never a good idea. I would suggest changing the workflow.

@applibs
Copy link
Author

applibs commented May 4, 2023

I see that handledName dooing what I am looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants