Last active
June 19, 2018 13:35
-
-
Save onebytegone/178b34a5cb8f10ff5a4811e4d42e69cc to your computer and use it in GitHub Desktop.
Datadog ScreenBoard Grid Aligner
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
$('.widget').each(function() { | |
var GRID_SIZE = 12, | |
el = $(this), | |
title = el.find('.title_text').text(), | |
roundToGrid; | |
roundToGrid = function(value) { | |
return Math.ceil(value / GRID_SIZE) * GRID_SIZE; | |
}; | |
console.log('%s - BEFORE left: %s, top: %s, width: %s, height: %s', title, el.css('left'), el.css('top'), el.width(), el.height()); | |
el.css('left', roundToGrid(parseInt(el.css('left'), 10)) + 'px'); | |
el.css('top', roundToGrid(parseInt(el.css('top'), 10)) + 'px'); | |
el.height(roundToGrid(el.height())); | |
el.width(roundToGrid(el.width())); | |
console.log('%s - AFTER %s, top: %s, width: %s, height: %s', title, el.css('left'), el.css('top'), el.width(), el.height()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment