Open 3rror404 opened 7 years ago
I could wire calling a callback when an image loads, but that code would go in the same place where isLoading is set in the module. Think of it in this way. The loaded event itself sets the isLoading property. I doubt if calling a callback at the loaded event would resolve this. It would be nothing more than syntactic sugar I reckon. Which platform are you currently on?
@bathejasumeet would be cool if I could do something like this though:
<WebImage stretch="aspectFill" row="1" #listImage (loaded)="animateImage(listImage)" [src]="item.downloadUrl"></WebImage>
animateImage(img: Image) {
return new Promise((resolve, reject) => {
img.animate({
duration: 500,
opacity: 1,
curve: enums.AnimationCurve.easeIn
}).then(() => {
img.animate({
duration: 500,
scale: { x: 1.0, y: 1.0 },
curve: enums.AnimationCurve.easeOut
}).then(() => {
resolve();
});
});
});
}
So I can do some sort of animation on the image when its loaded. ngAfterViewInit isn't suitable for me.
Can you know if the isLoading property changed?
I get the element with @Viewchild in AfterViewInit, and at that point if I'm downloading an image from the internet I get isLoading == true.
That value seems to never change after that, except if I check regularly with setInterval(...) (something I'd prefer no to do...).
But I'd like to know if the image ended loading and, for example, stop showing an ActivityIndicator.
Hi guys, Does anyone solve this problem? Thanks
Hey @alexandruantonica, I ended up just using the core image-source module and manually triggering garbage collection when the images were no longer needed.
This might not be suitable for your use case but there are more details here: https://github.com/NativeScript/NativeScript/issues/3887
Agree that a (loaded)
event would be a nice addition!
Thanks for this great plugin :)
I see that there is a
isLoading
property that we can query but is there any sort ofloaded
event that we can use?I need to display two images at exactly the same time. Currently I'm querying
isLoaded
insetInterval
loop and setting the parent elements opacity to 1 when bothisLoaded = true
but this doesn't this doesn't work very well.Even though both images report that they have finished loading they aren't actually both displayed at that point.
Is there any way I can tell when an image has been fully loaded and rendered in the
<IC:WebImage>
element?