function centerElement(element, totalWidth, totalHeight) {
  if (totalWidth)
    element.style.left = (totalWidth - element.offsetWidth) / 2 + 'px';
  if (totalHeight)
    element.style.top = (totalHeight - element.offsetHeight) / 2 + 'px';
}
/**
 * Helper function to center the element.
 * @param {Object} element The element to be centered.
 * @param {number} totalWidth The total width. An empty value disables centering
 *     horizontally.
 * @param {number} totalHeight The total height. An empty value disables
 *     centering vertically.
 */
Helper function to center the element.
@param {Object} element The element to be centered.
@param {number} totalWidth The total width. An empty value disables centering
horizontally.
@param {number} totalHeight The total height. An empty value disables
centering vertically.
Helper function to center the element . @param { Object } element The element to be centered . @param { number } totalWidth The total width . An empty value disables centering horizontally . @param { number } totalHeight The total height . An empty value disables centering vertically .
function centerElement(element, totalWidth, totalHeight) {
  if (totalWidth)
    element.style.left = (totalWidth - element.offsetWidth) / 2 + 'px';
  if (totalHeight)
    element.style.top = (totalHeight - element.offsetHeight) / 2 + 'px';
}
function centerElement ( element , totalWidth , totalHeight ) { if ( totalWidth ) element . style . left = ( totalWidth - element . offsetWidth ) / 2 + 'px' ; if ( totalHeight ) element . style . top = ( totalHeight - element . offsetHeight ) / 2 + 'px' ; }
Helper function to center the element.
Helper function to center the element .