Created
October 21, 2014 11:43
-
-
Save seangenabe/218211abd2d8abc27395 to your computer and use it in GitHub Desktop.
draw a div for debugging purposes
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
global.drawDiv = function(x, y, color) { | |
var div = document.createElement('div') | |
document.body.appendChild(div) | |
div.style.position = 'absolute' | |
div.style.top = '0px' | |
div.style.left = '0px' | |
div.style.width = x + 'px' | |
div.style.height = y + 'px' | |
div.style.borderWidth = '2px' | |
div.style.borderStyle = 'solid' | |
div.style.borderColor = color || 'white' | |
div.classList.add('drawn') | |
var interact = require('interact') | |
interact(div).draggable({ | |
onmove: function(e) { | |
div.style.left = parseFloat(div.style.left) + e.dx + 'px' | |
div.style.top = parseFloat(div.style.top) + e.dy + 'px' | |
} | |
}) | |
return div | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment