Skip to content

Instantly share code, notes, and snippets.

@seangenabe
Created October 21, 2014 11:43
Show Gist options
  • Save seangenabe/218211abd2d8abc27395 to your computer and use it in GitHub Desktop.
Save seangenabe/218211abd2d8abc27395 to your computer and use it in GitHub Desktop.
draw a div for debugging purposes
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