Skip to content

Instantly share code, notes, and snippets.

@RCTumolac
Created March 20, 2017 22:46
Show Gist options
  • Save RCTumolac/17059cd3270de6be4c6c534c0b409213 to your computer and use it in GitHub Desktop.
Save RCTumolac/17059cd3270de6be4c6c534c0b409213 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=17059cd3270de6be4c6c534c0b409213
<!DOCTYPE html>
<html>
<head>
<title>Gravity Starter Code</title>
</head>
<body>
<img id="pic" src="https://s-media-cache-ak0.pinimg.com/236x/24/2d/2e/242d2e2f40995f6f6ef2cd10a245c196.jpg">
<img id = "pic2" src = "https://img.clipartfest.com/5493ad092ec7af34540a4fa5562d3543_bomb-clip-art-images-free-for-atomic-bomb-clip-art_664-800.png">
<div id="ground"></div>
</body>
</html>
{"enabledLibraries":["jquery"]}
//sets element to the variable $pic
var $pic = $("#pic");
var $ground = $("#ground");
var $pic2 = $("#pic2");
$pic2.hide();
$pic.click(function(){
//Your code goes here
setInterval(function(){
if($pic.offset().top <= $ground.offset().top){
$pic.css("top", $("#pic").offset().top + 10);
}
else{
$pic.hide();
$pic2.show();
}
}, 10);
});
#pic {
position: absolute;
width: 50px;
width: 60px;
left: 50%;
top: 5%;
}
#ground {
position: absolute;
background-color: black;
width: 100%;
height: 20px;
top: 95%;
}
#pic2{
position: absolute;
left: 35%;
top: 11%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment