dist/bbn.js
/**
     * Centers the given element by giving it a position absolute.
     * 
     * @method   center
     * @global   
     * @example 
     * ```javascript
     * //<div style="position: absolute; top: 73px; left: 0px;">Documentation</div>
     * bbn.fn.center('<div>Documentation</div>')
     * ```
     * @memberof bbn.fn
     * @param    {HTMLElement} ele 
     * @returns  {HTMLElement} The dom element with the new style.             
     */
Centers the given element by giving it a position absolute.


Centers the given element by giving it a position absolute .
center(ele){
      let parent = ele.parentNode,
          w = parent.clientWidth,
          h = parent.clientHeight;
      while ( parent && (!w || !h) ){
        parent = ele.parentNode;        
        w = parent.clientWidth;
        h = parent.clientHeight;  
      }
      bbn.fn.log("BBN_CENTER", w, h);
      ele.style.position = "absolute";
      ele.style.top = Math.max(0, ((h - ele.offsetHeight) / 2) + parent.scrollTop) + "px";
      ele.style.left = Math.max(0, ((h - ele.offsetWidth) / 2) + parent.scrollLeft) + "px";
      return ele;
    }
center ( ele ) { let parent = ele . parentNode , w = parent . clientWidth , h = parent . clientHeight ; while ( parent && ( ! w || ! h ) ) { parent = ele . parentNode ; w = parent . clientWidth ; h = parent . clientHeight ; } bbn . fn . log ( "BBN_CENTER" , w , h ) ; ele . style . position = "absolute" ; ele . style . top = Math . max ( 0 , ( ( h - ele . offsetHeight ) / 2 ) + parent . scrollTop ) + "px" ; ele . style . left = Math . max ( 0 , ( ( h - ele . offsetWidth ) / 2 ) + parent . scrollLeft ) + "px" ; return ele ; }
Centers the given element by giving it a position absolute.
Centers the given element by giving it a position absolute .
//ele = $(ele); //w = parent.width(), //h = parent.height(); /*parent = parent.parent(),
          w = parent.width(),
          h = parent.height();*/ //ele.css("position","absolute"); //ele.css("top", Math.max(0, ((h - ele.outerHeight()) / 2) + parent.scrollTop()) + "px"); //ele.css("left", Math.max(0, ((w - ele.outerWidth()) / 2) + parent.scrollLeft()) + "px");