Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fabioluzm/8db0b6e72e52b73d0dc5d5ddb7d1cbac to your computer and use it in GitHub Desktop.
Save fabioluzm/8db0b6e72e52b73d0dc5d5ddb7d1cbac to your computer and use it in GitHub Desktop.
Animação Interativa - CSS Transitions
<div class="trigger">
<div class="box"></div>
</div>
$(".trigger").on("click", function() {
$(this).toggleClass("clicked");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
body {
padding: 50px;
}
.trigger {
width: 200px;
height: 200px;
border: 20px solid #999;
background: #ddd;
}
.box {
display: inline-block;
background: pink;
width: 200px;
height: 200px;
transition: -webkit-transform 300ms cubic-bezier(0, 0.47, 0.32, 1.97);
transition: transform 300ms cubic-bezier(0, 0.47, 0.32, 1.97);
transition: transform 300ms cubic-bezier(0, 0.47, 0.32, 1.97), -webkit-transform 300ms cubic-bezier(0, 0.47, 0.32, 1.97);
pointer-events: none;
}
.trigger.clicked .box {
-webkit-transform: translate(200px, 150px) rotate(20deg);
transform: translate(200px, 150px) rotate(20deg);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment