Created
January 3, 2016 20:06
-
-
Save MikeDigitize/ad352d8281f943f98367 to your computer and use it in GitHub Desktop.
Some coding challenges for the AO front end team who are learning JavaScript
This file contains 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
/* | |
style: | |
.marker { | |
background-color: #5F5FFF; | |
width: 7px; | |
height: 7px; | |
border-radius: 50%; | |
position: absolute; | |
box-shadow: 2px 2px 5px rgba(0,0,0,0.5); | |
} | |
*/ | |
function marker(x,y) { | |
var m = new Marker(); | |
m.className = "marker"; | |
m.style.left = x + "px"; | |
m.style.top = y + "px"; | |
return m; | |
} | |
function draw(e) { | |
e.preventDefault(); | |
document.body.appendChild(marker(e.clientX, e.clientY)); | |
} | |
var Marker = document.registerElement("my-marker"); | |
document.addEventListener("mousedown", function() { | |
document.addEventListener("mousemove", draw); | |
}); | |
document.addEventListener("mouseup", function() { | |
document.removeEventListener("mousemove", draw); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment