Before/After viewer with Draggable and TweenMax
How do I make an before/after viewer with draggable and tweenmax?
Just this effect - before and after using TweenMax and DraggableImages copyrighted to Ivaylo Yovchev Photography. What is a before/after viewer with draggable and tweenmax? How do you make a before/after viewer with draggable and tweenmax? This script and codes were developed by Chrysto on 16 July 2022, Saturday.
Before/After viewer with Draggable and TweenMax - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Before/After viewer with Draggable and TweenMax</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <!-- Adding TweenMax (or TweenLite+CSSPLugin) and Draggable -->
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/utils/Draggable.min.js"></script>
<!-- The actual markup -->
<ul id="controls"> <li class="to-start">Before</li> <li class="to-middle">Compare</li> <li class="to-end">After</li>
</ul>
<div id="before-after"> <div class="view view-after"><img src="http://cloud.bassta.bg/img-after.jpg" /></div> <div class="view view-before"><img src="http://cloud.bassta.bg/img-before.jpg" /></div> <div id="dragme"></div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Before/After viewer with Draggable and TweenMax - Script Codes CSS Codes
body, div, p{ margin: 0; padding: 0; font-family: Helvetica, sans-serif;
} #before-after{ position: relative; width: 600px; height: 500px; border: 2px solid grey; margin: 50px auto 0px;; } .view{ position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; overflow: hidden; } .view-before{ z-index: 100; } .view-after{ z-index: 200; } #dragme{ position: absolute; width: 5px; height: 100%; top: 0px; left: 0px; background-color: black; cursor: pointer; z-index: 300; } /* Controls */ ul{ text-align: center; margin-top: 50px; } ul li{ list-style: none; display: inline-block; font-size: 17px; cursor: pointer; margin: 0px 20px 0px 20px }
Before/After viewer with Draggable and TweenMax - Script Codes JS Codes
$(function(){ /* Dependencies : TweenMax and Draggable Images by Ivaylo Yovchev ( http://www.ivayloyovchev.com/ ) Test on touch device @ http://cloud.bassta.bg/before-after.html */ var $dragMe = $("#dragme"); var $beforeAfter = $("#before-after"); var $viewAfter = $(".view-after"); Draggable.create($dragMe, { type:"left", bounds: $beforeAfter, onDrag:updateImages }); function updateImages(){ TweenLite.set($viewAfter, {width: $dragMe.css("left") }); //or this.x if only dragging } //Intro Animation animateTo(350); //Externall nav $(".to-start").on("click", function(){ animateTo(0); }); $(".to-middle").on("click", function(){ animateTo(298); }); $(".to-end").on("click", function(){ animateTo(598); }); function animateTo(_left){ TweenLite.to( $dragMe, 1, {left: _left, onUpdate: updateImages }); } //V2 Click added $beforeAfter.on("click", function(event){ var eventLeft = event.clientX - $beforeAfter.offset().left; animateTo(eventLeft); });
});//end jQuery wrapper
Developer | Chrysto |
Username | bassta |
Uploaded | July 16, 2022 |
Rating | 4.5 |
Size | 2,738 Kb |
Views | 56,672 |
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 GSAP Slider | 2,839 Kb |
TweenLite staggerTo | 2,495 Kb |
Fullscreen image in Canvas | 2,268 Kb |
Fullscreen Parallax | 3,313 Kb |
Medium.com style header effect | 2,828 Kb |
TweenMax text - changing slogans | 2,333 Kb |
Page Header animation | 2,828 Kb |
One page website scrolling effect | 2,764 Kb |
Fullscreen slides with TweenLite, CSSPlugin and ScrollToPlugin | 4,226 Kb |
Single page website | 2,688 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 |
Page Transitions in Backbone | Mikefowler | 3,691 Kb |
Angular-HAML | Cwacht | 2,022 Kb |
Hello People | Danburrows | 2,365 Kb |
Buttons with style | Chbymnky | 2,082 Kb |
Particle Motion trajectories | Sniejadlik | 5,899 Kb |
Z-index demo | Kblh | 1,534 Kb |
Video Player Custom Controls | EleftheriaBatsou | 3,665 Kb |
Calculator - codevember 08 - 2016 | Caiocares | 3,260 Kb |
To Do List with Delete | Mattlbrody | 2,068 Kb |
Mini Profile | Frytyler | 3,828 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!