-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Collection-repeat image recycling while loading #1742
Comments
Your codepen isn't working, but I've seen this problem too. One solution is to use data-uris and prefetch your images. If we want to actually reset the But to try, we can create a directive that will make a new image element every time the src changes. Try this: <img resetting-img ng-src="{{something}}"> myApp.directive('resettingImg', function() {
return {
restrict: 'A',
link: function(scope, element, attr) {
var currentElement = element;
attr.$observe('src', function(src) {
var newImg = element.clone(true);
newImg.attr('src', src);
currentElement.replaceWith(newImg);
currentElement = newImg;
});
}
};
}); |
Sorry, the codepen url is: http://codepen.io/udfalkso/pen/aojet |
Thanks, your directive solution seems to work well and doesn't hurt scrolling performance (on my iphone 5 at least, haven't tried android). That solves the issue for my personal needs. Maybe collection-repeat could have a "reset-images='true'" option built in, for others that run into this issue? |
Confirmed working here, as well. |
Be careful. I just found a case where the original image element had some additional attributes set on it (like ng-style="") and those got wiped out by the new directive. I'll try write an improved version that handles this tomorrow. |
You could also try doing: attr.$observe('src', function(src) {
img.attr('src', '');
//on next frame, set src again
ionic.requestAnimationFrame(function() {
img.attr('src', src);
});
}); I don't know if it would work, but it's worth trying the simpler way. |
Unfortunately that trick doesn't seem to work @ajoslin |
So for now, the best way to fix this is to always use data-uris for your images. We'll have to find a way to really make the |
+1 with iOS 7 and beta 13 edit - ajoslin's technique didn't work for me so I went and modified it slightly .directive('resettingImg', function() {
return {
restrict: 'A',
link: function(scope, element, attr) {
var currentElement = element;
var applyNewSrc = function(src) {
var newImg = element.clone(true);
newImg.attr('src', src);
currentElement.replaceWith(newImg);
currentElement = newImg;
};
attr.$observe('src', applyNewSrc);
attr.$observe('ngSrc', applyNewSrc);
}
};
}) |
I have same issue nightly version in IOS resettingImg does not work |
Also have this same issue. |
I'm going to try to implement something similar to @dhcar's solution. |
So I found a less expensive way that works: every time we change an item's data, we refresh its images by simply setting them all to display: none then back. We should definitely not always do this. How does an attribute called |
An attribute called force-refresh-images="true" sounds good! |
force-refresh-images="true" has my blessing! |
Could you guys test this out? There are now two new attributes: collection-buffer-size and collection-refresh-images. Read the nightly docs for an explanation: http://ionicframework.com/docs/nightly/api/directive/collectionRepeat |
Additionally, doing this revealed an opportunity for some huge optimizations to collection-repeat! Those are coming soon. |
nice~! i expect optimizing~! |
Hey guys, don't know if it's implemented in RC5, but it doesn't seems to work for me.
Any idea why ? [EDIT] @ajoslin I can't see why Github would unassign you by me posting a comment :/ but this just popped up : "ajoslin was unassigned by JerryBels 19 seconds ago" |
Bump |
1 similar comment
Bump |
@JerryBels, are you seeing this still a problem in 1.0? |
@perrygovier yes, still occurs with 1.0.0. I recorded it in video for you to see : https://www.youtube.com/watch?v=0ZaeD2nlKoA No comments about the photos of our office :p The CDN delivering the photos is very fast so you see the bug very slightly but it's even more pronounced when running on a bad 3G connection. |
@perrygovier anything else I can do to help track down the issue ? |
I can confirm the existence of this problem in v1.0.0. Unfortunately that's not all as I've encountered a lot of difficulties combining There's no easy way to resolve this due to the isolated nature of
HTML:
EDIT: Created issue #4042 for this problem. |
Greetings @udfalkso! My sensors indicate a reply was requested, but we have not received one yet, I am using my robot powers to close this issue. However, if you are still experiencing this issue, please feel free to reopen it by creating a new issue, and include any examples or necessary information. Thank you for allowing me to assist you. |
@Ionitron @perrygovier as you can see with the last comments, the issue is still here... Do I need to open a new issue and reference this one in it or can you reopen this ? |
force-refresh-images doesn't work for me I can still see duplicated images |
I am also still seeing duplicated images with force-refresh-images. Did anyone else figure out a workaround? |
Please provide a codepen exmaple in a new issue. |
Same issue for me. |
Tks all, @ajoslin's method resolved my problem. |
I'm having a similar issue in which the first time I open the view the images are not shown. If I scroll down and then up again the images are shown. What could be the issue? I posted my general problem here: http://stackoverflow.com/questions/37707413/ionics-collection-repeat-directive-works-erratically-when-a-custom-directive-is
|
Same issue for here with images from a template using ng-include into the collection-repeat, check the issue guys: https://www.screencast.com/t/00PrU98MThAW Thanks in advance, Nicholls |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
I've noticed that while scrolling, if the image to be displayed has not yet downloaded, the user will be shown the last image that existed in that recycled node's "spot" until the new one loads.
It's misleading behavior and can be a bit confusing for the user. More preferable would be for later items to somehow be reset to initial conditions so the user sees an empty container while the image loads.
I've set up this codepen which reproduces the problem:
http://codepen.io/udfalkso/pen/aojet5
You'll have to throttle your internet connection somehow to consistently see the issue in action. Either on a mobile device without wifi or with SpeedLimit.prefPane. Scroll down quickly and you'll see that the images from up-top are repeated for some time until the new images load on top of them.
I hope this was clear. Any solutions? Thanks!
The text was updated successfully, but these errors were encountered: