Pausing Transitions
How do I make an pausing transitions?
Pausing CSS transitions using a button with pure javascript and jQuery for a CSS Trick's article. What is a pausing transitions? How do you make a pausing transitions? This script and codes were developed by Zach Saucier on 20 August 2022, Saturday.
Pausing Transitions - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Pausing Transitions</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h3>Pure Javascript</h3>
<div class='box'></div>
<button class='toggleButton' value='play'>Play</button>
<h3>jQuery</h3>
<div class='box'></div>
<button class='toggleButton' value='play'>Play</button> <script src='http://code.jquery.com/jquery-2.0.0.js'></script> <script src="js/index.js"></script>
</body>
</html>
Pausing Transitions - Script Codes CSS Codes
.box { margin: 30px; height: 50px; width: 50px; background-color: blue;
}
.box.horizTranslate { -webkit-transition: 3s; -moz-transition: 3s; -ms-transition: 3s; -o-transition: 3s; transition: 3s; margin-left: 50% !important;
}
Pausing Transitions - Script Codes JS Codes
var boxOne = document.getElementsByClassName('box')[0], $boxTwo = $('.box:eq(1)');
document.getElementsByClassName('toggleButton')[0].onclick = function() { if(this.innerHTML === 'Play') { this.innerHTML = 'Pause'; boxOne.classList.add('horizTranslate'); } else { this.innerHTML = 'Play'; var computedStyle = window.getComputedStyle(boxOne), marginLeft = computedStyle.getPropertyValue('margin-left'); boxOne.style.marginLeft = marginLeft; boxOne.classList.remove('horizTranslate'); }
}
$('.toggleButton:eq(1)').on('click', function() { if($(this).html() === 'Play') { $(this).html('Pause'); $boxTwo.addClass('horizTranslate'); } else { $(this).html('Play'); var computedStyle = $boxTwo.css('margin-left'); $boxTwo.removeClass('horizTranslate'); $boxTwo.css('margin-left', computedStyle); }
});
Developer | Zach Saucier |
Username | Zeaklous |
Uploaded | August 20, 2022 |
Rating | 3.5 |
Size | 2,098 Kb |
Views | 42,504 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Yin-Yang CSS Image Animation | 3,255 Kb |
Simple, flat contact form | 2,719 Kb |
Hipster date intro screen | 5,878 Kb |
Responsive CSS bars | 3,137 Kb |
Simple p5.js music visualizer | 2,479 Kb |
Single element color loader | 2,603 Kb |
Personal site header 2017 | 6,864 Kb |
Asset loading effects demo | 4,936 Kb |
CSS-Only Full Page Slider | 4,161 Kb |
CSS Callback Functions Using Iteration | 2,720 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Experiment | Toddmoy | 2,849 Kb |
A vuejs widget | Chrgl86 | 2,869 Kb |
Typefaces with descriptions | Megandoty | 2,944 Kb |
Michelle, submit your photography to Unsplash. | Zaneriley | 3,368 Kb |
Mesmerizing octopus | Jllodra | 3,549 Kb |
Project -Show the Local Weather | Luciano_Britis | 2,583 Kb |
Filter inputs | Rowinf | 1,721 Kb |
Resize image | Happyhj | 1,892 Kb |
Shape Outside - Polygon | Stacy | 3,954 Kb |
CSSOff 2013 Submission | Codewunder | 14,766 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!