/*
 * #%L
 * GwtMaterial
 * %%
 * Copyright (C) 2015 - 2017 GwtMaterialDesign
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package gwt.material.design.client.ui.table;

import gwt.material.design.client.jquery.JQueryExtension;
import gwt.material.design.client.ui.html.Div;

public class XScrollPanel extends Div {

    private Div scrollBar = new Div();

    public XScrollPanel() {
        super("x-scroll");

        add(scrollBar);

        int barSize = JQueryExtension.scrollBarWidth();
        super.setStyle("width: calc(100% - " + barSize + "px)");
        setHeight((barSize + 1) + "px");
    }

    @Override
    public void setWidth(String width) {
        scrollBar.setWidth(width);
    }

    @Override
    public void setHeight(String height) {
        super.setHeight(height);
        scrollBar.setHeight(height);
    }
}

@@ -692,16 +692,175 @@
 table;%0A%0A
+import com.google.gwt.event.logical.shared.AttachEvent;%0Aimport com.google.gwt.user.client.ui.Panel;%0Aimport gwt.material.design.client.base.helper.EventHelper;%0A
 import g
@@ -909,16 +909,16 @@
 ension;%0A
-
 import g
@@ -1062,16 +1062,31 @@
 llPanel(
+Panel container
 ) %7B%0A    
@@ -1146,56 +1146,209 @@
     
-int barSize = JQueryExtension.scrollBarWidth();%0A
+AttachEvent.Handler handler = event -%3E %7B%0A            int barSize = JQueryExtension.scrollBarWidth(container.getElement());%0A            if (barSize %3C 1) %7B%0A                barSize = 8;%0A            %7D%0A    
     
@@ -1416,16 +1416,20 @@
         
+    
 setHeigh
@@ -1449,24 +1449,203 @@
 1) + %22px%22);%0A
+        %7D;%0A%0A        if(!container.isAttached()) %7B%0A            EventHelper.onAttachOnce(container, handler);%0A        %7D else %7B%0A            handler.onAttachOrDetach(null);%0A        %7D%0A
     %7D%0A%0A    @

Fix the scroll bar issues on Safari.