Created
August 18, 2013 13:06
-
-
Save wanghailei/6261563 to your computer and use it in GitHub Desktop.
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
goog.provide('app'); | |
goog.require('goog.dom'); | |
goog.require('goog.style'); | |
goog.require('goog.array'); | |
app.plateSections = function() { | |
var plateWidth = 0; | |
// Add the first section's width. | |
goog.style.getSize( goog.dom.getFirstElementChild( goog.dom.getElement('plate') ) ).width ; | |
// Position each of the sections horizontally one after another starting from the first child of plate. | |
goog.array.forEach( goog.dom.getChildren( goog.dom.getElement('plate') ), function(section) { | |
goog.style.setPosition( goog.dom.getNextElementSibling(section), goog.style.getPosition(section).x + goog.style.getSize(section).width ); | |
// Accumulate the width of each section after the first section. | |
plateWidth += goog.style.getSize(section).width; | |
}); | |
// Get the should-be width of the plate element. | |
goog.style.setSize(goog.dom.getElement('plate'), plateWidth); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment