uses the next as a template<html lang="en"><head> <meta charset="UTF-8"> <link…
- User
uses the next as a template
<link rel="apple-touch-icon" type="image/png" href="https://cpwebassets.codepen.io/assets/favicon/apple-touch-icon-5ae1a0698dcc2402e9712f7d01ed509a57814f994c660df9f7a952f3060705ee.png"> <meta name="apple-mobile-web-app-title" content="CodePen"> <link rel="shortcut icon" type="image/x-icon" href="https://cpwebassets.codepen.io/assets/favicon/favicon-aec34940fbc1a6e787974dcd360f2c6b63348d4b1f4e06c77743096d55480f33.ico"> <link rel="mask-icon" type="image/x-icon" href="https://cpwebassets.codepen.io/assets/favicon/logo-pin-b4b4269c16397ad2f0f7a01bcdf513a1994f4c94b8af2f191c09eb0d601762b1.svg" color="#111"> <script src="https://cpwebassets.codepen.io/assets/common/stopExecutionOnTimeout-2c7831bb44f98c1391d6a4ffda0e1fd302503391ca806e7fcc7b9b87197aec26.js"></script><link rel="canonical" href="https://codepen.io/khesehang-samsohang/pen/VwJqMdW"><script id="rendered-js">document.addEventListener('DOMContentLoaded', function () { // Variables var windowWidth = window.innerWidth; var windowHeight = window.innerHeight; var header = document.querySelector('header'); var wrap = document.querySelector('#wrap'); var cubes = document.querySelectorAll('.cube'); var headerLinks = document.querySelectorAll('header nav li a');
// header anchor tags function headerAnchors() { var pageDirection = ''; var timeout;
headerLinks.forEach(function (link) { link.addEventListener('click', function (event) { event.preventDefault(); // Remove previous direction class cubes.forEach(function (cube) { cube.classList.remove('reverse-' + pageDirection); }); // Set new direction pageDirection = link.dataset.direction; var reverseDirection = link.dataset.reverseDirection; // Update classes link.parentElement.classList.add('active'); header.querySelectorAll('nav li').forEach(function (li) { if (li !== link.parentElement) { li.classList.remove('active'); } }); cubes.forEach(function (cube) { cube.classList.add('reverse-' + pageDirection); }); header.classList.add('go-out'); wrap.classList.add('active'); // Reset classes after timeout clearTimeout(timeout); timeout = setTimeout(function () { header.classList.remove('go-out'); wrap.classList.remove('active'); }, 1000); }); });}
headerAnchors();
window.addEventListener('resize', function () { // Update window dimensions windowWidth = window.innerWidth; windowHeight = window.innerHeight; // Perform additional functions if needed }); }); //# sourceURL=pen.js
- Assistant
Certainly! I'd be happy to help you with this template. Could you please specify how you'd like to use it or what assistance you need? Whether you want to understand how it works, modify it for your project, or troubleshoot any issues, let me know so I can provide the appropriate guidance.