Toggle Tween Direction

Size
2,325 Kb
Views
18,216

How do I make an toggle tween direction?

Simple example of how the direction of a Tween/Timeline can be changed with a unique function.Powered by GreenSock Animation Platform.. What is a toggle tween direction? How do you make a toggle tween direction? This script and codes were developed by Rodrigo Hernando on 18 November 2022, Friday.

Toggle Tween Direction Previews

Toggle Tween Direction - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Toggle Tween Direction</title> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ body
{ background:black; color:white; font: 16px "Trebuchet MS"; margin:0;
}
h2
{ text-align:center;
}
button
{ padding:10px; border-radius:5px; margin:20px;
}
#div1
{ width:100px; height:100px; background:blue; position:relative; margin-left:20px;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <h2>Simple Example to toggle the direction of a Tween/Timeline<br> Powered by GreenSock Animation Platform</h2>
<button id="btn">Toggle Tween Direction</button>
<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/latest/TweenMax.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Toggle Tween Direction - Script Codes CSS Codes

body
{ background:black; color:white; font: 16px "Trebuchet MS"; margin:0;
}
h2
{ text-align:center;
}
button
{ padding:10px; border-radius:5px; margin:20px;
}
#div1
{ width:100px; height:100px; background:blue; position:relative; margin-left:20px;
}

Toggle Tween Direction - Script Codes JS Codes

var div1 = $("#div1"), btn = $("#btn"), t = TweenLite.to(div1, 1.5, { left:300, top:100, rotation:360, ease:Back.easeOut }).reversed(true);
function toggleDirection()
{ t.reversed( !t.reversed() );
}
btn.click(function(){ toggleDirection();
});
Toggle Tween Direction - Script Codes
Toggle Tween Direction - Script Codes
Home Page Home
Developer Rodrigo Hernando
Username rhernando
Uploaded November 18, 2022
Rating 3
Size 2,325 Kb
Views 18,216
Do you need developer help for Toggle Tween Direction?

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!

Rodrigo Hernando (rhernando) Script Codes
Create amazing blog posts with AI!

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!