/**
 * @file ScrollBar vendor
 * @author liangxiaojun(liangxiaojun@derbysoft.com)
 */

import classNames from 'classnames';
import Direction from '../_statics/Direction';
import './ScrollBar.scss';

const tempSize = {
    vertical: null,
    horizontal: null
};

function getSize(direction = Direction.VERTICAL) {

    if (document == undefined || window == undefined) {
        return;
    }

    const isVertical = direction === Direction.VERTICAL;

    if (isVertical && tempSize.vertical !== null) {
        return tempSize.vertical;
    } else if (!isVertical && tempSize.horizontal != null) {
        return tempSize.horizontal;
    }

    const scrollDiv = document.createElement('div');
    scrollDiv.className = classNames('scroll-bar-for-measure', direction);
    document.body.appendChild(scrollDiv);

    let size = 0;
    if (isVertical) {
        size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
        tempSize.vertical = size;
    } else {
        size = scrollDiv.offsetHeight - scrollDiv.clientHeight;
        tempSize.horizontal = size;
    }

    document.body.removeChild(scrollDiv);

    return size;

}

export default {
    getSize
};

@@ -84,44 +84,18 @@
 */%0A%0A
-import classNames from 'classnames';
+// Statics
 %0Aimp
@@ -137,16 +137,76 @@
 ection';
+%0A%0A// Vendors%0Aimport classNames from 'classnames';%0A%0A// Styles
 %0Aimport 
@@ -226,16 +226,25 @@
 scss';%0A%0A
+// cache%0A
 const te
@@ -299,16 +299,23 @@
 ull%0A%7D;%0A%0A
+export 
 function
@@ -1187,28 +1187,319 @@
 ort 
-default %7B%0A    getSiz
+function getHideHorizontalScrollBarStyle() %7B%0A%0A    const size = getSize(Direction.HORIZONTAL);%0A%0A    return size %3E 0 ? %7B%0A        marginBottom: -size,%0A        paddingBottom: 0%0A    %7D : %7B%0A        marginBottom: -20,%0A        paddingBottom: 20%0A    %7D;%0A%0A%7D%0A%0Aexport default %7B%0A    getSize,%0A    getHideHorizontalScrollBarStyl
 e%0A%7D;

update ScrollBar