Z Index Tween
How do I make an z index tween?
Setting z-index property of a relative positioned element and then tween some css properties besides z-index. What is a z index tween? How do you make a z index tween? This script and codes were developed by Rodrigo Hernando on 18 November 2022, Friday.
Z Index Tween - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Z Index Tween</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="css/style.css">
</head>
<body> <button id="btn1">Tween</button>
<div id="log1">On start the element's z-index is: <span></span></div>
<div id="log2">The element's current z-index is: <span></span></div>
<div id="log3">On complete the element's z index is: <span></span></div>
<div id="div1"></div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/1.9.3/TweenMax.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Z Index Tween - Script Codes CSS Codes
#div1{ position:relative; width:150px; height:150px; background:#00f; margin-top:10px;
}
#log1, #log2, #log3{ width:300px; height:30px; line-height:30px; padding:10px; border:solid 1px #000; background:#E9E9E9; margin-top:10px;
}
Z Index Tween - Script Codes JS Codes
$(document).ready(function(){
var div1 = $("div#div1"), log1 = $("div#log1"), log2 = $("div#log2"), log3 = $("div#log3"), btn1 = $("button#btn1"), tn1 = new TweenMax.to(div1, 2, {top:200, left:300, rotation:360, zIndex:20, paused:true, onStart:tn1Start, onUpdate:tn1Update, onComplete:tn1Complete});
TweenMax.set(div1, {zIndex:50})
function tn1Start()
{ log1.children().html(div1.css('z-index'));
}
function tn1Update()
{ log2.children().html(div1.css('z-index'));
}
function tn1Complete()
{ log3.children().html(div1.css('z-index'));
}
btn1.click(function()
{ log1.children().html(''); log2.children().html(''); log3.children().html(''); tn1.play(0);
});
});
Developer | Rodrigo Hernando |
Username | rhernando |
Uploaded | November 18, 2022 |
Rating | 3 |
Size | 2,138 Kb |
Views | 22,264 |
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 |
Simple Slider Powered by GreenSock | 4,573 Kb |
Circular Bezier | 2,696 Kb |
Circular Progress Bar | 4,985 Kb |
Simple Drop Down Menu | 3,342 Kb |
GSAP Scramble Text Plugin | 2,521 Kb |
Toggle Tween Direction | 2,325 Kb |
Auto scroll to element offset | 2,549 Kb |
Greensock Bezier Morph | 2,463 Kb |
Animate SVG Gradient | 2,239 Kb |
Bezier Animation with straight paths | 2,087 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 |
Material design buttons | Fischaela | 4,381 Kb |
Free css icon set v2 - one div | Ben_jammin | 0 Kb |
Two Element Typeface | Chrisota | 4,942 Kb |
JQuery exercise | Brian-baum | 3,780 Kb |
Emberjs Bootstrap Modal Carousel | Somethingkindawierd | 4,233 Kb |
A Pen by Theun | Tjoen | 6,152 Kb |
Weather App | Kw7oe | 3,162 Kb |
JQuery AJAX reddit Exercise | Btholt | 1,777 Kb |
SVG Animation | Thepheer | 4,793 Kb |
Growing Root - Scroll control - CANVAS | Cjonasw | 2,342 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!