com.google.gwt.event.dom.client.ScrollEvent Java Examples

The following examples show how to use com.google.gwt.event.dom.client.ScrollEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GanttWidget.java    From gantt with Apache License 2.0 6 votes vote down vote up
@Override
public void onScroll(ScrollEvent event) {
    final Element element = event.getNativeEvent().getEventTarget().cast();
    if (element != container) {
        return;
    }
    AnimationScheduler.get().requestAnimationFrame(new AnimationCallback() {

        @Override
        public void execute(double timestamp) {
            int sl = container.getScrollLeft();
            int st = container.getScrollTop();
            if (sl != previousContainerScrollLeft) {
                timeline.setScrollLeft(sl);
                previousContainerScrollLeft = sl;
            }
            if (st != previousContainerScrollTop) {
                previousContainerScrollTop = st;
            }
        }
    });
}
 
Example #2
Source File: GanttConnector.java    From gantt with Apache License 2.0 6 votes vote down vote up
@Override
public void onScroll(ScrollEvent event) {
    if (delegatingVerticalScroll) {
        // if other component is scrolling, don't allow this scroll
        // event
        return;
    }
    AnimationScheduler.get().requestAnimationFrame(new AnimationCallback() {

        @Override
        public void execute(double timestamp) {
            ganttScrollDelay.cancel();
            ganttDelegatingVerticalScroll = true;
            int scrollTop = getWidget().getScrollContainer().getScrollTop();
            try {
                if (delegateScrollGridTarget != null) {
                    delegateScrollGridTarget.setScrollTop(scrollTop);
                }

            } finally {
                ganttScrollDelay.schedule(20);
            }
        }
    });
}
 
Example #3
Source File: DiagramController.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ScrollPanel getViewAsScrollPanel() {
	scrollPanel.addScrollHandler(new ScrollHandler() {
		@Override
		public void onScroll(ScrollEvent event) {
			unsynchronizedShapes();
		}
	});
	return scrollPanel;
}
 
Example #4
Source File: DiagramController.java    From EasyML with Apache License 2.0 5 votes vote down vote up
/**
 * Get the scroll panel in the drawing cavcas.
 * @return
 */
public ScrollPanel getViewAsScrollPanel() {
	scrollPanel.addScrollHandler(new ScrollHandler() {
		@Override
		public void onScroll(ScrollEvent event) {
		}
	});
	return scrollPanel;
}
 
Example #5
Source File: UIHider.java    From djvu-html5 with GNU General Public License v2.0 5 votes vote down vote up
public UIHider(int uiHideDelay, Widget textLayer) {
	this.uiHideDelay = uiHideDelay;
	textLayer.addDomHandler(this, MouseMoveEvent.getType());
	textLayer.addDomHandler(this, KeyDownEvent.getType());
	textLayer.addDomHandler(this, ScrollEvent.getType());
	textLayer.addDomHandler(this, TouchStartEvent.getType());
}
 
Example #6
Source File: TextLayer.java    From djvu-html5 with GNU General Public License v2.0 5 votes vote down vote up
public TextLayer(Djvu_html5 app) {
	this.app = app;
	setStyleName("textLayer");
	getElement().setAttribute("tabindex", "-1");

	addDomHandler(this, ScrollEvent.getType());

	app.getDataStore().addInfoListener(this::pageInfoAvailable);
	if (DjvuContext.getTextLayerEnabled())
		app.getDataStore().addTextListener(this::textAvailable);

	fontMeasure = Canvas.createIfSupported().getContext2d();
}
 
Example #7
Source File: TextLayer.java    From djvu-html5 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onScroll(ScrollEvent event) {
	int scrollTop = getElement().getScrollTop();
	int page = currentPage;
	Element pageElement = pages.get(page).getElement();
	while (page > 0 && pageElement.getOffsetTop() > scrollTop) {
		pageElement = pages.get(--page).getElement();
	}
	while (page + 1 < pages.size() && pageElement.getOffsetTop() + pageElement.getOffsetHeight() < scrollTop) {
		pageElement = pages.get(++page).getElement();
	}
	int left = pageElement.getOffsetLeft() - getElement().getScrollLeft();
	int top = pageElement.getOffsetTop() - scrollTop;
	app.getPageLayout().externalScroll(page, left, top);
}
 
Example #8
Source File: GanttConnector.java    From gantt with Apache License 2.0 5 votes vote down vote up
@Override
public void onScroll(ScrollEvent event) {
    if (ganttDelegatingVerticalScroll) {
        // if gantt is scrolling, don't allow this scroll event
        return;
    }
    AnimationScheduler.get().requestAnimationFrame(new AnimationCallback() {

        @Override
        public void execute(double timestamp) {
            onDelegateScroll();
        }
    });
}
 
Example #9
Source File: GanttConnector.java    From gantt with Apache License 2.0 5 votes vote down vote up
@Override
public void onScroll(com.vaadin.client.widget.grid.events.ScrollEvent event) {
    if (ganttDelegatingVerticalScroll) {
        // if gantt is scrolling, don't allow this scroll event
        return;
    }
    AnimationScheduler.get().requestAnimationFrame(new AnimationCallback() {

        @Override
        public void execute(double timestamp) {
            onDelegateScroll();
        }
    });
}
 
Example #10
Source File: UIHider.java    From djvu-html5 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onScroll(ScrollEvent event) {
	showUI();
}
 
Example #11
Source File: GanttWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
/**
 * Reset listeners.
 */
public void resetListeners() {
    Event.sinkEvents(container, Event.ONSCROLL | Event.ONCONTEXTMENU);

    if (contextMenuHandlerRegistration == null) {
        contextMenuHandlerRegistration = addDomHandler(contextMenuHandler, ContextMenuEvent.getType());
    }

    if (scrollHandlerRegistration == null) {
        scrollHandlerRegistration = addHandler(scrollHandler, ScrollEvent.getType());
    }
    if (isMsTouchSupported()) {
        // IE10 pointer events (ms-prefixed events)
        if (pointerDownHandlerRegistration == null) {
            pointerDownHandlerRegistration = addDomHandler(msPointerDownHandler, PointerDownEvent.getType());
        }
        if (pointerUpHandlerRegistration == null) {
            pointerUpHandlerRegistration = addDomHandler(msPointerUpHandler, PointerUpEvent.getType());
        }
        if (pointerMoveHandlerRegistration == null) {
            pointerMoveHandlerRegistration = addDomHandler(msPointerMoveHandler, PointerMoveEvent.getType());
        }
        if (pointerCancelHandlerRegistration == null) {
            pointerCancelHandlerRegistration = addHandler(msPointerCancelHandler, PointerCancelEvent.getType());
        }
    } else if (touchSupported) {
        // touch events replaces mouse events
        if (touchStartHandlerRegistration == null) {
            touchStartHandlerRegistration = addDomHandler(touchStartHandler, TouchStartEvent.getType());
        }
        if (touchEndHandlerRegistration == null) {
            touchEndHandlerRegistration = addDomHandler(touchEndHandler, TouchEndEvent.getType());
        }
        if (touchMoveHandlerRegistration == null) {
            touchMoveHandlerRegistration = addDomHandler(touchMoveHandler, TouchMoveEvent.getType());
        }
        if (touchCancelHandlerRegistration == null) {
            touchCancelHandlerRegistration = addHandler(touchCancelHandler, TouchCancelEvent.getType());
        }

    } else {
        if (mouseDblClickHandlerRegistration == null) {
            mouseDblClickHandlerRegistration = addDomHandler(doubleClickHandler, DoubleClickEvent.getType());
        }
        if (mouseDownHandlerRegistration == null) {
            mouseDownHandlerRegistration = addDomHandler(mouseDownHandler, MouseDownEvent.getType());
        }
        if (mouseUpHandlerRegistration == null) {
            mouseUpHandlerRegistration = addDomHandler(mouseUpHandler, MouseUpEvent.getType());
        }
        if (isMovableSteps() || isResizableSteps()) {
            if (mouseMoveHandlerRegistration == null) {
                mouseMoveHandlerRegistration = addDomHandler(mouseMoveHandler, MouseMoveEvent.getType());
            }
        } else if (mouseMoveHandlerRegistration != null) {
            mouseMoveHandlerRegistration.removeHandler();
            mouseMoveHandlerRegistration = null;
        }
    }
}