Update tween progress with Draggable
How do I make an update tween progress with draggable?
A simple example on how to update a tween's progress value with a Draggable instance. All using Greensock Animation Platform.. What is a update tween progress with draggable? How do you make a update tween progress with draggable? This script and codes were developed by Rodrigo Hernando on 18 November 2022, Friday.
Update tween progress with Draggable - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Update tween progress with Draggable</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h2>Drag the blue square in order to change the green square's Tween progress</h2>
<div id="drag-wrapper"> <div class="drag-border"> <div id="drag-container"> <div class="drag-bar"></div> <div class="drag-elem"></div> </div> </div>
</div>
<div id="div1"></div>
<div id="log-div">Tween current progress: <span></span></div>
<div id="footer">
For more information visit <a href="https://www.greensock.com/draggable/" target="_blank">Greensock.com/Draggable</a>
</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.19.1/TweenMax.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.1/utils/Draggable.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Update tween progress with Draggable - Script Codes CSS Codes
body
{ background:#000; margin:0; color:#fff; font:18px bold; font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
}
h2
{ text-align:center;
}
#drag-wrapper
{ text-align:center; margin-top:20px;
}
.drag-border
{ border:solid 1px #fff; width:450px; border-radius:5px; overflow:hidden; position:relative; left:50%; margin-left:-225px;
}
#drag-container
{ width:450px; background:#eee;
}
.drag-elem
{ position:relative; background:#00f; height:20px; width:20px; z-index:10; border-radius:5px;
}
.drag-bar
{ height:20px; background:#f0f; width:0; position:absolute; z-index:5; border-radius:5px;
}
#div1
{ width:100px; height:100px; position:relative; background:green; border:solid 1px; border-radius:10px; margin:20px;
}
#footer
{ position:absolute; bottom:20px; right:20px; text-align:right;
}
a
{ color:#71b200; text-decoration:none; font-weight:bold;
}
a:hover
{ text-decoration:underline;
}
Update tween progress with Draggable - Script Codes JS Codes
var div1 = $("#div1"), dragBar = $(".drag-bar"), dragElem = $(".drag-elem"), dragContainer = $("#drag-container"), dragLimit = dragContainer.width() - dragElem.width(), logDiv = $("#log-div span"), tn = TweenLite.to(div1, 1, {left:300, rotation:360, paused:true, ease:Linear.easeNone, onUpdate:upFn}), tnProgress;
Draggable.create(dragElem, { type:'x', bounds:dragContainer, edgeResistance:1, onDrag:function() { tnProgress = ( Math.round( (this.x / dragLimit) * 1000) ) /1000; logDiv.html(tnProgress); tn.progress(tnProgress); TweenLite.set(dragBar, {width:this.x + 10}); }, onPress:function() { tn.pause(); }
});
function upFn() { var xPos = tn.progress() * dragLimit; tnProgress = ( Math.round( tn.progress() * 1000) ) /1000; logDiv.html(tnProgress); TweenLite.set(dragElem, {x:xPos}); TweenLite.set(dragBar, {width:xPos+10});
}
div1.click(function() { tn.play();
});
Developer | Rodrigo Hernando |
Username | rhernando |
Uploaded | November 18, 2022 |
Rating | 3.5 |
Size | 2,695 Kb |
Views | 44,528 |
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 |
Greensock Bezier Morph | 2,463 Kb |
GSAP Scramble Text Plugin | 2,521 Kb |
Circular Bezier | 2,696 Kb |
Transform Orign | 2,051 Kb |
Greensock Draggable latest update | 2,971 Kb |
Greensock 3D Preloader Spinner | 2,373 Kb |
Toggle Tween Direction | 2,325 Kb |
Simple Slider Powered by GreenSock | 4,573 Kb |
Draggable add element | 2,378 Kb |
Spinning Images | 2,279 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 |
Button Option Group | Honchoman | 1,859 Kb |
Heatmap Color Scales | Stevepepple | 2,331 Kb |
Draggable directive | YahyaKacem | 2,277 Kb |
Collapsing Widget | Er40 | 4,279 Kb |
Responsive Table-less Shopping Cart | Alex_rodrigues | 6,637 Kb |
Twitch API | Coderpilot | 3,412 Kb |
Calendar | Miroot | 2,033 Kb |
Modal Dialog | Gigaleet | 2,251 Kb |
Slide out Menu | Rbiggs | 4,936 Kb |
Greyscale image with filter in CSS3 | NickyCDK | 1,562 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!