2
How to make a transition with pure CSS, and in the final transition layout I will have 2 boxes on the left side.
The transition:
When loading the page, you will only have one box with evaluation information. When I select a snippet of text, this box goes down and above it, there should appear a box that is hidden on the left of the page, this effect should occur when I select a snippet of text the box that will appear with a fadein effect (all effects, both to go down and to appear, must be synchronized), note that this I have the example of the effect in the link below (with javascript).
I would like to do the same effect using only CSS, being that I am using ng-Hide / ng-show from Angularjs.
It is possible to do the same effect?
Here follows SCSS that tried and did not get very good...
.display-mark {
opacity:0 ;
transform: translateX(100%);
-webkit-transform: translateX(100%);
-ms-transform: translateX(100%);
-moz-transform: translateX(100%);
-o-transform: translateX(100%);
//transform: translateX(0%);
//-webkit-transform: translateX(0%);
//-ms-transform: translateX(0%);
//-moz-transform: translateX(0%);
//-o-transform: translateX(0%);
display: block;
position: relative$i;
animation: all 0.3s ease-in;
-webkit-animation: all 0.3s ease-in;
//&.anime-open-vertical,
//&.anime-open-vertical-add {
// display: block;
// position: relative;
// animation: moveIn 0.4s ease-in;
// -webkit-animation: moveIn 0.4s ease-in;
//}
&.ng-animate.anime-close-vertical {
display: block$i;
animation: moveOut 0.4s ease-out;
-webkit-animation: moveOut 0.4s ease-out;
}
&.anime-open-vertical {
opacity:1;
transform: translateX(0%);
-webkit-transform: translateX(0%);
-ms-transform: translateX(0%);
-moz-transform: translateX(0%);
-o-transform: translateX(0%);
display: block$i;
}
&.anime-open-vertical-add,
&.ng-animate.anime-open-vertical {
transform: translateX(0%);
-webkit-transform: translateX(0%);
-ms-transform: translateX(0%);
-moz-transform: translateX(0%);
-o-transform: translateX(0%);
opacity:1;
display: block$i;
animation: moveIn 0.4s ease-in;
-webkit-animation: moveIn 0.4s ease-in;
}
&.ng-animate.ng-hide-add {
display: none$i;
}
&.ng-animate.ng-hide-remove {
display: block$i;
}
}
.anime-vertical{
//display: none$i;
position: relative;
height: 0;
animation: all 0.5s ease-in;
-webkit-animation: all 0.5s ease-in;
}
.display-mark.ng-animate.ng-hide {
opacity:0;
transform: translateX(100%);
-webkit-transform: translateX(100%);
-ms-transform: translateX(100%);
-moz-transform: translateX(100%);
-o-transform: translateX(100%);
display: block$i;
}
//.display-mark.animate-show-hide.ng-hide {
// opacity:0;
// transform: translateX(104%);
// -webkit-transform: translateX(104%);
// -ms-transform: translateX(104%);
// -moz-transform: translateX(104%);
// -o-transform: translateX(104%);
// display: block$i;
// position: relative$i;
//}
.anime-vertical {
&.anime-down {
display: block;
position: relative;
animation: moveDown 0.4s ease-in;
-webkit-animation: moveDown 0.4s ease-in;
}
&.anime-up {
display: block;
position: relative;
animation: moveUp 0.4s ease-in;
-webkit-animation: moveUp 0.4s ease-in;
}
}
@keyframes moveIn {
0% { transform: translateX(100%); opacity: 0; position: static$i }
50% { transform: translateX(50%); opacity: 1; position: static$i }
100% { transform: translateX(0%); opacity: 1; position: static$i }
}
@-webkit-keyframes moveIn {
0% { transform: translateX(100%); opacity: 0; position: static$i }
50% { transform: translateX(50%); opacity: 1; position: static$i }
100% { -webkit-transform: translateX(0%); opacity: 1; position: static$i }
}
@keyframes moveOut {
0% { transform: translateX(0%); opacity: 1;position: static$i }
50% { transform: translateX(50%); opacity: 1; position: static$i }
100% { transform: translateX(100%); opacity: 0; position: static$i }
}
@-webkit-keyframes moveOut {
0% { -webkit-transform: translateX(0%); opacity: 1; position: static$i }
50% { transform: translateX(50%); opacity: 1; position: static$i }
100% { -webkit-transform: translateX(100%); opacity: 0; position: static$i }
}
/**
*/
@keyframes moveUp {
0% { height: 310px; }
100% { height: 0px; }
}
@-webkit-keyframes moveUp {
0% { height: 310px; }
100% { height: 0px; }
}
@keyframes moveDown {
0% { height: 0px; }
100% { height: 310px; }
}
@-webkit-keyframes moveDown {
0% { height: 0px; }
100% { height: 310px; }
}
<div id="scroller_content" class="scroll-forms" ng-class="{'no-overflow': !variavel_true_false}">
BOX 1:
<div id="form_mark_box" ng-show="variavel_true_false" class="display-mark" ng-class="{'anime-open-vertical':(variavel_true_false),'anime-close-vertical':(!variavel_true_false)}"><!-- BOX 1 -->nonono nonono</div>
BOX 2:
<div id="animate-down-element" class="anime-vertical" ng-class="{'anime-down':(variavel_true_false), 'anime-up':(!variavel_true_false && data_review.animeUp)}"></div>
<div id="form_prod_textual" ng-style="data_review.reposition_form_producao_textual" class="form-rule-actions form-producao-textual">
<form class="form-review">
<!-- BOX 2 --> nonono nonono
</form>
</div>
Here is a video that shows the problem.
So the effect is similar to this, but I can’t use target, I can pass a class in ng-class during the event... because while the show/show event occurs, it also takes some classes, ng-Animate, ng-Hide-add, ng-Hide-remove...
– Ivan Ferrer
@Ivanferrer then just where is
#fecha:target ~ .box-fecha
or#abre:target ~ .box-abre
you put class names, without needing the:target
guy#fecha.ng-animate ~ .box-abre
or#abre.ng-animate ~ .box-fecha
. This is just an example. But what you have to understand istransition
and thetransition-delay
it is with them that you will synchronize the animation. And the concept of the selector~
which means that when a #ID element above receives theng-animate
element . class below will receive animation– hugocsl
I put a mother class, to trigger the target type events, the exit event works, but not in the way it should, but even so the biggest problem is that I am working with elements that have varying heights, because they are with position: relative or Static, in your example you used position: Absolute, which limits the action...
– Ivan Ferrer
@Ivanferrer this example would be for an "ideal" situation really. But it’s the concept that matters, when I did the answer I figured you’d need to adapt something. If you want to open another question and put what you have of code at the moment and what is the problem you are having there with details. Or if you prefer to take this Answer code and put a Question explaining that this model works well with fixed values, but you need it to work with variable values because you don’t know how big the red block on top will be etc. This makes it easier for me or someone else to help you
– hugocsl
I posted a video to expose my problem. Note that when I cancel, instead of the box go up smooth, it goes straight up... in case, this happens because it is not an absolute element, but when I put it as absolute, it goes up smooth, however, does not wait for the top element to disappear, and already begins to rise...
– Ivan Ferrer
@Ivanferrer tries so, after the input animation has already happened and the elements are in place, in the element you want to delay the animation you put a 500ms Transition-delay. This should solve. I did another example here, it is even simpler and does not use position:Bsolute. I made it with checkbox just to finish the model faster, but sometimes it can give you a light tb pq it does not use fixed height values. https://codepen.io/hugocsl/pen/VOGBvm
– hugocsl
This last example came closer, however, it comes from the right, I tried to do the same on the left, and it didn’t work...
– Ivan Ferrer
@Ivanferrer if that’s the case opens another question with the code you have at the moment. As I told you the purpose of this answer was to give you a practical example of how to apply the technique, and not to do exactly or replicate the problem you have there. The intention was to pass the knowledge to you to do the work. If you have another question, post what you have at the moment, that I or another member try to help you.
– hugocsl
Note that the form I used with click does not work, the example: https://jsfiddle.net/ivanferrer/3t4v29Lm/
– Ivan Ferrer