-
Notifications
You must be signed in to change notification settings - Fork 142
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
How to create a transition effect between defaultImage and lazyLoad #300
Comments
HI @AndreasSchmid1, thanks for your kind words. You can add an animation on the image, eg. img.ng-lazyloaded {
animation: fadein .5s;
}
@keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
} (see "Default image" on the example page: https://tjoskar.github.io/ng-lazyload-image) You can also add a transition between images if you create two images, one with the default image and one with the lazyloaded one. eg. https://github.com/tjoskar/ng-lazyload-image/blob/master/example/pixelated-image.component.ts (see "Pixelated image" on the example page: https://tjoskar.github.io/ng-lazyload-image) It is also possible to add a transition on the #image {
height: 250px;
width: 500px;
transition: background-image 1s ease-out;
} <div id="image" [defaultImage]="defaultImage" [lazyLoad]="image"></div> See this page for an example (not using ng-lazyload-image): http://jsfiddle.net/8L7775fa/4/ Let me know if you run into problems. |
Hi All, Below is my code------------------------ The defaultImage is a spinner gif image(comes from my component) which I want to show to the users until my real images get loaded ( [lazyLoad]="image.carousel_image_key" ).I have fixed the size of my carousel as below in my css #mainCarouselImgLayout{ |
@chandrasachin Did you find soution? |
Thank you for this snippet @tjoskar ! |
I tried your hooks as described, but they won't if i use custom scroll-content on multiple class LazyLoadImageHooks extends IntersectionObserverHooks {
public setLoadedImage(imagePath: string, attributes: Attributes): void {
attributes.element.classList.add('animated-img');
super.setLoadedImage(imagePath, attributes);
}
public finally(attributes: Attributes): void {
super.finally(attributes);
setTimeout(() => {
attributes.element.classList.remove('animated-img');
}, 3000);
}
}
...
@NgModule({
imports: [
LazyLoadImageModule
],
providers: [
{ provide: LAZYLOAD_IMAGE_HOOKS, useClass: LazyLoadImageHooks },
],
}) .animated-img {
animation: fadeIn 3s;
}
@keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
} |
Hello tjoskar. Thank you for this great library! I want to ask if it is possible to create a transition effect beween the defaultImage and the lazy loaded image.
Thank you for help in advance
The text was updated successfully, but these errors were encountered: