PK T # hamburger-menu-animations/README.mdUT b# Hamburger Menu Animations
A Pen created on CodePen.io. Original URL: [https://codepen.io/Zaku/pen/ejLNJL](https://codepen.io/Zaku/pen/ejLNJL).
Four different menu animations for menu button toggle between hamburger, cross and back icon.
Prefer Dots?
Go this way: https://codepen.io/Zaku/details/YjRqzB/
Additional Source: https://github.com/tamino-martinius/ui-snippets-menu-animationsPKA+ PK T % hamburger-menu-animations/LICENSE.txtUT bThe MIT License (MIT)
Copyright (c) 2022 by Tamino Martinius (https://codepen.io/Zaku/pen/ejLNJL)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.PK0b b PK T ( hamburger-menu-animations/src/index.htmlUT b
Debug
PKO&;5" " PK T + hamburger-menu-animations/src/style.postcssUT b@use postcss-nested;
html,
body {
width: 100vw;
height: 100vh;
padding: 0;
margin: 0;
background-color: #121314;
}
input {
display: none;
}
.grid {
display: grid;
grid-template-rows: 1fr 1fr;
grid-template-columns: 1fr 1fr;
width: 100vw;
height: 100vh;
position: absolute;
}
.grid>* {
position: relative;
}
label {
display: block;
cursor: pointer;
position: absolute;
width: 50vw;
height: 50vw;
max-width: 150px;
max-height: 150px;
}
@media (min-aspect-ratio: 1/1) {
label {
width: 50vh;
height: 50vh;
}
}
.menu--1 label,
.menu--2 label {
bottom: 0;
}
.menu--3 label,
.menu--4 label {
top: 0;
}
.menu--1 label,
.menu--3 label {
right: 0;
}
.menu--2 label,
.menu--4 label {
left: 0;
}
path {
fill: none;
stroke: #ffffff;
stroke-width: 3;
stroke-linecap: round;
stroke-linejoin: round;
--length: 24;
--offset: -38;
stroke-dasharray: var(--length) var(--total-length);
stroke-dashoffset: var(--offset);
transition: all .8s cubic-bezier(.645, .045, .355, 1);
}
circle {
fill: #fff3;
opacity: 0;
}
label:hover circle {
opacity: 1;
}
.cross input:checked+svg {
.line--1,
.line--3 {
--length: 22.627416998;
}
.line--2 {
--length: 0;
}
}
.back input:checked+svg {
.line--1,
.line--3 {
--length: 8.602325267;
}
}
.menu--1 {
background-color: #3f77e9;
.line--1,
.line--3 {
--total-length: 126.64183044433594;
}
.line--2 {
--total-length: 70;
}
input:checked+svg {
.line--1,
.line--3 {
--offset: -94.1149185097;
}
.line--2 {
--offset: -50;
}
}
}
.menu--2 {
background-color: #0095f9;
.line--1,
.line--3 {
--total-length: 111.22813415527344;
--offset: -50.22813415527344;
}
.line--2 {
--total-length: 99;
}
input:checked+svg {
path {
transform: translateX(30px);
}
.line--1,
.line--3 {
--offset: -16.9705627485;
}
.line--2 {
--offset: -20;
}
}
}
.menu--3 {
background-color: #00aef6;
.line--1,
.line--3 {
--total-length: 126.38166809082031;
}
.line--2 {
--total-length: 80;
}
input:checked+svg {
.line--1,
.line--3 {
--offset: -109.1770175568;
}
}
}
.menu--4 {
background-color: #18bee5;
.line--1,
.line--3 {
--total-length: 103.35061645507812;
--offset: -42.35061645507812;
}
.line--2 {
--total-length: 99;
}
input:checked+svg {
path {
transform: translateX(31px);
}
.line--1,
.line--3 {
--offset: -8.602325267;
}
.line--2 {
--offset: -7;
}
}
}
.debug {
display: none;
}
.line--debug {
opacity: 0;
stroke-dasharray: none;
}
@media screen and (min-width: 800px) {
.debug {
opacity: 0.8;
display: block;
position: absolute;
z-index: 1;
font-family: sans-serif;
transform: rotate(-45deg);
transform-origin: 0% 100%;
background: #000;
color: #fff;
width: 150px;
height: 100px;
line-height: 150px;
text-align: center;
user-select: none;
&:hover {
opacity: 1;
}
&.active {
background: #fff;
color: #000;
}
}
.debug.active+.grid path.line--debug {
opacity: .2;
}
}
/* dribbble - twitter */
.dribbble {
position: fixed;
display: block;
right: 20px;
bottom: 20px;
img {
display: block;
height: 28px;
}
}
.twitter {
position: fixed;
display: block;
right: 64px;
bottom: 14px;
svg {
width: 32px;
height: 32px;
path {
fill: #1da1f2;
stroke: none;
}
}
}
PK] PK T / hamburger-menu-animations/src/script.typescriptUT bArray.from(document.getElementsByTagName('path')).map(path => {
console.log(path.getTotalLength());
const debugPath = path.cloneNode();
debugPath.classList.add('line--debug');
if (path.parentNode) path.parentNode.insertBefore(debugPath.cloneNode(), path);
});
const debugCheckbox = document.getElementById('debug');
debugCheckbox.addEventListener('change', () => {
if (debugCheckbox.checked) {
debugCheckbox.parentElement.classList.add('active');
} else {
debugCheckbox.parentElement.classList.remove('active');
}
});
let currentActive = 0;
const checkboxes = document.querySelectorAll('.grid input');
const autoShow = setInterval(() => {
checkboxes[currentActive % 4].checked = !checkboxes[currentActive % 4].checked;
if (!checkboxes[currentActive % 4].checked) currentActive += 1;
}, 1000);
document.querySelector('.grid').addEventListener('click', () => {
clearInterval(autoShow);
})PK' PK T ) hamburger-menu-animations/dist/index.htmlUT b
CodePen - Hamburger Menu Animations
Debug
PKD D PK T ( hamburger-menu-animations/dist/style.cssUT bhtml,
body {
width: 100vw;
height: 100vh;
padding: 0;
margin: 0;
background-color: #121314;
}
input {
display: none;
}
.grid {
display: grid;
grid-template-rows: 1fr 1fr;
grid-template-columns: 1fr 1fr;
width: 100vw;
height: 100vh;
position: absolute;
}
.grid>* {
position: relative;
}
label {
display: block;
cursor: pointer;
position: absolute;
width: 50vw;
height: 50vw;
max-width: 150px;
max-height: 150px;
}
@media (min-aspect-ratio: 1/1) {
label {
width: 50vh;
height: 50vh;
}
}
.menu--1 label,
.menu--2 label {
bottom: 0;
}
.menu--3 label,
.menu--4 label {
top: 0;
}
.menu--1 label,
.menu--3 label {
right: 0;
}
.menu--2 label,
.menu--4 label {
left: 0;
}
path {
fill: none;
stroke: #ffffff;
stroke-width: 3;
stroke-linecap: round;
stroke-linejoin: round;
--length: 24;
--offset: -38;
stroke-dasharray: var(--length) var(--total-length);
stroke-dashoffset: var(--offset);
transition: all .8s cubic-bezier(.645, .045, .355, 1);
}
circle {
fill: #fff3;
opacity: 0;
}
label:hover circle {
opacity: 1;
}
.cross input:checked+svg .line--1,
.cross input:checked+svg .line--3 {
--length: 22.627416998;
}
.cross input:checked+svg .line--2 {
--length: 0;
}
.back input:checked+svg .line--1,
.back input:checked+svg .line--3 {
--length: 8.602325267;
}
.menu--1 {
background-color: #3f77e9;
}
.menu--1 .line--1,
.menu--1 .line--3 {
--total-length: 126.64183044433594;
}
.menu--1 .line--2 {
--total-length: 70;
}
.menu--1 input:checked+svg .line--1,
.menu--1 input:checked+svg .line--3 {
--offset: -94.1149185097;
}
.menu--1 input:checked+svg .line--2 {
--offset: -50;
}
.menu--2 {
background-color: #0095f9;
}
.menu--2 .line--1,
.menu--2 .line--3 {
--total-length: 111.22813415527344;
--offset: -50.22813415527344;
}
.menu--2 .line--2 {
--total-length: 99;
}
.menu--2 input:checked+svg path {
transform: translateX(30px);
}
.menu--2 input:checked+svg .line--1,
.menu--2 input:checked+svg .line--3 {
--offset: -16.9705627485;
}
.menu--2 input:checked+svg .line--2 {
--offset: -20;
}
.menu--3 {
background-color: #00aef6;
}
.menu--3 .line--1,
.menu--3 .line--3 {
--total-length: 126.38166809082031;
}
.menu--3 .line--2 {
--total-length: 80;
}
.menu--3 input:checked+svg .line--1,
.menu--3 input:checked+svg .line--3 {
--offset: -109.1770175568;
}
.menu--4 {
background-color: #18bee5;
}
.menu--4 .line--1,
.menu--4 .line--3 {
--total-length: 103.35061645507812;
--offset: -42.35061645507812;
}
.menu--4 .line--2 {
--total-length: 99;
}
.menu--4 input:checked+svg path {
transform: translateX(31px);
}
.menu--4 input:checked+svg .line--1,
.menu--4 input:checked+svg .line--3 {
--offset: -8.602325267;
}
.menu--4 input:checked+svg .line--2 {
--offset: -7;
}
.debug {
display: none;
}
.line--debug {
opacity: 0;
stroke-dasharray: none;
}
@media screen and (min-width: 800px) {
.debug {
opacity: 0.8;
display: block;
position: absolute;
z-index: 1;
font-family: sans-serif;
transform: rotate(-45deg);
transform-origin: 0% 100%;
background: #000;
color: #fff;
width: 150px;
height: 100px;
line-height: 150px;
text-align: center;
user-select: none;
}
.debug:hover {
opacity: 1;
}
.debug.active {
background: #fff;
color: #000;
}
.debug.active+.grid path.line--debug {
opacity: .2;
}
}
/* dribbble - twitter */
.dribbble {
position: fixed;
display: block;
right: 20px;
bottom: 20px;
}
.dribbble img {
display: block;
height: 28px;
}
.twitter {
position: fixed;
display: block;
right: 64px;
bottom: 14px;
}
.twitter svg {
width: 32px;
height: 32px;
}
.twitter svg path {
fill: #1da1f2;
stroke: none;
}PKK PK T ( hamburger-menu-animations/dist/script.jsUT b"use strict";
Array.from(document.getElementsByTagName('path')).map(path => {
console.log(path.getTotalLength());
const debugPath = path.cloneNode();
debugPath.classList.add('line--debug');
if (path.parentNode)
path.parentNode.insertBefore(debugPath.cloneNode(), path);
});
const debugCheckbox = document.getElementById('debug');
debugCheckbox.addEventListener('change', () => {
if (debugCheckbox.checked) {
debugCheckbox.parentElement.classList.add('active');
}
else {
debugCheckbox.parentElement.classList.remove('active');
}
});
let currentActive = 0;
const checkboxes = document.querySelectorAll('.grid input');
const autoShow = setInterval(() => {
checkboxes[currentActive % 4].checked = !checkboxes[currentActive % 4].checked;
if (!checkboxes[currentActive % 4].checked)
currentActive += 1;
}, 1000);
document.querySelector('.grid').addEventListener('click', () => {
clearInterval(autoShow);
});PKIլ PK TA+ # hamburger-menu-animations/README.mdUT bPK T0b b % hamburger-menu-animations/LICENSE.txtUT bPK TO&;5" " ( hamburger-menu-animations/src/index.htmlUT bPK T] + hamburger-menu-animations/src/style.postcssUT bPK T' / hamburger-menu-animations/src/script.typescriptUT bPK TD D ) |$ hamburger-menu-animations/dist/index.htmlUT bPK TK ( 1 hamburger-menu-animations/dist/style.cssUT bPK TIլ (
A hamburger-menu-animations/dist/script.jsUT bPK :E