Example usage for com.vaadin.client WidgetUtil mayHaveScrollBars

List of usage examples for com.vaadin.client WidgetUtil mayHaveScrollBars

Introduction

In this page you can find the example usage for com.vaadin.client WidgetUtil mayHaveScrollBars.

Prototype

public static boolean mayHaveScrollBars(com.google.gwt.dom.client.Element pe) 

Source Link

Document

Detects what is currently the overflow style attribute in given element.

Usage

From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.VLayoutDragDropMouseHandler.java

License:Apache License

private boolean isEventOnScrollBar(NativeEvent event) {
    Element element = Element.as(event.getEventTarget());
    ;//  w w  w .j  a v  a2  s.co m

    if (WidgetUtil.mayHaveScrollBars(element)) {

        final int nativeScrollbarSize = WidgetUtil.getNativeScrollbarSize();

        int x = WidgetUtil.getTouchOrMouseClientX(event) - element.getAbsoluteLeft();
        int y = WidgetUtil.getTouchOrMouseClientY(event) - element.getAbsoluteTop();

        // Hopefully we have horizontal scroll.
        final int scrollWidth = element.getScrollWidth();
        final int clientWidth = element.getClientWidth();
        if (scrollWidth > clientWidth && clientWidth - nativeScrollbarSize < x) {
            return true;
        }

        // Hopefully we have vertical scroll.
        final int scrollHeight = element.getScrollHeight();
        final int clientHeight = element.getClientHeight();
        if (scrollHeight > clientHeight && clientHeight - nativeScrollbarSize < y) {
            return true;
        }

    }

    return false;
}