Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hibadattebayo/cab3047de4a7ce994080067cab935aa1 to your computer and use it in GitHub Desktop.
Save hibadattebayo/cab3047de4a7ce994080067cab935aa1 to your computer and use it in GitHub Desktop.
GSAP Animate CSS background-position (just clouds)
<div id="clouds"></div>
// window load event makes sure image is // loaded before running animation
$(window).on("load", function() {
var tl = new TimelineMax({repeat:-1});
tl.to("#clouds", 30, {
backgroundPosition: "-2247px 0px",
//autoRound:false,
ease: Linear.easeNone
});
});
<script src="//cdnjs.cloudflare.com/ajax/libs/gsap/1.18.0/TweenMax.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
body{
margin:0;
padding:0;
background:#ACE6FF;
}
#clouds{
background:url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/56901/bg-clouds.png") repeat 0 0 transparent;
width:100%;
height:190px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment