Java Code Examples for com.google.gwt.user.client.Window#getScrollTop()
The following examples show how to use
com.google.gwt.user.client.Window#getScrollTop() .
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: DomUtil.java From jetpad-projectional-open-source with Apache License 2.0 | 6 votes |
public static Rectangle visiblePart(Element ctx, Rectangle rect) { while (true) { if (ctx.getOffsetParent() == null) { Rectangle visibleArea = new Rectangle(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight()); return visibleArea.intersect(rect); } else { Rectangle visible; if (hasScroller(ctx)) { visible = new Rectangle(0, 0, ctx.getClientWidth(), ctx.getClientHeight()); Vector scroll = new Vector(ctx.getScrollLeft(), ctx.getScrollTop()); rect = rect.sub(scroll); } else { visible = new Rectangle(0, 0, ctx.getScrollWidth(), ctx.getScrollHeight()); } Rectangle newRect = visible.intersect(rect); Vector offset = new Vector(ctx.getOffsetLeft(), ctx.getOffsetTop()); ctx = ctx.getOffsetParent(); rect = newRect.add(offset); } } }
Example 2
Source File: Affix.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 6 votes |
public void resetPosistion() { if (!this.isVisible()) { return; } int scrollTop = Window.getScrollTop(); int docHeigth = Document.get().getScrollHeight(); this.getElement().getStyle().clearHeight(); this.offsetHeight = this.getElement().getClientHeight(); int top = this.pinnedOffset - scrollTop - this.offsetTop; int bottom = docHeigth - scrollTop - this.offsetBottom - this.offsetTop - this.offsetHeight; if (bottom <= 0 || this.fixBottom != Integer.MIN_VALUE) { this.toggleAffix(Affixed.BOTTOM); } else if (top >= 0) { this.toggleAffix(Affixed.TOP); } else { this.toggleAffix(Affixed.AFFIX); } }
Example 3
Source File: FilterBox.java From unitime with Apache License 2.0 | 6 votes |
private void position(final UIObject relativeObject, int offsetWidth, int offsetHeight) { int textBoxOffsetWidth = relativeObject.getOffsetWidth(); int offsetWidthDiff = offsetWidth - textBoxOffsetWidth; int left = relativeObject.getAbsoluteLeft(); if (offsetWidthDiff > 0) { int windowRight = Window.getClientWidth() + Window.getScrollLeft(); int windowLeft = Window.getScrollLeft(); int distanceToWindowRight = windowRight - left; int distanceFromWindowLeft = left - windowLeft; if (distanceToWindowRight < offsetWidth && distanceFromWindowLeft >= offsetWidthDiff) { left -= offsetWidthDiff; } } int top = relativeObject.getAbsoluteTop(); int windowTop = Window.getScrollTop(); int windowBottom = Window.getScrollTop() + Window.getClientHeight(); int distanceFromWindowTop = top - windowTop; int distanceToWindowBottom = windowBottom - (top + relativeObject.getOffsetHeight()); if (distanceToWindowBottom < offsetHeight && distanceFromWindowTop >= offsetHeight) { top -= offsetHeight; } else { top += relativeObject.getOffsetHeight(); } setPopupPosition(left, top); }
Example 4
Source File: CellContainerToDomMapper.java From jetpad-projectional-open-source with Apache License 2.0 | 6 votes |
@Override protected void onAttach(MappingContext ctx) { super.onAttach(ctx); getSource().setCellContainerPeer(createCellContainerPeer()); disablePopup(getTarget()); getTarget().setTabIndex(0); getTarget().addClassName(CSS.rootContainer()); getTarget().appendChild(myLineHighlight1); getTarget().appendChild(myLineHighlight2); getTarget().appendChild(myContent); refreshLineHighlight(); myScrollLeft = Window.getScrollLeft(); myScrollTop = Window.getScrollTop(); myWindowReg = Window.addWindowScrollHandler(new Window.ScrollHandler() { @Override public void onWindowScroll(Window.ScrollEvent event) { myScrollLeft = event.getScrollLeft(); myScrollTop = event.getScrollTop(); } }); }
Example 5
Source File: ViewContainerToElementMapper.java From jetpad-projectional-open-source with Apache License 2.0 | 6 votes |
private MouseEvent toMouseEvent(Event e) { int cx = e.getClientX(); int cy = e.getClientY(); int scrollLeft = Window.getScrollLeft(); int scrollTop = Window.getScrollTop(); int absoluteLeft = myRootDiv.getAbsoluteLeft(); int absoluteTop = myRootDiv.getAbsoluteTop(); int elScrollTop = myRootDiv.getScrollTop(); int elScrollLeft = myRootDiv.getScrollLeft(); int x = cx + scrollLeft - absoluteLeft + elScrollLeft; int y = cy + scrollTop - absoluteTop + elScrollTop; return new MouseEvent(x, y); }
Example 6
Source File: SuggesterConnector.java From cuba with Apache License 2.0 | 5 votes |
protected void setPopupPosition(SuggestPopup popup) { int[] cursorPos = widget.getCursorCoords(); int scrollLeft = Window.getScrollLeft(); int scrollTop = Window.getScrollTop(); int leftPos = cursorPos[0] - scrollLeft; int topPos = cursorPos[1] - scrollTop + CURSOR_LINE_HEIGHT; popup.setPopupPosition(leftPos, topPos); }
Example 7
Source File: InstructorAttributeEdit.java From unitime with Apache License 2.0 | 5 votes |
public void show() { UniTimePageLabel.getInstance().setPageName(iAttribute.getId() == null ? MESSAGES.pageAddInstructorAttribute() : MESSAGES.pageEditInstructorAttribute()); setVisible(true); iLastScrollLeft = Window.getScrollLeft(); iLastScrollTop = Window.getScrollTop(); onShow(); Window.scrollTo(0, 0); }
Example 8
Source File: CubaTreeTableWidget.java From cuba with Apache License 2.0 | 5 votes |
@Override public void showContextMenu(Event event) { if (_delegate.contextMenuEnabled && enabled && (_delegate.customContextMenu != null || actionKeys != null)) { // Show context menu if there are registered action handlers int left = WidgetUtil.getTouchOrMouseClientX(event) + Window.getScrollLeft(); int top = WidgetUtil.getTouchOrMouseClientY(event) + Window.getScrollTop(); selectRowForContextMenuActions(event); showContextMenu(left, top); } }
Example 9
Source File: OffsetPosition.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * Create a offset position base on the event's client X, Y. The return offset * position is relative to the Document body coordinate. * * @param event */ public OffsetPosition(Event event) { // convert the event's client coordinate system, which is client area base, to the // body position coordinate system. this.left = event.getClientX() + Window.getScrollLeft() - Document.get().getBodyOffsetLeft(); this.top = event.getClientY() + Window.getScrollTop() - Document.get().getBodyOffsetTop(); this.offsetParent = null; }
Example 10
Source File: RoomDepartmentsEdit.java From unitime with Apache License 2.0 | 5 votes |
public void show() { UniTimePageLabel.getInstance().setPageName(MESSAGES.pageEditRoomsDepartments()); setVisible(true); iLastScrollLeft = Window.getScrollLeft(); iLastScrollTop = Window.getScrollTop(); onShow(); Window.scrollTo(0, 0); }
Example 11
Source File: SolutionReportsPage.java From unitime with Apache License 2.0 | 5 votes |
public static void __search() { final int left = Window.getScrollLeft(); final int top = Window.getScrollTop(); SolutionReportsPage page = (SolutionReportsPage)RootPanel.get("UniTimeGWT:Body").getWidget(0); page.init(new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Boolean result) { if (result) Window.scrollTo(left, top); } }); }
Example 12
Source File: Affix.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
protected void toggleAffix(Affixed affix) { Element e = this.getElement(); Style style = e.getStyle(); if (this.affixed != affix) { this.clearElementStyle(); this.affixed = affix; StyleUtils.addStyle(e, this.affixed); } switch (affix) { case AFFIX: style.setTop(this.offsetTop, Unit.PX); style.setWidth(this.offsetWidth, Unit.PX); style.setHeight(this.offsetHeight, Unit.PX); style.setZIndex(this.layerIndex); e.getParentElement().getStyle().setPaddingTop(this.offsetHeight, Unit.PX); break; case BOTTOM: int docHeigth = Document.get().getScrollHeight(); int scrollTop = Window.getScrollTop(); int bottom = this.offsetBottom - (docHeigth - scrollTop - this.clientHeigth); if (this.fixBottom != Integer.MIN_VALUE) { bottom = Math.max(bottom, this.fixBottom); } style.setPosition(Position.FIXED); style.setBottom(bottom, Unit.PX); style.setWidth(this.offsetWidth, Unit.PX); style.setHeight(this.offsetHeight, Unit.PX); style.setZIndex(this.layerIndex); break; default: break; } }
Example 13
Source File: NotAssignedClassesPage.java From unitime with Apache License 2.0 | 5 votes |
public static void __search() { final int left = Window.getScrollLeft(); final int top = Window.getScrollTop(); NotAssignedClassesPage page = (NotAssignedClassesPage)RootPanel.get("UniTimeGWT:Body").getWidget(0); page.search(new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Boolean result) { if (result) Window.scrollTo(left, top); } }); }
Example 14
Source File: EventAdd.java From unitime with Apache License 2.0 | 5 votes |
public void show() { UniTimePageLabel.getInstance().setPageName(iEvent.getId() == null ? MESSAGES.pageAddEvent() : MESSAGES.pageEditEvent()); setVisible(true); iLastScrollLeft = Window.getScrollLeft(); iLastScrollTop = Window.getScrollTop(); onShow(); Window.scrollTo(0, 0); if (iForm.getRowFormatter().isVisible(iSessionRow)) { iSession.setFilter(this); iForm.setWidget(iSessionRow, 1, iSession); } iFileUpload.check(); }
Example 15
Source File: AssignmentHistoryPage.java From unitime with Apache License 2.0 | 5 votes |
public static void __search() { final int left = Window.getScrollLeft(); final int top = Window.getScrollTop(); AssignmentHistoryPage page = (AssignmentHistoryPage)RootPanel.get("UniTimeGWT:Body").getWidget(0); page.search(new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Boolean result) { if (result) Window.scrollTo(left, top); } }); }
Example 16
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 4 votes |
private int getDesiredTopPosition() { return toInt32(WidgetUtil.getBoundingClientRect(VComboBoxMultiselect.this.tb.getElement()) .getBottom()) + Window.getScrollTop(); }
Example 17
Source File: TimeGrid.java From unitime with Apache License 2.0 | 4 votes |
@Override public void onBrowserEvent(Event event) { if (Event.ONMOUSEMOVE == DOM.eventGetType(event) && !iSelection.isActive() && iMoving != null) { iMoving.onBrowserEvent(event); if (iMoving.iCursor != null) getElement().getStyle().setCursor(iMoving.iCursor); return; } double x = event.getClientX() - getAbsoluteLeft() + Window.getScrollLeft(); double y = event.getClientY() - getAbsoluteTop() + Window.getScrollTop(); int slot = 3 * Math.min(Math.max(0, (int)Math.round(4 * (y - 1 + iStart * iCellHeight) / iCellHeight)), 96); int day = Math.min(Math.max(0, (int)Math.floor((x - 2) / iCellWidth)), iDays.length - 1); int weeks = (isSingleRoom() ? iSelectedWeeks.size() : iRoomResources.size()); int week = Math.min(Math.max(0, (int)Math.floor(weeks * (x - 2 - iCellWidth * day) / (iCellWidth - 6))), weeks - 1); if (iRTL) { day = iDays.length - day - 1; week = weeks - week - 1; } int dayOfWeek = iDays[day]; int h = slot / 12; int m = 5 * (slot % 12); String time = (CONSTANTS.useAmPm() ? (h == 0 ? "12": h <= 12 ? h : h-12) : h) + ":" + (m < 10 ? "0" : "") + m + (CONSTANTS.useAmPm() ? (h <= 11 ? "a" : "p") : ""); int dayInv = (iDayOfWeeks == null ? (7 + dayOfWeek - iPropertiesProvider.getFirstDayOfWeek()) % 7 : dayOfWeek); String text = (iDayOfWeeks == null ? CONSTANTS.longDays()[dayOfWeek] : iDayOfWeeks.get(dayOfWeek)) + " " + (isSingleRoom() ? iSelectedWeeks.get(week) : iSelectedWeeks.get(0)).getDayNames().get(dayInv) + " " + time + (isSingleRoom() ? "" : " " + iRoomResources.get(week).getName()); ResourceInterface room = (isSingleRoom() ? iRoomResources.get(0) : iRoomResources.get(week)); iPopup.setPopupPosition(event.getClientX() + Window.getScrollLeft(), event.getClientY() + Window.getScrollTop()); getElement().getStyle().setCursor(Cursor.CROSSHAIR); switch (DOM.eventGetType(event)) { case Event.ONMOUSEDOWN: iSelection.setStart(dayOfWeek, slot, week); iSelection.setEnd(dayOfWeek, slot, week); iSelection.setVisible(true); iSelection.setActive(true); break; case Event.ONMOUSEMOVE: iSelection.setEnd(dayOfWeek, slot, week); if (!iPopup.isShowing()) iPopup.show(); if (!room.getId().equals(iLastRoomId)) { RoomHint.showHint(iPopup.getElement(), room.getId(), "", (room.hasDistance() ? String.valueOf(Math.round(room.getDistance())) : ""), false); iLastRoomId = room.getId(); } break; case Event.ONMOUSEUP: onMouseUp(); break; case Event.ONMOUSEOVER: if (!iPopup.isShowing() && (iSelection.isActive() || iMoving == null)) iPopup.show(); if (iSelection.isActive() && !iSelection.isVisible()) { iSelection.setVisible(true); } if (!room.getId().equals(iLastRoomId)) { RoomHint.showHint(iPopup.getElement(), room.getId(), "", (room.hasDistance() ? String.valueOf(Math.round(room.getDistance())) : ""), false); iLastRoomId = room.getId(); } break; case Event.ONMOUSEOUT: Element child = DOM.eventGetToElement(event); if (child != null && !getElement().isOrHasChild(child)) { if (iPopup.isShowing()) { iPopup.hide(); RoomHint.hideHint(); iLastRoomId = null; } iSelection.setVisible(false); } /* if (iSelection.isActive() && !DOM.isOrHasChild(TimeGrid.this.getElement(), DOM.eventGetToElement(event))) { iSelection.setActive(false); } */ break; } iHint.setText((iSelection.isVisible() && iSelection.isActive() ? iSelection.toString() : text)); event.preventDefault(); event.stopPropagation(); }
Example 18
Source File: ViewContainerToElementMapper.java From jetpad-projectional-open-source with Apache License 2.0 | 4 votes |
private void update() { Rectangle newRect = new Rectangle(Window.getScrollLeft() - myRootDiv.getAbsoluteLeft(), Window.getScrollTop() - myRootDiv.getAbsoluteTop(), Window.getClientWidth(), Window.getClientHeight()); if (myVisibleArea.get() != null && myVisibleArea.get().contains(newRect)) return; myVisibleArea.set(expand(newRect)); }
Example 19
Source File: DropDownButton.java From appinventor-extensions with Apache License 2.0 | 4 votes |
/** * @param offsetWidth width of the ContextMenu being positioned on the parent element * @param offsetHeight height of the ContextMenu being positioned on the parent element * Sets the position of the ContextMenu on the screen given it's dimensions */ @Override public void setPosition(int offsetWidth, int offsetHeight) { // getAbsoluteLeft/Right() gives the top coordinate of the parent element // getOffsetWidth/Height() gives the width/height of the parent element int left = Window.Navigator.getUserAgent().contains("Chrome") && isPinchZoomed() ? getTrueAbsoluteLeft() : getAbsoluteLeft(); if (rightAlign) { left += getOffsetWidth() - offsetWidth; } int top = Window.Navigator.getUserAgent().contains("Chrome") && isPinchZoomed() ? getTrueAbsoluteTop() + getOffsetHeight() : getAbsoluteTop() + getOffsetHeight(); // Values to determine how to display the ContextMenu - above or below int dropDownBottom = top + offsetHeight; int screenBottom = Window.getScrollTop()+Window.getClientHeight(); // if the bottom will go off the current browser screen, display // the dropdown as a 'dropup' where the ContextMenu appears // above instead if(dropDownBottom > screenBottom) { int newTop = Window.Navigator.getUserAgent().contains("Chrome") && isPinchZoomed() ? getTrueAbsoluteTop() -offsetHeight : getAbsoluteTop() - offsetHeight; // account for the extreeeemely unlikely case where newTop // also goes off the screen in this case, it makes more // sense to just go off the bottom of the screen (the screen // won't grow up, and so the menu would get completely cut // off at the top if(newTop >= 0) { top = newTop; } } menu.setPopupPosition(left, top); }
Example 20
Source File: Geometry.java From gwt-traction with Apache License 2.0 | 2 votes |
/** * This takes into account scrolling and will be in absolute * coordinates where the top left corner of the page is 0,0 but * the viewport may be scrolled to something else. */ public static final Rect getViewportBounds() { return new Rect(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight()); }