function updateScroll () {
    if (!elements.li[0]) return;
    var height = elements.li[0].offsetHeight,
        top = height * ctrl.index,
        bot = top + height,
        hgt = elements.scroller.clientHeight,
        scrollTop = elements.scroller.scrollTop;
    if (top < scrollTop) {
      scrollTo(top);
    } else if (bot > scrollTop + hgt) {
      scrollTo(bot - hgt);
    }
  }
function updateScroll () {
    if (!elements.li[0]) return;
    var height = elements.li[0].offsetHeight,
        top = height * ctrl.index,
        bot = top + height,
        hgt = elements.scroller.clientHeight,
        scrollTop = elements.scroller.scrollTop;
    if (top < scrollTop) {
      scrollTo(top);
    } else if (bot > scrollTop + hgt) {
      scrollTo(bot - hgt);
    }
  }
function updateScroll ( ) { if ( ! elements . li [ 0 ] ) return ; var height = elements . li [ 0 ] . offsetHeight , top = height * ctrl . index , bot = top + height , hgt = elements . scroller . clientHeight , scrollTop = elements . scroller . scrollTop ; if ( top < scrollTop ) { scrollTo ( top ) ; } else if ( bot > scrollTop + hgt ) { scrollTo ( bot - hgt ) ; } }
Makes sure that the focused element is within view.
Makes sure that the focused element is within view .