Background slide animation during onMouseMove not working as expected - css

I have a React Login screen with black background set using CSS Styling. The login screen is quite elementary at this point which comprises of 3 input tag username, password and submit respectively.
All i am trying to do right now is change the background of the login screen with slide down effect (height 0 to height $loginScreenHeight) whenever the mouse moves.
I got it working as expected but with a slight side-effect. The side-effect is whenever the mouse moves the initial background goes away momentarily and the new background starts sliding down.
I want the new background to start sliding on top of the old background and cover it up. Can some Css expert please throw a light on what i am missing here?
Following is my code.
import React from "react";
import axios from "axios";
import { connect } from "react-redux";
import { userlogin } from "./../action/userLogin";
class Login extends React.Component {
state = {
email: "",
passwd: "",
loginStatus: "",
mouseOverLogin: false
};
enteruname = e => this.setState({ email: e.target.value });
enterpasswd = e => this.setState({ passwd: e.target.value });
submitCredentials = e => e.preventDefault();
render() {
return (
<div
className="login"
onMouseMove={() => this.setState({ mouseOverLogin: true })}
>
<form
onSubmit={this.submitCredentials}
className={
this.state.mouseOverLogin ? "loginForm animateLogin" : "loginForm"
}
>
<p>Login</p>
<hr />
<input
className="uname"
placeholder="Enter Username"
type="email"
name="email"
value={this.state.email}
onChange={this.enteruname}
/>
<input
className="passwd"
placeholder="Enter Password"
type="password"
name="passwd"
value={this.state.passwd}
onChange={this.enterpasswd}
/>
<button className="loginBtn">Login</button>
</form>
</div>
);
}
}
export default connect()(Login);
CSS File:-
.login {
width: 100vw;
height: 100vh;
overflow: hidden;
position: absolute;
top: 0vh;
left: 0vw;
}
.loginForm {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
top: 25vh;
left: 38vw;
width: 27vw;
height: 54vh;
background: rgba(0, 0, 0, 0.7);
position: relative;
z-index: 1000;
border-radius: 20px;
}
.login form input {
margin: 0 auto;
width: 24vw;
height: 6vh;
border-radius: 20px;
outline: none;
background: rgba(42, 27, 61, 0.6);
color: white;
text-align: center;
font-size: 1.2rem;
}
.uname {
position: absolute;
top: 18vh;
}
.uname:focus,
.passwd:focus {
background: rgba(42, 27, 61, 0.6);
}
.passwd {
position: absolute;
top: 28vh;
}
.loginBtn {
position: absolute;
width: 50%;
height: 5vh;
left: 25%;
text-decoration: none;
outline: none;
top: 38vh;
border-radius: 20px;
background: rgba(42, 27, 61, 0.6);
color: white;
}
.login form input::placeholder {
color: white;
text-align: center;
font-size: 1.2rem;
}
.login form p {
color: white;
font-size: 25px;
width: 24vw;
position: absolute;
top: 5vh;
left: 2vw;
}
.animateLogin {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 25vh;
left: 38vw;
width: 27vw;
animation: slideDown 2s 1 forwards ease-in-out;
z-index: 0;
// transition: all 280ms ease-in-out;
}
#keyframes slideDown {
from {
height: 0;
background: rgba(0, 0, 0, 0.7);
}
to {
background: $navlink;
height: 54vh;
}
}
hr {
position: absolute;
top: 12vh;
width: 24vw;
height: 1px;
background: white;
}

the height change to 0 is a problem because the "old background" is set on the element with 0 height.
I wrote 2 POC that can help you:
.a,
.b {
margin: 10px;
padding: 10px;
height: 30px;
text-align: center;
border: solid 1px blue;
background: green;
position: relative;
}
.a:hover {
animation: slidebg 2s;
box-shadow: inset 0 50px 0 0 blue;
}
#keyframes slidebg {
0% {
box-shadow: inset 0 0 0 0 blue;
}
100% {
box-shadow: inset 0 50px 0 0 blue;
}
}
.b-bg {
position: absolute;
height: 0;
top: 0;
left: 0;
background: blue;
width: 100%;
}
.b span {
position: relative;
z-index: 10;
}
.b:hover .b-bg {
animation: slidebg2 2s;
height: 100%;
}
#keyframes slidebg2 {
0% {
height: 0;
}
100% {
height: 100%;
}
}
<div class="a">link</div>
<div class="b">
<div class="b-bg"></div>
<span>link</span>
</div>

Related

video format camera not working properly on iphone

In nuxtjs I developed a simple camera without plugin. On notebook and android phones it works, but on iphone not correctly.
The problem is that on the iphone the css I inserted does not disable the pointer-events and the controls, that is, you can open the video and it should work statically, without the controls.
Could someone tell me what's missing?
<div class="takePhoto__camera">
<video ref="video" muted></video>
<img class="takePhoto__camera__filter" src="../../assets/images/filtro.png" ref="filter" alt="Filtro">
<button class="takePhoto__camera__btn" #click.prevent="photoTaken"></button>
</div>
<script>
import { mapMutations } from "vuex"
export default {
name: "ComponentCameraVideo",
data(){
return{
video: null,
}
},
mounted(){
this.video = this.$refs.video;
this.init();
},
methods: {
...mapMutations(["SET_VIDEO"]),
init(){
if('mediaDevices' in navigator && 'getUserMedia' in navigator.mediaDevices){
navigator.mediaDevices.getUserMedia({video: true}).then((stream) => {
this.video.srcObject = stream;
this.video.play();
}).catch((error) => {
console.log(error)
alert(error);
})
}
else{
alert("Não foi possível acessar a câmera!");
}
},
photoTaken(){
this.SET_VIDEO([this.video, this.$refs.filter]);
this.$emit("photoTaken");
}
},
}
</script>
&__camera{
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: rgb(0, 0, 0);
box-sizing: border-box;
position: fixed;
top: 0;
left: 0;
z-index: 999999;
video{
width: 100%;
pointer-events: none;
height: 100%;
&::-webkit-media-controls,
&::-webkit-media-controls-enclosure,
&::-webkit-media-controls-timeline,
&::-webkit-full-screen {
display:none !important;
}
}
button{
width: 75px;
height: 75px;
display: block;
background-color: #fff;
border: 2px solid $dark_green;
border-radius: 50%;
box-shadow: 0 1px 5px rgba(0, 0, 0, .3);
position: absolute;
left: 50%;
bottom: 10px;
transform: translateX(-50%);
z-index: 99;
&:hover{
box-shadow: 0 1px 5px rgba(0, 0, 0, 1);
}
}
&__filter{
height: 100%;
pointer-events: none;
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
z-index: 9;
}
}
The project link for you to test if necessary.
https://torcida.petronas.com.br/

Fade one element out while fade in background element on hover

I want to fade out a text placed on an image on hover and fade in another from the background.
So far the fade out part is working, but the fade in part not. See "run code snippet".
I want fade out the first text completely but not fully cover the background image which is why the opacity of:
location-wrapper { background-color: rgba(0, 0, 0, 0.6);}
is set to 0.6 and:
.location-wrapper:hover {
background-color: rgb(255, 255, 255);
opacity: 0.7;
}
set to 0.7.
If I set the opacity of the background text to 1, I can see the background text is there, but the transition on hover to blend it in is not working. I guess because the div is in the background and the hover of the first div is triggered and not the hover option of the background?
.location-container {
position: relative;
height: 200px;
width: 100%;
color: white;
}
.location-bg-image {
position: absolute !important;
width: 100%;
height: 100%;
background-color: transparent;
z-index: -1;
}
.location-wrapper {
background-color: rgba(0, 0, 0, 0.6);
text-align: center;
position: absolute;
width: 100%;
height: 100%;
z-index: 10;
opacity: 1;
transition: 2s;
}
.location-wrapper:hover {
background-color: rgb(255, 255, 255);
opacity: 0.7;
}
.location-overlay {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.location-city {
padding-bottom: 60px;
color: white;
font-size: 25px;
font-weight: 400;
}
.location-text-wrapper {
height: 100%;
padding-top: 40px;
width: 100%;
opacity: 1;
transition: 5s;
display: flex;
flex-direction: column;
-ms-flex-align: center;
align-items: center;
justify-content: center;
}
.location-text-wrapper:hover {
opacity: 1;
}
.location-text {
color: white;
font-size: 18px;
opacity: 0;
transition: 5s
}
.location-text:hover {
opacity: 1;
}
<div class="location-container">
<Image class="location-bg-image" src="https://via.placeholder.com/150/000000/FFFFFF/"/>
<div class="location-wrapper has-bg-image">
<div class="location-overlay">
<div class="location-city">ExampleCity</div>
</div>
</div>
<div class="location-text-wrapper">
<div class="location-text">ExampleBackgroundText</div>
</div>
</div>
You don't need to have a separate .location-text-wrapper. I've changed your HTML a bit in the snippet below. I've inserted .location-text inside .location-overlay, and on .location-wrapper:hover I'm updating the value of opacity for .location-city and .location-text. This will give you the behaviour that you desire.
.location-container {
position: relative;
height: 200px;
width: 100%;
color: white;
}
.location-bg-image {
position: absolute !important;
width: 100%;
height: 100%;
background-color: transparent;
z-index: -1;
}
.location-wrapper {
background-color: rgba(0, 0, 0, 0.6);
text-align: center;
position: absolute;
width: 100%;
height: 100%;
z-index: 10;
opacity: 1;
transition: 2s;
}
.location-wrapper:hover {
background-color: rgb(255, 255, 255);
opacity: 0.7;
}
.location-overlay {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
opacity: 1
}
.location-city {
padding-bottom: 60px;
color: white;
font-size: 25px;
font-weight: 400;
opacity: 1;
transition: 5s;
}
.location-wrapper:hover .location-city {
opacity: 0;
}
.location-wrapper:hover .location-text {
opacity: 1;
}
.location-text {
color: black;
font-size: 18px;
opacity: 1;
transition: 5s
}
<div class="location-container">
<Image class="location-bg-image" src="https://via.placeholder.com/150/000000/FFFFFF/"/>
<div class="location-wrapper has-bg-image">
<div class="location-overlay">
<div class="location-city">ExampleCity</div>
<div class="location-text">ExampleBackgroundText</div>
</div>
</div>
</div>

Fullscreen Background Image with React JS Div and Component

I'm sure the answer is right in front of me, but I have searched and searched for hours and have been unable to come up with a fix. I am wondering how to have my background image fill the whole screen. It fills most of the screen, except where the header would be. I can get the full screen background image, only when I comment out the "Form" component. When I go to inspect the portion that is not filled, it says it shows as html, which I suspect is pulled from the index.html file in the public folder. I would greatly appreciate any and all help on this.
App.js
import React from 'react';
import './App.css';
import Form from './Form';
import wallstreet from './images/wallstreet.png';
function App() {
return (
<div className="App">
<div className="overlay"
style={{backgroundImage: `url(${wallstreet})`}} />
<Form />
</div>
);
}
export default App;
App.css
#import url('https://fonts.googleapis.com/css2?family=PT+Sans&display=swap');
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'PT Sans', sans-serif;
}
.overlay {
position: fixed;
min-width: 100%;
min-height: 100%;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
Form.js
import React, { useState } from 'react';
import FormSignup from './FormSignup';
import FormSuccess from './FormSuccess';
import './Form.css';
const Form = () => {
const [isSubmitted, setIsSubmitted] = useState(false)
function submitForm() {
setIsSubmitted(true);
}
return (
<>
<div className="form-container">
<span className="close-btn">x</span>
<div className="form-content-left">
<img className='form-img' src='images/bullish.png' alt='bullish' />
</div>
{!isSubmitted ? (<FormSignup submitForm=
{submitForm} />) : <FormSuccess />}
</div>
</>
);
};
export default Form;
Form.css
.form-container {
margin: 100px auto;
width: 1000px;
box-shadow: 0 5px 8px 0 rgba(0, 0, 0, 0.2), 0 7px 20px 0 rgba(0, 0, 0, 0.2);
position: relative;
border-radius: 10px;
height: 600px;
display: grid;
grid-template-columns: 1fr 1fr;
}
.close-btn {
position: absolute;
top: 2%;
right: 3%;
font-size: 1.5rem;
z-index: 1;
color: #fff;
cursor: pointer;
}
.form-content-left {
background: linear-gradient(
90deg,
rgb(39, 176, 255) 0%,
rgb(0, 232, 236) 100%
);
border-radius: 10px 0 0 10px;
position: relative;
}
.form-img {
width: 80%;
height: 80%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.form-img-2 {
width: 60%;
height: 60%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.form-success {
text-align: center;
font-size: 24px;
margin-top: 80px;
color: #fff;
}
.form-content-right {
border-radius: 0 10px 10px 0;
position: relative;
background: linear-gradient(90deg, rgb(40, 40, 40) 0%, rgb(17, 17, 17) 100%);
}
.form {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 90%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.form h1 {
font-size: 1rem;
text-align: start;
width: 80%;
margin-bottom: 1rem;
color: #fff;
}
.form-inputs {
margin-bottom: 0.5rem;
width: 80%;
}
.form-inputs p {
font-size: 0.8rem;
margin-top: 0.5rem;
color: #f00e0e;
}
.form-label {
display: inline-block;
font-size: 0.8rem;
margin-bottom: 6px;
color: #fff;
}
.form-input {
display: block;
padding-left: 10px;
outline: none;
border-radius: 2px;
height: 40px;
width: 100%;
border: none;
}
.form-input::placeholder {
color: #595959;
font-size: 12px;
}
.form-input-btn {
width: 80%;
height: 50px;
margin-top: 10px;
border-radius: 2px;
background: linear-gradient(
90deg,
rgb(39, 176, 255) 0%,
rgb(0, 232, 236) 100%
);
outline: none;
border: none;
color: #fff;
font-size: 1rem;
}
.form-input-btn:hover {
cursor: pointer;
background: linear-gradient(
90deg,
rgb(39, 143, 255) 0%,
rgb(12, 99, 250) 100%
);
transition: all 0.4s ease-out;
}
.form-input-login {
font-size: 0.8rem;
margin-top: 10px;
color: #fff;
width: 80%;
text-align: center;
}
.form-input-login a {
text-decoration: none;
color: #27cdff;
font-weight: 6
00;
}
Did you try 100vh and 100vw along with position absolute.
also search if any of the parent element is having relative position

Using Toastr, how can I create a very different looking toast from default (what are my options?)

I am using Angular 9 and ngx-toastr
I have the task of using toastr to create a set of toasts which look quite different from the default toast styles. Each in the set are basically the same, except for border colour, fontawesome icon and message (which I can just pass in).
Here is one of the toast mockups: enter image description here
Toastr has it's own toastr.css style sheet which I added to angular.json. Without it, toasts won't even open. I have my own toast-messages.scss file that contains all the css to realize my mockup. I will include it. It's also added to angular.json
"styles": [
"node_modules/#fortawesome/fontawesome-free/css/fontawesome.css",
"node_modules/#fortawesome/fontawesome-free/css/solid.css",
"src/styles.scss",
"node_modules/ngx-toastr/toastr.css",
"src/app/styles/toast-messages.scss"
],
What I find is that unless every line in my toast-messages.scss file needs an !important in it for it to override what's in the toastr.css and you know that's horrible.
my question
What are my options to create this style of toast without using all these !important tags in my css. Am I referencing the css/scss files in the wrong spot? Should I create a custom toast and if so, is there a good resource for that? I am only 2 months into Angular.
toast-messages.scss I know my formatting is horrible, this has been trial and error
.toast-container .ngx-toastr {
position: relative;
width: 888px;
height: 79px;
margin-left: auto;
margin-right: auto;
top: 60px;
padding-right: 0px;
padding-top: 0px;
padding-bottom: 0px;
border-radius: 5px;
background-position: 15px center;
background-repeat: no-repeat;
background-size: 24px;
box-shadow: 0 0 12px #999999;
color: #FFFFFF;
}
.toast-container .ngx-toastr:hover {
box-shadow: 0 0 12px #000000 ;
opacity: 1;
cursor: pointer ;
}
.toast-container {
pointer-events: none;
position: fixed;
z-index: 9999;
}
.toast-container * {
box-sizing: border-box;
}
.toast-message {
position: relative;
word-wrap: break-word;
background-color: #FFFFFF;
top: 2px;
width: 886px;
height: 75px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
.message-boxy {
top: 2px;
width: 886px;
height: 75px;
}
.message-symbol {
background-color: #800017;
width: 79px;
height: 75px;
text-align: center;
position: relative;
float: left;
left: 0px;
}
.message-symbol i {
width: 28px;
height: 28px;
transform: translateY(0.7em);
}
.toast-text-container {
position: relative;
width:886px;
border-style:solid;
border-color: #FFAE15;
border-width:2px;
left: 0px;
height: 75px;
background-color: transparent;
z-index: 10;
}
.message-text {
line-height: 75px;
border-style:solid;
left: 79px;
height: 75px;
border-color: #157EF9;
border-width:2px;
width: 500px;
letter-spacing: 0px;
text-align: left;
text-indent: 10px;
font-weight: bold;
font-size: 18px;
color: #555555;
z-index: 10;
}
.btncontainer {
background-color: pink;
position: relative;
float:right;
padding: 0 20px;
z-index: 20;
}
.reloadpage {
color: #157EF9;
font-weight: bold;
opacity: 1;
z-index: 20;
}
.reloadpage:hover {
opacity: 0.8;
}
.toast-close-button {
border: none;
top: 27px;
right: 10px;
float: right;
background-color: #FFFFFF;
width: 25px !important;
height: 25px !important;
opacity: 1;
z-index: 10;
}
/*Additional properties for button version
iOS requires the button element instead of an anchor tag.
If you want the anchor version, it requires `href="#"`.*/
button.toast-close-button {
cursor: pointer;
border: none;
background-color: #FFFFFF;
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' width='512' height='512'%3E%3Cpath fill='rgb(255,255,255)' d='M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z'/%3E%3C/svg%3E");
width: 25px !important;
height: 25px !important;
opacity: 1;
z-index: 10;
}
.toast-close-button:hover,
.toast-close-button:focus {
text-decoration: none;
cursor: pointer;
opacity: 1;
}
/* https://github.com/FortAwesome/Font-Awesome-Pro/blob/master/advanced-options/raw-svg/regular/info-circle.svg */
.toast-info {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' width='512' height='512'%3E%3Cpath fill='rgb(255,255,255)' d='M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z'/%3E%3C/svg%3E");
width: 28.74px;
height: 28.74px;
padding: 25px;
}
/* https://github.com/FortAwesome/Font-Awesome-Pro/blob/master/advanced-options/raw-svg/regular/times-circle.svg */
.toast-error {
background-image: none;
}
/* https://github.com/FortAwesome/Font-Awesome-Pro/blob/master/advanced-options/raw-svg/regular/check.svg */
.toast-success {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' width='512' height='512'%3E%3Cpath fill='rgb(255,255,255)' d='M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z'/%3E%3C/svg%3E");
width: 28.74px;
height: 70px;
justify-self: center !important;
}
/* https://github.com/FortAwesome/Font-Awesome-Pro/blob/master/advanced-options/raw-svg/regular/exclamation-triangle.svg */
.toast-warning {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' width='512' height='512'%3E%3Cpath fill='rgb(255,255,255)' d='M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z'/%3E%3C/svg%3E");
width: 28.74px;
height: 28.74px;
}
.toast-container.toast-top-full-width .ngx-toastr,
.toast-container.toast-bottom-full-width .ngx-toastr {
width: 96%;
margin-left: auto;
margin-right: auto;
}
.ngx-toastr {
background-color: #030303;
pointer-events: auto;
}
.toast-success {
background-color: #4C6A13;
}
.toast-error {
background-color: #800017;
}
.toast-info {
background-color: #555555;
}
.toast-warning {
background-color: #FFAE15;
}
.toast-progress {
position: absolute;
left: 0;
bottom: 0;
height: 4px;
background-color: #000000;
opacity: 0.4;
}
You can create your custom toast as mentioned in the documentation
You can follow this code:
import {
animate,
keyframes,
state,
style,
transition,
trigger
} from '#angular/animations';
import { Component } from '#angular/core';
import { Toast, ToastrService, ToastPackage } from '../lib/public_api';
#Component({
selector: '[pink-toast-component]',
styles: [`
:host {
background-color: #FF69B4;
position: relative;
overflow: hidden;
margin: 0 0 6px;
padding: 10px 10px 10px 10px;
width: 300px;
border-radius: 3px 3px 3px 3px;
color: #FFFFFF;
pointer-events: all;
cursor: pointer;
}
.btn-pink {
-webkit-backface-visibility: hidden;
-webkit-transform: translateZ(0);
}
`],
template: `
<div class="row" [style.display]="state.value === 'inactive' ? 'none' : ''">
<div class="col-9">
<div *ngIf="title" [class]="options.titleClass" [attr.aria-label]="title">
{{ title }}
</div>
<div *ngIf="message && options.enableHtml" role="alert" aria-live="polite"
[class]="options.messageClass" [innerHTML]="message">
</div>
<div *ngIf="message && !options.enableHtml" role="alert" aria-live="polite"
[class]="options.messageClass" [attr.aria-label]="message">
{{ message }}
</div>
</div>
<div class="col-3 text-right">
<a *ngIf="!options.closeButton" class="btn btn-pink btn-sm" (click)="action($event)">
{{ undoString }}
</a>
<a *ngIf="options.closeButton" (click)="remove()" class="btn btn-pink btn-sm">
close
</a>
</div>
</div>
<div *ngIf="options.progressBar">
<div class="toast-progress" [style.width]="width + '%'"></div>
</div>
`,
animations: [
trigger('flyInOut', [
state('inactive', style({
opacity: 0,
})),
transition('inactive => active', animate('400ms ease-out', keyframes([
style({
transform: 'translate3d(100%, 0, 0) skewX(-30deg)',
opacity: 0,
}),
style({
transform: 'skewX(20deg)',
opacity: 1,
}),
style({
transform: 'skewX(-5deg)',
opacity: 1,
}),
style({
transform: 'none',
opacity: 1,
}),
]))),
transition('active => removed', animate('400ms ease-out', keyframes([
style({
opacity: 1,
}),
style({
transform: 'translate3d(100%, 0, 0) skewX(30deg)',
opacity: 0,
}),
]))),
]),
],
preserveWhitespaces: false,
})
export class PinkToast extends Toast {
// used for demo purposes
undoString = 'undo';
// constructor is only necessary when not using AoT
constructor(
protected toastrService: ToastrService,
public toastPackage: ToastPackage,
) {
super(toastrService, toastPackage);
}
action(event: Event) {
event.stopPropagation();
this.undoString = 'undid';
this.toastPackage.triggerAction();
return false;
}
}

Flexbox not working correctly - seems that dom is recalculated

I have this menu (this happens also with the website text)
<div id="container" class='container'>
<div class='meta-background'></div>
<section class='meta-container'>
<div class="meta-menu meta-menu-top">
<ul>
<li>testsas</li>
<li>fdadasdasdas</li>
<li>dsdasdsadasdsa</li>
</ul>
<span class="meta-title">WEBSITE</span>
</div>
<div class="meta-menu meta-menu-bottom"></div>
</section>
</div>
css:
/* contaner */
/* * { padding:0; margin:0; box-sizing: border-box;} */
.container {
max-width: 2380px;
margin-left: auto;
margin-right: auto;
}
.meta-container {
display: flex;
/* -webkit-box-pack: center; */
/* -ms-flex-pack: center; */
justify-content: center;
}
.meta-background {
position: fixed;
margin-left: auto;
margin-right: auto;
z-index: -1;
background-size: cover;
background-repeat: no-repeat;
-webkit-filter: blur(10px);
filter: blur(10px);
top: 0;
right: 0;
bottom: 0;
left: 0;
/* background-image: url('./assets/img/3.jpg'); */
}
.meta-title {
color: white;
position: absolute;
bottom: 10px;
display: block;
}
/* menus */
.meta-menu-top {
background: #252422;
color: #959595;
border-radius: 0px 0px 10px 10px;
/* top: 0px; */
position: absolute;
height: 48%;
width: 360px;
opacity: 0.7;
display: flex;
justify-content: center;
}
.meta-menu-top ul {
padding: 0;
margin-top: 30%;
}
.meta-menu-top li {
list-style-type: none;
display: block;
}
.meta-menu-bottom {
background: #eef1f5;
color: white;
border-radius: 10px 10px 0px 0px;
/* bottom: 0px; */
position: absolute;
height: 48%;
width: 360px;
}
and the JS to hide/show the menu
let menutop = $('.meta-menu-top'),
menubottom = $('.meta-menu-bottom');
//set cookie for future preference
//
//
//get cookie if first run or not
//
//
let upDown = 0,
duration = 1;
let tlshow = new TimelineMax({ paused: true });
tlshow.fromTo(menutop, duration, {top: '-40%' } ,{ top: 0, ease: Power3.easeInOut })
.fromTo(menubottom, duration, { bottom: '-40%' },{ bottom: 0, ease: Power3.easeInOut }, '-=' + duration);
let tlhide = new TimelineMax({ paused: true });
tlhide.fromTo(menutop, duration, { top: 0 } ,{ top: "-40%", ease: Power3.easeInOut })
.fromTo(menubottom, duration, { bottom: 0 },{ bottom: "-40%", ease: Power3.easeInOut }, '-=' + duration);
menutop.on("click",function(){
console.log("CLICKED MENUTOP");
if(upDown == 0) {
tlhide.restart();
upDown = 1;
}
else {
tlshow.restart();
upDown = 0;
}
});
codepen here: https://codepen.io/giventofly/pen/RxMRMR
on chrome works okay, on firefox the meta-menu-top/bottom are pushed to the left and rearranged to center again.
tried with the webkit/moz prefix and even using normalize.css with no results.
what could be?
Since you use position: absolute for top and bottom menus, you have no need to use display: flex for the parent element. Below is an example of working code (a little simplified).
var metaContainer = document.querySelector('.meta-container');
var menuTop = document.querySelector('.meta-menu-top');
menuTop.onclick = close;
function close() {
metaContainer.classList.toggle('closed');
}
body {
overflow: hidden;
}
.meta-menu {
left: 50%;
transform: translateX(-50%);
}
.meta-menu-bottom,
.meta-menu-top {
height: 48%;
position: absolute;
width: 360px;
transition: 300ms;
}
.meta-menu-top {
align-items: center;
background: #252422;
color: #959595;
display: flex;
border-radius: 0px 0px 10px 10px;
justify-content: center;
opacity: 0.7;
text-align: center;
top: 0;
}
.meta-menu-top ul {
padding: 0;
margin-bottom: 30px;
}
.meta-menu-top li {
list-style-type: none;
}
.meta-title {
color: white;
bottom: 10px;
left: 0;
position: absolute;
width: 100%;
}
.meta-menu-bottom {
background: #eef1f5;
bottom: 0;
border-radius: 10px 10px 0px 0px;
color: white;
}
.closed .meta-menu-top {
top: -48%;
margin-top: 35px;
}
.closed .meta-menu-bottom {
bottom: -48%;
margin-bottom: 30px;
}
<div id="container" class='container'>
<div class='meta-background'></div>
<section class='meta-container'>
<div class="meta-menu meta-menu-top">
<ul>
<li>testsas</li>
<li>fdadasdasdas</li>
<li>dsdasdsadasdsa</li>
</ul>
<div class="meta-title">WEBSITE</div>
</div>
<div class="meta-menu meta-menu-bottom"></div>
</section>
</div>
It seems that there is a Firefox-specifc bug TweenMax
The way that the elements are centered in your page is by the use of the flex display, which is totally fine. However, Firefox rendering has major issues when the left style being unspecified. This is what causes both animated elements to randomly move.
A simple way to overcome this issue is to specify a left value for your element; i.e. add the css below. Or alternatively, you can avoid the use of display flex, unless it is important for you.
.meta-menu-top {
left: calc(50% - 180px);
}
.meta-menu-bottom {
left: calc(50% - 180px);
}
Here is an updated CodePen

Resources