java类com.google.gwt.event.dom.client.ScrollHandler的实例源码

ShowMorePagerPanel.java 文件源码 项目:Peergos 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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);
      }
    }
  });
}
ScrollablePanelWidget.java 文件源码 项目:vaadin-scrollable-panel 阅读 24 收藏 0 点赞 0 评论 0
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();
        }
    });

}
WebPlotView.java 文件源码 项目:firefly 阅读 22 收藏 0 点赞 0 评论 0
public void onScroll() {
    int x= getScrollX();
    int y= getScrollY();

    int w= getScrollWidth();
    int h= getScrollHeight();
    if (_lastX!=x || _lastY!=y || _lastW!=w || _lastH!=h) {
        //todo - no lose this optimization - i think it needs to be somewhere else now
        _lastX= x;
        _lastY= y;
        _lastW= w;
        _lastH= h;
    }

    if (_primaryScrollInfo!=null) {
        _primaryScrollInfo._sWidth= w;
        _primaryScrollInfo._sHeight= h;
        _primaryScrollInfo._scrollHPos= x;
        _primaryScrollInfo._scrollVPos= y;
    }
    for(ScrollHandler handler : _scrollHandlerList) {
        handler.onScroll(null);
    }
}
GridLienzoPanel.java 文件源码 项目:appformer 阅读 22 收藏 0 点赞 0 评论 0
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));
}
GridLienzoScrollHandlerTest.java 文件源码 项目:appformer 阅读 27 收藏 0 点赞 0 评论 0
@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());
}
GanttChartView.java 文件源码 项目:gwt-gantt 阅读 23 收藏 0 点赞 0 评论 0
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());
            }
        });
    }
LazyVerticalLayoutConnector.java 文件源码 项目:LazyLayouts 阅读 19 收藏 0 点赞 0 评论 0
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());
    }
}
DiagramController.java 文件源码 项目:EasyML 阅读 26 收藏 0 点赞 0 评论 0
/**
 * Get the scroll panel in the drawing cavcas.
 * @return
 */
public ScrollPanel getViewAsScrollPanel() {
    scrollPanel.addScrollHandler(new ScrollHandler() {
        @Override
        public void onScroll(ScrollEvent event) {
        }
    });
    return scrollPanel;
}
GridLienzoScrollHandler.java 文件源码 项目:appformer 阅读 20 收藏 0 点赞 0 评论 0
ScrollHandler onScroll() {
    return (ScrollEvent event) -> {
        final Boolean mouseIsNotDragging = !getMousePanMediator().isDragging();

        if (mouseIsNotDragging) {
            updateGridLienzoPosition();
        }
    };
}
GridLienzoScrollHandlerTest.java 文件源码 项目:appformer 阅读 25 收藏 0 点赞 0 评论 0
@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();
}
GridLienzoScrollHandlerTest.java 文件源码 项目:appformer 阅读 32 收藏 0 点赞 0 评论 0
@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();
}
SimulationPresenter.java 文件源码 项目:mechaverse 阅读 22 收藏 0 点赞 0 评论 0
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);
    }
  });
}
GuidedDecisionTableModellerViewImplTest.java 文件源码 项目:drools-wb 阅读 25 收藏 0 点赞 0 评论 0
@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();
}
VerticalDecoratedTemplateDataGridWidget.java 文件源码 项目:drools-wb 阅读 28 收藏 0 点赞 0 评论 0
/**
 * 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() );
        }

    };
}
ScrollNavigator.java 文件源码 项目:swarm 阅读 18 收藏 0 点赞 0 评论 0
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);
}
ShowMorePagerPanel.java 文件源码 项目:swarm 阅读 26 收藏 0 点赞 0 评论 0
/**
 * 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);
      }
    }
  });
}
ShowMorePagerPanel.java 文件源码 项目:plugin-datasource 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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);
            }
        }
    });
}
ScrollablePanelWidget.java 文件源码 项目:vaadin-scrollable-panel 阅读 26 收藏 0 点赞 0 评论 0
@Override
public HandlerRegistration addScrollHandler(final ScrollHandler handler) {
    return super.addScrollHandler(handler);
}
WebPlotView.java 文件源码 项目:firefly 阅读 28 收藏 0 点赞 0 评论 0
public HandlerRegistration addScrollHandler(final ScrollHandler handler) {
    _scrollHandlerList.add(handler);
    return new HandlerRegistration() {
        public void removeHandler() { _scrollHandlerList.remove(handler); }
    };
}
GanttChart.java 文件源码 项目:gwt-gantt 阅读 23 收藏 0 点赞 0 评论 0
@Override
public HandlerRegistration addScrollHandler(ScrollHandler handler) {
    return super.getWidget().addHandler(handler, ScrollEvent.getType());
}
GreenHorizontalScroll.java 文件源码 项目:ineform 阅读 17 收藏 0 点赞 0 评论 0
@Override
public HandlerRegistration addScrollHandler(ScrollHandler handler) {
    return addDomHandler(handler, ScrollEvent.getType());
}
GreenVerticalScroll.java 文件源码 项目:ineform 阅读 18 收藏 0 点赞 0 评论 0
@Override
public HandlerRegistration addScrollHandler(ScrollHandler handler) {
    return addDomHandler(handler, ScrollEvent.getType());
}
GreenScrollPanel.java 文件源码 项目:ineform 阅读 19 收藏 0 点赞 0 评论 0
@Override
public HandlerRegistration addScrollHandler(ScrollHandler handler) {
    return impl.addScrollHandler(handler);
}
VNavigationView.java 文件源码 项目:touchkit 阅读 22 收藏 0 点赞 0 评论 0
public HandlerRegistration addScrollHandler(ScrollHandler scrollHandler) {
    return addHandler(scrollHandler, ScrollEvent.getType());
}
AbstractDecoratedGridWidget.java 文件源码 项目:kie-wb-common 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Return the ScrollPanel in which the DecoratedGridWidget "grid" is nested.
 * This allows ScrollEvents to be hooked up to other defendant controls
 * (e.g. the Header).
 * @return
 */
protected abstract ScrollHandler getScrollHandler();


问题


面经


文章

微信
公众号

扫码关注公众号