Сообщение от Alexodiy
|
И все же, можно ли как нибудь переписать этот скрипт под ванильный js
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body{
transition: 2s;
opacity: 0;
}
</style>
</head>
<body>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Expedita magni quos perferendis aperiam sunt perspiciatis, excepturi, minus nam natus tenetur fugiat libero sint voluptates hic, cumque repudiandae rerum corporis quas. Alias dolore rem suscipit molestias non soluta culpa quam consequuntur vero. Explicabo odit reprehenderit omnis consequatur rerum ratione, ipsum aut quas, harum quae modi, blanditiis culpa in repellendus esse eum laudantium commodi nihil maxime temporibus amet. Tempore aut, doloribus aspernatur eos debitis, obcaecati, veniam labore placeat quidem quo facilis vero, explicabo possimus autem! Id dicta odio officiis quia placeat unde totam vel amet iste maiores soluta facere, eaque vero excepturi, minus, accusantium ipsa nemo ad! Dicta labore voluptate amet, rem quibusdam aspernatur fugiat nisi corporis molestiae ad consequuntur, soluta minima nobis nulla perferendis possimus dolorem!
<a href="#" class="transition">ссылка</a>
<script>
window.onload = function(){
document.body.style.opacity = 1;
};
document.addEventListener("DOMContentLoaded", function(){
[].forEach.call(document.querySelectorAll("a.transition"), function(el){
el.onclick = function(event){
event.preventDefault();
linkLocation = this.href;
document.body.style.transition = '1s';
document.body.style.opacity = 0;
setTimeout(redirectPage,1000);
};
});
function redirectPage() {
window.location = linkLocation;
}
});
</script>
</body>
</html>