-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(carousel): first image slides in for crossfade transition, animat…
- Loading branch information
Showing
4 changed files
with
152 additions
and
144 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
projects/coreui-angular/src/lib/carousel/carousel-inner/carousel-inner.component.html
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
258 changes: 126 additions & 132 deletions
258
projects/coreui-angular/src/lib/carousel/carousel.animation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,142 +1,136 @@ | ||
import { | ||
animate, | ||
group, | ||
query, | ||
state, | ||
style, | ||
transition, | ||
trigger, | ||
} from '@angular/animations'; | ||
import { animate, animation, group, query, state, style, transition, trigger, useAnimation } from '@angular/animations'; | ||
|
||
export function toLeft(fromState: any, toState: any): boolean { | ||
return toState.left === true; | ||
export function toSlideLeft(fromState: any, toState: any): boolean { | ||
return toState.left === true && toState.type === 'slide'; | ||
} | ||
export function toRight(fromState: any, toState: any): boolean { | ||
return toState.left === false; | ||
|
||
export function toSlideRight(fromState: any, toState: any): boolean { | ||
return toState.left === false && toState.type === 'slide'; | ||
} | ||
|
||
export function toFadeLeft(fromState: any, toState: any): boolean { | ||
return toState.left === true && toState.type !== 'slide'; | ||
} | ||
|
||
export function toFadeRight(fromState: any, toState: any): boolean { | ||
return toState.left === false && toState.type !== 'slide'; | ||
} | ||
|
||
export const slideAnimation = trigger('slideAnimation', [ | ||
state( | ||
'*', | ||
style({ transform: 'translateX(0)', display: 'block', opacity: 1 }) | ||
), | ||
transition( | ||
toLeft, | ||
group([ | ||
query( | ||
':leave', | ||
[ | ||
animate( | ||
'0.6s ease-in-out', | ||
style({ | ||
transform: 'translateX(-100%)', | ||
}) | ||
), | ||
], | ||
{ optional: true } | ||
), | ||
query( | ||
':enter', | ||
[ | ||
export const slideAnimationLeft = animation( | ||
group([ | ||
query( | ||
':leave', | ||
[ | ||
animate( | ||
'0.6s ease-in-out', | ||
style({ | ||
transform: 'translateX(100%)', | ||
}), | ||
animate('0.6s ease-in-out', style('*')), | ||
], | ||
{ optional: true } | ||
), | ||
]) | ||
), | ||
transition( | ||
toRight, | ||
group([ | ||
query( | ||
':enter', | ||
[ | ||
transform: 'translateX(-100%)' | ||
}) | ||
) | ||
], | ||
{ optional: true } | ||
), | ||
query( | ||
':enter', | ||
[ | ||
style({ | ||
transform: 'translateX(100%)' | ||
}), | ||
animate('0.6s ease-in-out', style('*')) | ||
], | ||
{ optional: true } | ||
) | ||
]) | ||
); | ||
|
||
export const slideAnimationRight = animation( | ||
group([ | ||
query( | ||
':enter', | ||
[ | ||
style({ | ||
transform: 'translateX(-100%)' | ||
}), | ||
animate('0.6s ease-in-out', style('*')) | ||
], | ||
{ optional: true } | ||
), | ||
query( | ||
':leave', | ||
[ | ||
animate( | ||
'0.6s ease-in-out', | ||
style({ | ||
transform: 'translateX(-100%)', | ||
}), | ||
animate('0.6s ease-in-out', style('*')), | ||
], | ||
{ optional: true } | ||
), | ||
query( | ||
':leave', | ||
[ | ||
animate( | ||
'0.6s ease-in-out', | ||
style({ | ||
transform: 'translateX(100%)', | ||
}) | ||
), | ||
], | ||
{ optional: true } | ||
), | ||
]) | ||
), | ||
]); | ||
transform: 'translateX(100%)' | ||
}) | ||
) | ||
], | ||
{ optional: true } | ||
) | ||
]) | ||
); | ||
|
||
export const fadeAnimation = trigger('fadeAnimation', [ | ||
state( | ||
'*', | ||
style({ zIndex: 1, opacity: 1 }) | ||
), | ||
transition( | ||
toLeft, | ||
group([ | ||
query( | ||
':leave', | ||
[ | ||
animate( | ||
'0.6s ease-in-out', | ||
style({ | ||
zIndex: 0, | ||
opacity: 0, | ||
}) | ||
), | ||
], | ||
{ optional: true } | ||
), | ||
query( | ||
':enter', | ||
[ | ||
export const fadeAnimationLeft = animation( | ||
group([ | ||
query( | ||
':leave', | ||
[ | ||
animate( | ||
'0.9s ease-in-out', | ||
style({ | ||
zIndex: 1, | ||
opacity: 1 | ||
}), | ||
animate('0.6s ease-in-out', style('*')), | ||
], | ||
{ optional: true } | ||
), | ||
]) | ||
), | ||
transition( | ||
toRight, | ||
group([ | ||
query( | ||
':enter', | ||
[ | ||
zIndex: 0, | ||
opacity: 0 | ||
}) | ||
) | ||
], | ||
{ optional: true } | ||
), | ||
query( | ||
':enter', | ||
[ | ||
style({ | ||
zIndex: 1, | ||
opacity: 1 | ||
}), | ||
animate('0.6s ease-in-out', style('*')) | ||
], | ||
{ optional: true } | ||
) | ||
]) | ||
); | ||
export const fadeAnimationRight = animation( | ||
group([ | ||
query( | ||
':enter', | ||
[ | ||
style({ | ||
zIndex: 1, | ||
opacity: 1 | ||
}), | ||
animate('0.6s ease-in-out', style('*')) | ||
], | ||
{ optional: true } | ||
), | ||
query( | ||
':leave', | ||
[ | ||
animate( | ||
'0.9s ease-in-out', | ||
style({ | ||
zIndex: 1, | ||
opacity: 1 | ||
}), | ||
animate('0.6s ease-in-out', style('*')), | ||
], | ||
{ optional: true } | ||
), | ||
query( | ||
':leave', | ||
[ | ||
animate( | ||
'0.6s ease-in-out', | ||
style({ | ||
zIndex: 0, | ||
opacity: 0, | ||
}) | ||
), | ||
], | ||
{ optional: true } | ||
), | ||
]) | ||
), | ||
zIndex: 0, | ||
opacity: 0 | ||
}) | ||
) | ||
], | ||
{ optional: true } | ||
) | ||
]) | ||
); | ||
|
||
export const carouselPlay = trigger('carouselPlay', [ | ||
state('*', style({ transform: 'translateX(0)', display: 'block', opacity: 1 })), | ||
transition(toFadeLeft, useAnimation(fadeAnimationLeft)), | ||
transition(toFadeRight, useAnimation(fadeAnimationRight)), | ||
transition(toSlideLeft, useAnimation(slideAnimationLeft)), | ||
transition(toSlideRight, useAnimation(slideAnimationRight)) | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters