Created
July 19, 2017 19:11
-
-
Save DestinyLuong/9228b7df3baa75094df2bab9f785d2b5 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=9228b7df3baa75094df2bab9f785d2b5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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"> | |
<div id="ground"></div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"enabledLibraries":["jquery"]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//sets element to the variable $pic | |
var $pic = $("#pic"); | |
$pic.click(function(){ | |
//Your code goes here | |
var picTop = $pic.offset().top; | |
var picBottom = picTop + $pic.height(); | |
var groundTop = $("#ground").offset().top; | |
var interval = setInterval(function(){ | |
$pic.css("top",$pic.offset().top + 10); | |
if(picBottom > groundTop){ | |
clearInterval(interval); | |
} | |
} , 1000); | |
}); | |
//("#pic").click(function(){ | |
// //Your code goes here | |
//var picTop = ("#pic").offset().top; | |
//var picBottom = picTop + ("#pic").width(); | |
//var groundTop = ("pic").offset().top; | |
//var interval = setInterval(function(){("pic").css("top",("pic").offset().top + 10);} , 1000); | |
//if(picBottom > groundTop){ | |
//clearInterval(interval); | |
//} | |
//}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pic { | |
position: absolute; | |
width: 50px; | |
width: 60px; | |
left: 50%; | |
top: 5%; | |
} | |
#ground { | |
position: absolute; | |
background-color: black; | |
width: 100%; | |
height: 20px; | |
top: 95%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment