Angular Flip AnimationAngular Animations to flip cardHow can I create a “Please Wait, Loading…” animation using jQuery?Android: Expand/collapse animationHow do I animate constraint changes?CSS3 Card Flip backface disappears at end of transformcss3 :hover animation not working on firefoxcss3 transition(rotation) does not work properly in ChromiumCSS-3 transforms mangle HTML element when i add another sibling element .Angular HTML bindingHuge number of files generated for every Angular projectChrome CSS3 Scrollable div won't render until animation finished
Is this password scheme legit?
Do clerics commit a sin if they do not recite the liturgy of the hours?
Who was the most successful German spy against Great Britain in WWII, from the contemporary German perspective?
Joining lists with same elements
about to retire but not retired yet, employed but not working any more
Convergence of series of normally distributed random variables
Adoption records in 1871 based on census info
Count the number of paths to n
Semantic difference between regular and irregular 'backen'
Why should a self-financing strategy be previsible?
What are the occurences of total war in the Native Americans?
Why error propagation in CBC mode encryption affect two blocks?
Why is "-ber" the suffix of the last four months of the year?
Why can't I access the 'name' of an object when looping through the scene's objects?
Why does Windows store Wi-Fi passwords in a reversible format?
How to gently end involvement with an online community?
I don't have the theoretical background in my PhD topic. I can't justify getting the degree
What is the meaning of “these lederhosen are riding up my Bundesliga”?
What is Spectral Subtraction for noise reduction?
How do I feed my black hole?
How were medieval castles built in swamps or marshes without draining them?
Billiard balls collision
Handling Disruptive Student on the Autism Spectrum
"There were either twelve sexes or none."
Angular Flip Animation
Angular Animations to flip cardHow can I create a “Please Wait, Loading…” animation using jQuery?Android: Expand/collapse animationHow do I animate constraint changes?CSS3 Card Flip backface disappears at end of transformcss3 :hover animation not working on firefoxcss3 transition(rotation) does not work properly in ChromiumCSS-3 transforms mangle HTML element when i add another sibling element .Angular HTML bindingHuge number of files generated for every Angular projectChrome CSS3 Scrollable div won't render until animation finished
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm attempting to make a flip animation in Angular. It should flip over the Y-axis when clicked, then flip back over the Y-axis in the reverse direction when clicked again. Additionally, it should have front-side and back-side content that is displayed depending on the flip state.
The back-to-front flip is giving me grief. I'm getting odd behavior depending on what I try. The best I have been able to do is a weird flip which starts in the same direction as the front-to-back flip, then it changes direction at the end. *shrugs*
Note that if you click it before the animation finishes, it works as desired. If you wait for it to finish the animation, then it has the aforementioned behavior.
Here is the prototype: https://angular-epkrtn.stackblitz.io
Can anybody help with the back-to-front flip?
Copying the code from the link below
app.component.ts
import Component from '@angular/core';
import trigger, transition, animate, style, keyframes, state from '@angular/animations';
@Component(
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ],
animations: [
trigger('flip', [
state('front', style(
transform: 'rotateY(0deg)'
)),
state('back', style(
transform: 'rotateY(180deg)'
)),
transition('front => back', [
animate('1s 0s ease-out',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) rotateY(180deg)',
offset: 1
)
]))
]),
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(180deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(0deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 1
)
]))
])
])
]
)
export class AppComponent
flipState = 'front';
onFlipClick()
if (this.flipState == 'front')
this.flipState = 'back';
else
this.flipState = 'front';
app.component.html
<div (click)="onFlipClick()" class="flip-card">
<div [@flip]="flipState" class="flip-card-inner">
<div class="flip-card-front">
FRONT
</div>
<div class="flip-card-back">
BACK
</div>
</div>
</div>
app.component.css
.flip-card
height: 200px;
width: 200px;
background-color: transparent;
margin-top: 250px;
margin-left: auto;
margin-right: auto;
.flip-card-inner
position: relative;
height: 100%;
width: 100%;
transform-style: preserve-3d;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
.flip-card-inner > div
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
.flip-card-front
background-color: blue;
.flip-card-back
transform: rotateY(180deg);
background-color: green;
angular css3 animation flip angular-animations
add a comment |
I'm attempting to make a flip animation in Angular. It should flip over the Y-axis when clicked, then flip back over the Y-axis in the reverse direction when clicked again. Additionally, it should have front-side and back-side content that is displayed depending on the flip state.
The back-to-front flip is giving me grief. I'm getting odd behavior depending on what I try. The best I have been able to do is a weird flip which starts in the same direction as the front-to-back flip, then it changes direction at the end. *shrugs*
Note that if you click it before the animation finishes, it works as desired. If you wait for it to finish the animation, then it has the aforementioned behavior.
Here is the prototype: https://angular-epkrtn.stackblitz.io
Can anybody help with the back-to-front flip?
Copying the code from the link below
app.component.ts
import Component from '@angular/core';
import trigger, transition, animate, style, keyframes, state from '@angular/animations';
@Component(
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ],
animations: [
trigger('flip', [
state('front', style(
transform: 'rotateY(0deg)'
)),
state('back', style(
transform: 'rotateY(180deg)'
)),
transition('front => back', [
animate('1s 0s ease-out',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) rotateY(180deg)',
offset: 1
)
]))
]),
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(180deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(0deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 1
)
]))
])
])
]
)
export class AppComponent
flipState = 'front';
onFlipClick()
if (this.flipState == 'front')
this.flipState = 'back';
else
this.flipState = 'front';
app.component.html
<div (click)="onFlipClick()" class="flip-card">
<div [@flip]="flipState" class="flip-card-inner">
<div class="flip-card-front">
FRONT
</div>
<div class="flip-card-back">
BACK
</div>
</div>
</div>
app.component.css
.flip-card
height: 200px;
width: 200px;
background-color: transparent;
margin-top: 250px;
margin-left: auto;
margin-right: auto;
.flip-card-inner
position: relative;
height: 100%;
width: 100%;
transform-style: preserve-3d;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
.flip-card-inner > div
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
.flip-card-front
background-color: blue;
.flip-card-back
transform: rotateY(180deg);
background-color: green;
angular css3 animation flip angular-animations
add a comment |
I'm attempting to make a flip animation in Angular. It should flip over the Y-axis when clicked, then flip back over the Y-axis in the reverse direction when clicked again. Additionally, it should have front-side and back-side content that is displayed depending on the flip state.
The back-to-front flip is giving me grief. I'm getting odd behavior depending on what I try. The best I have been able to do is a weird flip which starts in the same direction as the front-to-back flip, then it changes direction at the end. *shrugs*
Note that if you click it before the animation finishes, it works as desired. If you wait for it to finish the animation, then it has the aforementioned behavior.
Here is the prototype: https://angular-epkrtn.stackblitz.io
Can anybody help with the back-to-front flip?
Copying the code from the link below
app.component.ts
import Component from '@angular/core';
import trigger, transition, animate, style, keyframes, state from '@angular/animations';
@Component(
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ],
animations: [
trigger('flip', [
state('front', style(
transform: 'rotateY(0deg)'
)),
state('back', style(
transform: 'rotateY(180deg)'
)),
transition('front => back', [
animate('1s 0s ease-out',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) rotateY(180deg)',
offset: 1
)
]))
]),
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(180deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(0deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 1
)
]))
])
])
]
)
export class AppComponent
flipState = 'front';
onFlipClick()
if (this.flipState == 'front')
this.flipState = 'back';
else
this.flipState = 'front';
app.component.html
<div (click)="onFlipClick()" class="flip-card">
<div [@flip]="flipState" class="flip-card-inner">
<div class="flip-card-front">
FRONT
</div>
<div class="flip-card-back">
BACK
</div>
</div>
</div>
app.component.css
.flip-card
height: 200px;
width: 200px;
background-color: transparent;
margin-top: 250px;
margin-left: auto;
margin-right: auto;
.flip-card-inner
position: relative;
height: 100%;
width: 100%;
transform-style: preserve-3d;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
.flip-card-inner > div
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
.flip-card-front
background-color: blue;
.flip-card-back
transform: rotateY(180deg);
background-color: green;
angular css3 animation flip angular-animations
I'm attempting to make a flip animation in Angular. It should flip over the Y-axis when clicked, then flip back over the Y-axis in the reverse direction when clicked again. Additionally, it should have front-side and back-side content that is displayed depending on the flip state.
The back-to-front flip is giving me grief. I'm getting odd behavior depending on what I try. The best I have been able to do is a weird flip which starts in the same direction as the front-to-back flip, then it changes direction at the end. *shrugs*
Note that if you click it before the animation finishes, it works as desired. If you wait for it to finish the animation, then it has the aforementioned behavior.
Here is the prototype: https://angular-epkrtn.stackblitz.io
Can anybody help with the back-to-front flip?
Copying the code from the link below
app.component.ts
import Component from '@angular/core';
import trigger, transition, animate, style, keyframes, state from '@angular/animations';
@Component(
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ],
animations: [
trigger('flip', [
state('front', style(
transform: 'rotateY(0deg)'
)),
state('back', style(
transform: 'rotateY(180deg)'
)),
transition('front => back', [
animate('1s 0s ease-out',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) rotateY(180deg)',
offset: 1
)
]))
]),
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(180deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(0deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 1
)
]))
])
])
]
)
export class AppComponent
flipState = 'front';
onFlipClick()
if (this.flipState == 'front')
this.flipState = 'back';
else
this.flipState = 'front';
app.component.html
<div (click)="onFlipClick()" class="flip-card">
<div [@flip]="flipState" class="flip-card-inner">
<div class="flip-card-front">
FRONT
</div>
<div class="flip-card-back">
BACK
</div>
</div>
</div>
app.component.css
.flip-card
height: 200px;
width: 200px;
background-color: transparent;
margin-top: 250px;
margin-left: auto;
margin-right: auto;
.flip-card-inner
position: relative;
height: 100%;
width: 100%;
transform-style: preserve-3d;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
.flip-card-inner > div
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
.flip-card-front
background-color: blue;
.flip-card-back
transform: rotateY(180deg);
background-color: green;
angular css3 animation flip angular-animations
angular css3 animation flip angular-animations
edited Mar 27 at 20:30
The Gilbert Arenas Dagger
asked Mar 27 at 19:50
The Gilbert Arenas DaggerThe Gilbert Arenas Dagger
5,7277 gold badges41 silver badges57 bronze badges
5,7277 gold badges41 silver badges57 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I think there are three issues with your code rotateY, scale3d and The background logic. I am no CSS expert and cannot help you a lot with the background logic if its needed to be fixed. It might is another question worth it if crucial for your usecase.
RotateY
- Your startpoint (back to front) is 180deg. That initially lets the card flip one way around with 0 time to animate
- Your animation direction is the wrong way, you need to animate negative wise.
- The provided solution only works if you do not click within the animation. So you need to wait for the @flip.done to be able to click/animate again. Otherwise you start animating from a ~180deg - 0deg rotation and move it around this way
Scale3d You do not finish your animation with the initial value: scale3d(1, 1, 1). I guess that can cause some weird behavior.
Background logic If you start your back to front animation you need to start initially your animation at 0deg. This will cause the front to show up, because your styling is broken there - Therefore I have no solution yet.
Link that fixed the animation: Flip Animation
Full code
trigger('flip', [
state('front', style(
transform: 'rotateY(0deg)'
)),
state('back', style(
transform: 'rotateY(180deg)'
)),
transition('front => back', [
animate('1s 0s ease-out',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) scale3d(1, 1, 1) rotateY(180deg)',
offset: 1
)
]))
]),
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(-80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(-100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(-180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) scale3d(1, 1, 1) rotateY(-180deg)',
offset: 1
)
]))
])
])
I hope I could help you. Feel free to ask more or correct me if I am wrong
1
Thanks for your response and +1. I agree with a lot of your assessment, I had attempted similar solutions but couldn't get past the front showing at the start of the back-to-front flip.
– The Gilbert Arenas Dagger
Mar 28 at 13:18
add a comment |
I was able to get the desired behavior with only a minor tweak to the original code. In the back => front transition, the starting value for rotateY is -180deg, not positive 180deg. Everything else is 100% identical.
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(-180deg)',
offset: 0
),
Demo: https://angular-hzuxl9.stackblitz.io
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55385400%2fangular-flip-animation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think there are three issues with your code rotateY, scale3d and The background logic. I am no CSS expert and cannot help you a lot with the background logic if its needed to be fixed. It might is another question worth it if crucial for your usecase.
RotateY
- Your startpoint (back to front) is 180deg. That initially lets the card flip one way around with 0 time to animate
- Your animation direction is the wrong way, you need to animate negative wise.
- The provided solution only works if you do not click within the animation. So you need to wait for the @flip.done to be able to click/animate again. Otherwise you start animating from a ~180deg - 0deg rotation and move it around this way
Scale3d You do not finish your animation with the initial value: scale3d(1, 1, 1). I guess that can cause some weird behavior.
Background logic If you start your back to front animation you need to start initially your animation at 0deg. This will cause the front to show up, because your styling is broken there - Therefore I have no solution yet.
Link that fixed the animation: Flip Animation
Full code
trigger('flip', [
state('front', style(
transform: 'rotateY(0deg)'
)),
state('back', style(
transform: 'rotateY(180deg)'
)),
transition('front => back', [
animate('1s 0s ease-out',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) scale3d(1, 1, 1) rotateY(180deg)',
offset: 1
)
]))
]),
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(-80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(-100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(-180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) scale3d(1, 1, 1) rotateY(-180deg)',
offset: 1
)
]))
])
])
I hope I could help you. Feel free to ask more or correct me if I am wrong
1
Thanks for your response and +1. I agree with a lot of your assessment, I had attempted similar solutions but couldn't get past the front showing at the start of the back-to-front flip.
– The Gilbert Arenas Dagger
Mar 28 at 13:18
add a comment |
I think there are three issues with your code rotateY, scale3d and The background logic. I am no CSS expert and cannot help you a lot with the background logic if its needed to be fixed. It might is another question worth it if crucial for your usecase.
RotateY
- Your startpoint (back to front) is 180deg. That initially lets the card flip one way around with 0 time to animate
- Your animation direction is the wrong way, you need to animate negative wise.
- The provided solution only works if you do not click within the animation. So you need to wait for the @flip.done to be able to click/animate again. Otherwise you start animating from a ~180deg - 0deg rotation and move it around this way
Scale3d You do not finish your animation with the initial value: scale3d(1, 1, 1). I guess that can cause some weird behavior.
Background logic If you start your back to front animation you need to start initially your animation at 0deg. This will cause the front to show up, because your styling is broken there - Therefore I have no solution yet.
Link that fixed the animation: Flip Animation
Full code
trigger('flip', [
state('front', style(
transform: 'rotateY(0deg)'
)),
state('back', style(
transform: 'rotateY(180deg)'
)),
transition('front => back', [
animate('1s 0s ease-out',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) scale3d(1, 1, 1) rotateY(180deg)',
offset: 1
)
]))
]),
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(-80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(-100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(-180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) scale3d(1, 1, 1) rotateY(-180deg)',
offset: 1
)
]))
])
])
I hope I could help you. Feel free to ask more or correct me if I am wrong
1
Thanks for your response and +1. I agree with a lot of your assessment, I had attempted similar solutions but couldn't get past the front showing at the start of the back-to-front flip.
– The Gilbert Arenas Dagger
Mar 28 at 13:18
add a comment |
I think there are three issues with your code rotateY, scale3d and The background logic. I am no CSS expert and cannot help you a lot with the background logic if its needed to be fixed. It might is another question worth it if crucial for your usecase.
RotateY
- Your startpoint (back to front) is 180deg. That initially lets the card flip one way around with 0 time to animate
- Your animation direction is the wrong way, you need to animate negative wise.
- The provided solution only works if you do not click within the animation. So you need to wait for the @flip.done to be able to click/animate again. Otherwise you start animating from a ~180deg - 0deg rotation and move it around this way
Scale3d You do not finish your animation with the initial value: scale3d(1, 1, 1). I guess that can cause some weird behavior.
Background logic If you start your back to front animation you need to start initially your animation at 0deg. This will cause the front to show up, because your styling is broken there - Therefore I have no solution yet.
Link that fixed the animation: Flip Animation
Full code
trigger('flip', [
state('front', style(
transform: 'rotateY(0deg)'
)),
state('back', style(
transform: 'rotateY(180deg)'
)),
transition('front => back', [
animate('1s 0s ease-out',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) scale3d(1, 1, 1) rotateY(180deg)',
offset: 1
)
]))
]),
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(-80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(-100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(-180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) scale3d(1, 1, 1) rotateY(-180deg)',
offset: 1
)
]))
])
])
I hope I could help you. Feel free to ask more or correct me if I am wrong
I think there are three issues with your code rotateY, scale3d and The background logic. I am no CSS expert and cannot help you a lot with the background logic if its needed to be fixed. It might is another question worth it if crucial for your usecase.
RotateY
- Your startpoint (back to front) is 180deg. That initially lets the card flip one way around with 0 time to animate
- Your animation direction is the wrong way, you need to animate negative wise.
- The provided solution only works if you do not click within the animation. So you need to wait for the @flip.done to be able to click/animate again. Otherwise you start animating from a ~180deg - 0deg rotation and move it around this way
Scale3d You do not finish your animation with the initial value: scale3d(1, 1, 1). I guess that can cause some weird behavior.
Background logic If you start your back to front animation you need to start initially your animation at 0deg. This will cause the front to show up, because your styling is broken there - Therefore I have no solution yet.
Link that fixed the animation: Flip Animation
Full code
trigger('flip', [
state('front', style(
transform: 'rotateY(0deg)'
)),
state('back', style(
transform: 'rotateY(180deg)'
)),
transition('front => back', [
animate('1s 0s ease-out',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) scale3d(1, 1, 1) rotateY(180deg)',
offset: 1
)
]))
]),
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(-80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(-100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(-180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) scale3d(1, 1, 1) rotateY(-180deg)',
offset: 1
)
]))
])
])
I hope I could help you. Feel free to ask more or correct me if I am wrong
trigger('flip', [
state('front', style(
transform: 'rotateY(0deg)'
)),
state('back', style(
transform: 'rotateY(180deg)'
)),
transition('front => back', [
animate('1s 0s ease-out',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) scale3d(1, 1, 1) rotateY(180deg)',
offset: 1
)
]))
]),
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(-80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(-100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(-180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) scale3d(1, 1, 1) rotateY(-180deg)',
offset: 1
)
]))
])
])
trigger('flip', [
state('front', style(
transform: 'rotateY(0deg)'
)),
state('back', style(
transform: 'rotateY(180deg)'
)),
transition('front => back', [
animate('1s 0s ease-out',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) scale3d(1, 1, 1) rotateY(180deg)',
offset: 1
)
]))
]),
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(0deg)',
offset: 0
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(-80deg)',
offset: 0.4
),
style(
transform: 'perspective(400px) scale3d(1.5, 1.5, 1.5) rotateY(-100deg)',
offset: 0.5
),
style(
transform: 'perspective(400px) scale3d(0.95, 0.95, 0.95) rotateY(-180deg)',
offset: 0.8
),
style(
transform: 'perspective(400px) scale3d(1, 1, 1) rotateY(-180deg)',
offset: 1
)
]))
])
])
answered Mar 28 at 12:59
Jonathan StellwagJonathan Stellwag
1,1571 gold badge9 silver badges26 bronze badges
1,1571 gold badge9 silver badges26 bronze badges
1
Thanks for your response and +1. I agree with a lot of your assessment, I had attempted similar solutions but couldn't get past the front showing at the start of the back-to-front flip.
– The Gilbert Arenas Dagger
Mar 28 at 13:18
add a comment |
1
Thanks for your response and +1. I agree with a lot of your assessment, I had attempted similar solutions but couldn't get past the front showing at the start of the back-to-front flip.
– The Gilbert Arenas Dagger
Mar 28 at 13:18
1
1
Thanks for your response and +1. I agree with a lot of your assessment, I had attempted similar solutions but couldn't get past the front showing at the start of the back-to-front flip.
– The Gilbert Arenas Dagger
Mar 28 at 13:18
Thanks for your response and +1. I agree with a lot of your assessment, I had attempted similar solutions but couldn't get past the front showing at the start of the back-to-front flip.
– The Gilbert Arenas Dagger
Mar 28 at 13:18
add a comment |
I was able to get the desired behavior with only a minor tweak to the original code. In the back => front transition, the starting value for rotateY is -180deg, not positive 180deg. Everything else is 100% identical.
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(-180deg)',
offset: 0
),
Demo: https://angular-hzuxl9.stackblitz.io
add a comment |
I was able to get the desired behavior with only a minor tweak to the original code. In the back => front transition, the starting value for rotateY is -180deg, not positive 180deg. Everything else is 100% identical.
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(-180deg)',
offset: 0
),
Demo: https://angular-hzuxl9.stackblitz.io
add a comment |
I was able to get the desired behavior with only a minor tweak to the original code. In the back => front transition, the starting value for rotateY is -180deg, not positive 180deg. Everything else is 100% identical.
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(-180deg)',
offset: 0
),
Demo: https://angular-hzuxl9.stackblitz.io
I was able to get the desired behavior with only a minor tweak to the original code. In the back => front transition, the starting value for rotateY is -180deg, not positive 180deg. Everything else is 100% identical.
transition('back => front', [
animate('1s 0s ease-in',
keyframes([
style(
transform: 'perspective(400px) rotateY(-180deg)',
offset: 0
),
Demo: https://angular-hzuxl9.stackblitz.io
answered Mar 28 at 13:31
The Gilbert Arenas DaggerThe Gilbert Arenas Dagger
5,7277 gold badges41 silver badges57 bronze badges
5,7277 gold badges41 silver badges57 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55385400%2fangular-flip-animation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown