Here is a link https://www.youtube.com/shorts/MpxWVhlp360 showing a video of the problem. This only happens on mobile browsers and Safari. I have tried to enable hardware rendering by using -webkit-transform: translate3d(0, 0, 0); -moz-transform: translate3d(0, 0, 0); -ms-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); But unfortunately it couln't fix the problem.
Here is the CSS/SCSS code
@import "../../styles/colors.scss";
.burger {
all: unset;
position: fixed;
right: 25px;
top: 25px;
z-index: 8;
width: 40px;
height: 40px;
display: flex;
flex-direction: column;
border-radius: 8px;
border: 1px solid $light-blue;
row-gap: 4px;
align-items: center;
justify-content: center;
cursor: pointer;
span {
width: 20px;
height: 2px;
border-radius: 1px;
background-color: white;
transition: 0.5s;
transform-origin: left center;
}
}
.menu {
z-index: 5;
position: fixed;
width: 326px;
max-width: 326px;
height: 100vh;
background-color: $dark-background;
padding: 77px 30px;
display: flex;
flex-direction: column;
row-gap: 30px;
right: -326px;
top: 0;
.link {
font-style: normal;
font-weight: 400;
font-size: 20px;
color: #ffffff;
opacity: 0.37;
position: relative;
transition: 0.5s;
&:hover {
color: $light-blue;
opacity: 1;
}
}
}
.open {
row-gap: 5.07px;
span:nth-child(1) {
animation: open1 500ms linear forwards;
}
span:nth-child(2) {
animation: open2 500ms linear forwards;
}
span:nth-child(3) {
animation: open3 500ms linear forwards;
}
}
.close {
span {
row-gap: 4px;
}
span:nth-child(1) {
animation: close1 500ms linear forwards;
}
span:nth-child(2) {
animation: close2 500ms linear forwards;
}
span:nth-child(3) {
animation: close3 500ms linear forwards;
}
}
.slide {
animation: slide 500ms linear forwards;
}
.slide_back {
animation: slide-back 500ms linear forwards;
}
@keyframes open1 {
to {
transform: translateX(2.93px) rotate(45deg);
background-color: $light-blue;
}
}
@keyframes open2 {
to {
opacity: 0;
}
}
@keyframes open3 {
to {
transform: translateX(2.93px) rotate(315deg);
background-color: $light-blue;
}
}
@keyframes close1 {
from {
transform: translateX(2.93px) rotate(45deg);
background-color: $light-blue;
}
to {
transform: none;
background-color: #ffffff;
}
}
@keyframes close2 {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes close3 {
from {
transform: translateX(2.93px) rotate(315deg);
background-color: $light-blue;
}
to {
transform: none;
background-color: white;
}
}
@keyframes slide {
to {
right: 0px;
}
}
@keyframes slide-back {
from {
right: 0;
}
to {
right: -326px;
}
}
Here is the react jsx/html to go with the css:
import React, { useState } from "react";
import DownloadButton from "../download-button/DownloadButton";
import styles from "./burger-menu-styles.module.scss";
import classNames from "classnames";
export default function BurgerMenu() {
const [isMounted, setIsMounted] = useState(false);
const [burgerMenuActive, setBurgerMenuActive] = useState(false);
const activateBurgerMenu = () => {
if (!isMounted) {
setIsMounted(true);
setBurgerMenuActive(!burgerMenuActive);
} else setBurgerMenuActive(!burgerMenuActive);
};
const burgerClasses = classNames({
[styles.burger]: true,
[styles.open]: burgerMenuActive,
[styles.close]: !burgerMenuActive && isMounted,
});
const menuClasses = classNames({
[styles.menu]: true,
[styles.slide]: burgerMenuActive,
[styles.slide_back]: !burgerMenuActive && isMounted,
});
return (
<div className="relative">
<div className={menuClasses}>
<a href="#about" onClick={activateBurgerMenu} className={styles.link}>
About
</a>
<a
href="#services"
onClick={activateBurgerMenu}
className={styles.link}
>
Experience
</a>
<a href="#work" onClick={activateBurgerMenu} className={styles.link}>
Work
</a>
<a href="#contact" onClick={activateBurgerMenu} className={styles.link}>
Contact Me
</a>
<DownloadButton href="/assets/batetambe_tanyi.pdf">
Resume
</DownloadButton>
</div>
<button className={burgerClasses} onClick={activateBurgerMenu}>
<span></span>
<span></span>
<span></span>
</button>
</div>
);
}