/** * Construct a new {@link ShowMorePagerPanel}. */ public ShowMorePagerPanel() { initWidget(scrollable); // Do not let the scrollable take tab focus. scrollable.getElement().setTabIndex(-1); // Handle scroll events. scrollable.addScrollHandler(new ScrollHandler() { public void onScroll(ScrollEvent event) { // If scrolling up, ignore the event. int oldScrollPos = lastScrollPos; lastScrollPos = scrollable.getVerticalScrollPosition(); if (oldScrollPos >= lastScrollPos) { return; } HasRows display = getDisplay(); if (display == null) { return; } int maxScrollTop = scrollable.getWidget().getOffsetHeight() - scrollable.getOffsetHeight(); if (lastScrollPos >= maxScrollTop) { // We are near the end, so increase the page size. int newPageSize = Math.min( display.getVisibleRange().getLength() + incrementSize, display.getRowCount()); display.setVisibleRange(0, newPageSize); } } }); }
@Override public void onScroll(ScrollEvent event) { // Do nothing if content height less scroll area height if (scrollPanel.getElement().getScrollHeight() < scrollPanel.getElement().getOffsetHeight()) { followOutput = true; if (delegate != null) { delegate.onOutputScrolled(followOutput); } return; } // Follow output if scroll area is scrolled to the end if (scrollPanel.getElement().getScrollTop() + scrollPanel.getElement().getOffsetHeight() >= scrollPanel.getElement().getScrollHeight()) { followOutput = true; } else { followOutput = false; } if (delegate != null) { delegate.onOutputScrolled(followOutput); } }
public ScrollablePanelWidget() { super(); setTouchScrollingDisabled(true); addScrollHandler(new ScrollHandler() { @Override public void onScroll(final ScrollEvent event) { ScrollablePanelWidget.this.currentScrollingPos = new ScrollData(); if (event != null && event.getRelativeElement() != null) { final Element e = event.getRelativeElement(); ScrollablePanelWidget.this.currentScrollingPos.setTop(e.getScrollTop()); ScrollablePanelWidget.this.currentScrollingPos.setLeft(e.getScrollLeft()); ScrollablePanelWidget.this.currentScrollingPos.setBottom(e.getScrollHeight() - (e.getScrollTop() + e.getOffsetHeight())); ScrollablePanelWidget.this.currentScrollingPos.setRight(e.getScrollWidth() - (e.getScrollLeft() + e.getOffsetWidth())); ScrollablePanelWidget.this.currentScrollingPos.setScrollHeight(e.getScrollHeight()); ScrollablePanelWidget.this.currentScrollingPos.setScrollWidth(e.getScrollWidth()); } startTrigger(); } }); }
private void setupDefaultHandlers() { //Prevent DOMElements scrolling into view when they receive the focus domElementContainer.addDomHandler(new ScrollHandler() { @Override public void onScroll(final ScrollEvent scrollEvent) { domElementContainer.getElement().setScrollTop(0); domElementContainer.getElement().setScrollLeft(0); } }, ScrollEvent.getType()); addAttachHandler(new AttachEvent.Handler() { @Override public void onAttachOrDetach(final AttachEvent event) { if (event.isAttached()) { onResize(); } } }); addMouseDownHandler((e) -> setFocus(true)); }
@Test public void testSetupScrollBarSynchronization() { final AbsolutePanel scrollPanel = mock(AbsolutePanel.class); final ScrollHandler scrollHandler = mock(ScrollHandler.class); doReturn(scrollHandler).when(gridLienzoScrollHandler).onScroll(); doReturn(scrollPanel).when(gridLienzoScrollHandler).getScrollPanel(); doNothing().when(gridLienzoScrollHandler).synchronizeScrollSize(); gridLienzoScrollHandler.setupScrollBarSynchronization(); verify(gridLienzoScrollHandler).synchronizeScrollSize(); verify(scrollPanel).addDomHandler(scrollHandler, ScrollEvent.getType()); }
public void init() { taskScrollPanel.getElement().getStyle().setPosition(Position.ABSOLUTE); taskScrollPanel.getElement().getStyle().setOverflow(Overflow.SCROLL); //initialize the SVG panel initSVG(); //add scroll handler taskScrollPanel.addScrollHandler(new ScrollHandler() { @Override public void onScroll(ScrollEvent event) { int hscroll = taskScrollPanel.getHorizontalScrollPosition() * -1; firstHeaderRow.getElement().getStyle().setLeft(hscroll, Unit.PX); secondHeaderRow.getElement().getStyle().setLeft(hscroll, Unit.PX); taskBackgroundPanel.getElement().getStyle().setLeft(hscroll, Unit.PX); display.fireEvent(event); // view.onScroll(taskScrollPanel.getHorizontalScrollPosition(), // taskScrollPanel.getScrollPosition()); } }); }
protected void attachScrollingEvents(ComponentConnector connector) { Widget widget = connector.getWidget(); if(widget instanceof LazyScrollNotifier) { LazyScrollNotifier not = (LazyScrollNotifier) widget; scrollingElement = not.getLazyScrollingElement(); not.addLazyScrollListener(this); } else if (widget instanceof VWindow) { final VWindow window = (VWindow)widget; scrollingElement = window.contentPanel.getElement(); handlerRegistration = ((VWindow)widget).contentPanel.addScrollHandler(new ScrollHandler() { @Override public void onScroll(ScrollEvent event) { onLazyScroll(window.contentPanel.getElement()); } }); } else { LOGGER.severe("Failed to connect to scrolling events of " + connector.getClass().getName()); } }
@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; } } }); }
private void updateVerticalScrollGridDelegation() { // register scroll handler to Gantt widget ganttScrollHandlerRegistration = getWidget().addDomHandler(ganttScrollHandler, ScrollEvent.getType()); scrollDelegateHandlerRegistration = delegateScrollGridTarget.addScrollHandler(gridScrollDelegateTargetHandler); // add detach listener to unregister scroll handler when its // detached. delegateScrollGridTarget.addAttachHandler(new Handler() { @Override public void onAttachOrDetach(AttachEvent event) { if (!event.isAttached() && scrollDelegateHandlerRegistration != null) { scrollDelegateHandlerRegistration.removeHandler(); } } }); }
private void updateVerticalScrollTableDelegation() { // register scroll handler to Gantt widget ganttScrollHandlerRegistration = getWidget().addDomHandler(ganttScrollHandler, ScrollEvent.getType()); // register a scroll handler to 'delegation' scroll panel. scrollDelegateHandlerRegistration = delegateScrollPanelTarget.addScrollHandler(scrollDelegateTargetHandler); // add detach listener to unregister scroll handler when its // detached. delegateScrollPanelTarget.addAttachHandler(new Handler() { @Override public void onAttachOrDetach(AttachEvent event) { if (!event.isAttached() && scrollDelegateHandlerRegistration != null) { scrollDelegateHandlerRegistration.removeHandler(); } } }); }
void setupGridPanel() { //Lienzo stuff - Set default scale final Transform transform = newTransform().scale(VP_SCALE); gridPanel.getViewport().setTransform(transform); //Lienzo stuff - Add mouse pan support defaultTransformMediator = new BoundaryTransformMediator(GuidedDecisionTableModellerViewImpl.this); mousePanMediator.setTransformMediator(defaultTransformMediator); gridPanel.getViewport().getMediators().push(mousePanMediator); mousePanMediator.setBatchDraw(true); gridPanel.setBounds(getBounds()); gridPanel.getScrollPanel().addDomHandler(scrollEvent -> getPresenter().updateRadar(), ScrollEvent.getType()); //Wire-up widgets gridPanel.add(gridLayer); //Set ID on GridLienzoPanel for Selenium tests. gridPanel.getElement().setId("dtable_container_" + Document.get().createUniqueId()); }
public SignInOrUpPanel(ViewContext viewContext) { m_viewContext = viewContext; m_signIn = new SignInPanel(viewContext); m_signUp = new SignUpPanel(viewContext); this.addStyleName("sm_signuporin_panel"); m_innerContainer.setSize("100%", "100%"); m_innerContainer.add(m_signIn); m_innerContainer.add(m_signUp); this.add(m_innerContainer); this.addDomHandler(this, ScrollEvent.getType()); }
/** * Get the scroll panel in the drawing cavcas. * @return */ public ScrollPanel getViewAsScrollPanel() { scrollPanel.addScrollHandler(new ScrollHandler() { @Override public void onScroll(ScrollEvent event) { } }); return scrollPanel; }
@UiHandler("revisionsPanel") public void onPanelScrolled(ScrollEvent ignored) { // We cannot rely on exact equality of scroll positions because GWT sometimes round such values // and it is possible that the actual max scroll position is a pixel less then declared. if (revisionsPanel.getMaximumVerticalScrollPosition() - revisionsPanel.getVerticalScrollPosition() <= 1) { // to avoid autoscrolling to selected item revisionsPanel.getElement().focus(); delegate.onScrolledToBottom(); } }
@UiHandler("revisionsPanel") public void onPanelScrolled(ScrollEvent ignored) { // We cannot rely on exact equality of scroll positions because GWT sometimes round such values // and it is possible that the actual max scroll position is a pixel less then declared. if (revisionsPanel.getMaximumVerticalScrollPosition() - revisionsPanel.getVerticalScrollPosition() <= 1) { // to avoid autoscrolling to selected item revisionsPanel.getElement().focus(); delegate.onScrolledToButton(); } }
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()); }
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(); }
@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); }
ScrollHandler onScroll() { return (ScrollEvent event) -> { final Boolean mouseIsNotDragging = !getMousePanMediator().isDragging(); if (mouseIsNotDragging) { updateGridLienzoPosition(); } }; }
@Test public void testOnScrollWhenMouseIsNotDragging() { final RestrictedMousePanMediator mediator = mock(RestrictedMousePanMediator.class); final ScrollEvent scrollEvent = mock(ScrollEvent.class); doReturn(false).when(mediator).isDragging(); doReturn(mediator).when(gridLienzoScrollHandler).getMousePanMediator(); doNothing().when(gridLienzoScrollHandler).updateGridLienzoPosition(); final ScrollHandler scrollHandler = gridLienzoScrollHandler.onScroll(); scrollHandler.onScroll(scrollEvent); verify(gridLienzoScrollHandler).updateGridLienzoPosition(); }
@Test public void testOnScrollWhenMouseIsDragging() { final RestrictedMousePanMediator mediator = mock(RestrictedMousePanMediator.class); final ScrollEvent scrollEvent = mock(ScrollEvent.class); doReturn(true).when(mediator).isDragging(); doReturn(mediator).when(gridLienzoScrollHandler).getMousePanMediator(); final ScrollHandler scrollHandler = gridLienzoScrollHandler.onScroll(); scrollHandler.onScroll(scrollEvent); verify(gridLienzoScrollHandler, never()).updateGridLienzoPosition(); }
@Override public void onScroll(ScrollEvent event) { checkMoreItemsSpinnerIsMeasured(); if (noItemsFound && !moreItemsSpinnerIsVisible()) { noItemsFound = false; } if (!fetchingMoreItems && moreItemsSpinnerIsVisible()) { if (noItemsFound) { return; } log("LazyList: fetch more items"); fetchMoreItems(); add(moreItemsSpinner); } }
private void addScrollHandler() { if (scrollHandler != null) { scrollHandler.removeHandler(); } scrollHandler = view.addScrollHandler(new ScrollHandler() { @Override public void onScroll(ScrollEvent event) { updateTimer.cancel(); updateTimer.schedule(UPDATE_INTERVAL); } }); }
@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 (delegateScrollPanelTarget != null) { delegateScrollPanelTarget.setScrollPosition(scrollTop); } else if (delegateScrollGridTarget != null) { delegateScrollGridTarget.setScrollTop(scrollTop); } } finally { ganttScrollDelay.schedule(20); } } }); }
@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(); } }); }
@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(); } }); }
@Test public void testRadarIsUpdatedAfterScrolling() throws Exception { final ArgumentCaptor<ScrollHandler> scrollHandler = ArgumentCaptor.forClass(ScrollHandler.class); final ScrollEvent scrollEvent = mock(ScrollEvent.class); final AbsolutePanel mainPanel = mock(AbsolutePanel.class); final Transform transform = mock(Transform.class); final Viewport viewport = mock(Viewport.class); final Mediators mediators = mock(Mediators.class); final Element element = mock(Element.class); doReturn(transform).when(transform).scale(anyDouble()); doReturn(presenter).when(view).getPresenter(); doReturn(transform).when(view).newTransform(); doReturn(mediators).when(viewport).getMediators(); doReturn(element).when(mockGridPanel).getElement(); doReturn(mainPanel).when(mockGridPanel).getScrollPanel(); doReturn(viewport).when(mockGridPanel).getViewport(); view.setupGridPanel(); verify(mainPanel).addDomHandler(scrollHandler.capture(), eq(ScrollEvent.getType())); scrollHandler.getValue().onScroll(scrollEvent); verify(presenter).updateRadar(); }
/** * Return a ScrollHandler to ensure the Header and Sidebar are repositioned * according to the position of the scroll bars surrounding the GridWidget */ @Override protected ScrollHandler getScrollHandler() { return new ScrollHandler() { public void onScroll( ScrollEvent event ) { headerWidget.setScrollPosition( scrollPanel.getHorizontalScrollPosition() ); sidebarWidget.setScrollPosition( scrollPanel.getVerticalScrollPosition() ); } }; }
@EventHandler("sessionContainer") protected void onScroll(@ForEvent("scroll") ScrollEvent e) { // on the editor scroll recalculate palette position to be fixed on the screen palettePanel.getElement().getStyle().setTop(paletteInitialTop + e.getRelativeElement().getScrollTop(), Style.Unit.PX); palettePanel.getElement().getStyle().setLeft(paletteInitialLeft + e.getRelativeElement().getScrollLeft(), Style.Unit.PX); e.preventDefault(); }
public ScrollNavigator(ViewContext viewContext, Panel scrollContainer, Panel scrollee, Panel mouseLayer) { m_viewContext = viewContext; m_scrollContainer = scrollContainer; m_scrollContainerInner = scrollee; m_mouseLayer = mouseLayer; m_scrollBarWidthDiv2 = (int) Math.floor(((double)U_Css.getScrollBarWidth())/2); m_cellHudHeight = viewContext.appConfig.cellHudHeight; m_scrollContainer.getElement().getStyle().setZIndex(1); m_args_SnapToCoord.historyShouldIgnore = true; m_scrollContainer.addDomHandler(new ScrollHandler() { @Override public void onScroll(ScrollEvent event) { State_ViewingCell viewingState = m_viewContext.stateContext.get(State_ViewingCell.class); if( viewingState != null ) { VisualCell cell = (VisualCell)viewingState.getCell().getVisualization(); setTargetLayout(cell); //m_viewContext.cellMngr.updateCellTransforms(0.0); } else { //--- DRK > I guess when we leave viewing state and reset scroll left/top to zero, //--- that fires a scroll event, so valid case here...ASSERT removed for now. //smU_Debug.ASSERT(false, "Expected viewing state to be entered."); } if( m_scrollListener != null ) m_scrollListener.onScroll(); } }, ScrollEvent.getType()); this.toggleScrollBars(null, null); }
public void onScroll(ScrollEvent ev) { if (_enableScrollCheck) updateScrollPositions(_mpw); }
@Override public void onScroll(ScrollEvent event) { render(); }
@Override public void onScroll(ScrollEvent event) { showUI(); }
void setupScrollBarSynchronization() { getScrollPanel().addDomHandler(onScroll(), ScrollEvent.getType()); synchronizeScrollSize(); }
@Override public HandlerRegistration addScrollHandler(ScrollHandler handler) { return super.getWidget().addHandler(handler, ScrollEvent.getType()); }
private void scrollTo(int postion) { setScrollPosition(postion); ScrollEvent event = new IPhoneScrollEvent(); fireEvent(event); }
protected void scrollHorizontalTo(int postion) { setHorizontalScrollPosition(postion); ScrollEvent event = new IPhoneScrollEvent(); fireEvent(event); }