-
Notifications
You must be signed in to change notification settings - Fork 224
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
[PROPOSAL] Update API #24
Comments
@oncletom So this proposal is to allow a user to completely change the list of images that Imager is watching to a different set of images. For example, given the following HTML... <div id="a">
<img class="delayed-image-load" src="1.jpg">
<img class="delayed-image-load" src="2.jpg">
<img class="delayed-image-load" src="3.jpg">
</div>
<div id="b">
<img class="delayed-image-load" src="4.jpg">
<img class="delayed-image-load" src="5.jpg">
<img class="delayed-image-load" src="6.jpg">
</div> ...the user could initially instantiate an instance of Imager with Is that what this proposal is suggesting? If so I'm not sure I see a real world use case for this need. It seems like a nice idea but I just can't imagine why I'd ever use it? Maybe you can give me a better real world example. |
Changing the selector is not indeed very relevant, it's like creating a new Imager instance. So no, it's not needed. I was rather thinking if the content was updated dynamically. Some new images were added in the same container (AJAX request, a user adds a new comment containing an image, swipe navigation etc.). If we use |
@oncletom OK that makes more sense. So to clarify: the I don't believe we can access the CSS selector that window.selectorResults = [];
document.querySelectorAllOriginal = document.querySelectorAll;
Element.prototype.querySelectorAll = function (selector) {
console.log('over ridden version');
var results = document.querySelectorAllOriginal(selector);
window.selectorResults.push(results);
return results;
} ...but that didn't work (I had tried overriding the If I directly used So yeah it does looks like we might need to use the update API you've proposed. Unless we get the user to just pass in a selector String and then we do some trickery in the implementation to actually use 'delegation' on the |
The intention
Once we have instantiated an Imager instance, there is no documented way to update the pool of responsive images it handles (unless a DIY of the
cache
property).The proposal
Adding a prototype method to replace the actual pool of responsive images by another one.
Ideally, it will share the same behavior as the Constructor Explicit Argument API (cf. #22).
Note: not satisfied with the naming, as it should suggest updating the list of related responsive images and not updating their
src
attribute (cf. #25).With jQuery:
With DOM NodeList:
With string CSS selector:
The text was updated successfully, but these errors were encountered: