List of usage examples for com.google.gwt.user.client Element getScrollLeft
@Override public int getScrollLeft()
From source file:com.googlecode.kanbanik.client.components.WindowBox.java
License:Apache License
/** * * @param resize//ww w . j av a2 s. co m * @param clientX * @return */ private int getRelX(com.google.gwt.dom.client.Element resize, int clientX) { return clientX - resize.getAbsoluteLeft() + resize.getScrollLeft() + resize.getOwnerDocument().getScrollLeft(); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.scrollboxlayout.CubaScrollBoxLayoutWidget.java
License:Apache License
@Override public void onBrowserEvent(Event event) { super.onBrowserEvent(event); if (DOM.eventGetType(event) == Event.ONSCROLL) { Element element = getElement(); int scrollTop = element.getScrollTop(); int scrollLeft = element.getScrollLeft(); if (this.scrollTop != scrollTop || this.scrollLeft != scrollLeft) { if (onScrollHandler != null) { onScrollHandler.accept(scrollTop, scrollLeft); }// w ww . j av a2 s . com this.scrollTop = scrollTop; this.scrollLeft = scrollLeft; } } }
From source file:com.vaadin.terminal.gwt.client.Util.java
License:Open Source License
/** * Run workaround for webkits overflow auto issue. * /*from ww w .j a va 2 s. co m*/ * See: our bug #2138 and https://bugs.webkit.org/show_bug.cgi?id=21462 * * @param elem * with overflow auto */ public static void runWebkitOverflowAutoFix(final Element elem) { // Add max version if fix lands sometime to Webkit // Starting from Opera 11.00, also a problem in Opera if ((BrowserInfo.get().getWebkitVersion() > 0 || BrowserInfo.get().getOperaVersion() >= 11) && getNativeScrollbarSize() > 0) { final String originalOverflow = elem.getStyle().getProperty("overflow"); if ("hidden".equals(originalOverflow)) { return; } // check the scrolltop value before hiding the element final int scrolltop = elem.getScrollTop(); final int scrollleft = elem.getScrollLeft(); elem.getStyle().setProperty("overflow", "hidden"); Scheduler.get().scheduleDeferred(new Command() { public void execute() { // Dough, Safari scroll auto means actually just a moped elem.getStyle().setProperty("overflow", originalOverflow); if (scrolltop > 0 || elem.getScrollTop() > 0) { int scrollvalue = scrolltop; if (scrollvalue == 0) { // mysterious are the ways of webkits scrollbar // handling. In some cases webkit reports bad (0) // scrolltop before hiding the element temporary, // sometimes after. scrollvalue = elem.getScrollTop(); } // fix another bug where scrollbar remains in wrong // position elem.setScrollTop(scrollvalue - 1); elem.setScrollTop(scrollvalue); } // fix for #6940 : Table horizontal scroll sometimes not // updated when collapsing/expanding columns // Also appeared in Safari 5.1 with webkit 534 (#7667) if ((BrowserInfo.get().isChrome() || (BrowserInfo.get().isSafari() && BrowserInfo.get().getWebkitVersion() >= 534)) && (scrollleft > 0 || elem.getScrollLeft() > 0)) { int scrollvalue = scrollleft; if (scrollvalue == 0) { // mysterious are the ways of webkits scrollbar // handling. In some cases webkit may report a bad // (0) scrollleft before hiding the element // temporary, sometimes after. scrollvalue = elem.getScrollLeft(); } // fix another bug where scrollbar remains in wrong // position elem.setScrollLeft(scrollvalue - 1); elem.setScrollLeft(scrollvalue); } } }); } }
From source file:com.zipsoft.widgets.client.lazylayout.VLazyLayout.java
License:Apache License
/** * Proveravam u DOM-u koji se widgeti trenutno vide * @param mainWidget To je u stvari ova komponenta * @param child//from w ww . j ava2 s . co m * @param proximity * @return */ private static boolean isBeingShown(final Widget mainWidget, final Widget child, final int proximity) { final Element element = child.getElement(); /* * track the original element's position as we iterate through the DOM * tree */ int originalTopAdjusted = 0; final int originalHeight = element.getOffsetHeight(); int originalLeftAdjusted = 0; final int originalWidth = element.getOffsetWidth(); com.google.gwt.dom.client.Element childElement = element; com.google.gwt.dom.client.Element parentElement = element.getParentElement(); // What part of its canvas the parent shows, relative to its own // coordinates (0,0 is the top left corner) // final int parentTop = parentElement.getScrollTop(); //VEROVATNO MORA DA SE UZME I SKROL POZICIJA ELEMENTA KOJI SKROLUJE final int parentTop = mainWidget.getElement().getScrollTop(); //OVO JE VISINA CELOG KONTEJNERA - ONE JE MAKSIMALNA - MOZDA TREBA MERITI SAMO VISINU KOJA SE VIDI // final int parentBottom = parentTop + parentElement.getClientHeight(); final int parentBottom = parentTop + mainWidget.getElement().getClientHeight(); // debug("Box: top: " + parentTop+ "px, btm: " + parentBottom + "px"); final int parentLeft = parentElement.getScrollLeft(); final int parentRight = parentLeft + parentElement.getClientWidth(); /* * renderbox is the target box that is checked for visibility. If * the renderbox and parent's viewport don't overlap, it should not * be rendered. The renderbox is the child's position with an * adjusted margin. */ final int renderBoxTop = childElement.getOffsetTop() - proximity; final int renderBoxBottom = childElement.getOffsetTop() + childElement.getOffsetHeight() + proximity; final int renderBoxLeft = childElement.getOffsetLeft() - proximity; final int renderBoxRight = childElement.getOffsetLeft() + childElement.getOffsetWidth() + proximity; if (!colliding2D(parentTop, parentRight, parentBottom, parentLeft, renderBoxTop, renderBoxRight, renderBoxBottom, renderBoxLeft)) { return false; } /* * see if the original component is visible from the parent. Move * the object around to correspond the relative changes in position. * The offset is always relative to the parent - not the canvas. */ originalTopAdjusted += childElement.getOffsetTop() - childElement.getScrollTop(); originalLeftAdjusted += childElement.getOffsetLeft() - childElement.getScrollLeft(); if (!colliding2D(parentTop, parentRight, parentBottom, parentLeft, originalTopAdjusted - proximity, originalLeftAdjusted + originalWidth + proximity, originalTopAdjusted + originalHeight + proximity, originalLeftAdjusted - proximity)) { return false; } return true; }
From source file:com.zipsoft.widgets.client.lazylayout.VLazyLayout.java
License:Apache License
@Deprecated private static boolean isBeingShown(final Widget child, final int proximity) { final Element element = child.getElement(); /*/* www .j a v a2 s . co m*/ * track the original element's position as we iterate through the DOM * tree */ int originalTopAdjusted = 0; final int originalHeight = element.getOffsetHeight(); int originalLeftAdjusted = 0; final int originalWidth = element.getOffsetWidth(); com.google.gwt.dom.client.Element childElement = element; com.google.gwt.dom.client.Element parentElement = element.getParentElement(); // while (parentElement != null) { // clientheight == the height as seen in browser // offsetheight == the DOM element's native height // What part of its canvas the parent shows, relative to its own // coordinates (0,0 is the top left corner) final int parentTop = parentElement.getScrollTop(); //OVO JE VISINA CELOG KONTEJNERA - ONE JE MAKSIMALNA - MOZDA TREBA MERITI SAMO VISINU KOJA SE VIDI // final int parentBottom = parentTop + parentElement.getClientHeight(); final int parentBottom = parentTop + parentElement.getClientHeight(); final int parentLeft = parentElement.getScrollLeft(); final int parentRight = parentLeft + parentElement.getClientWidth(); /* * renderbox is the target box that is checked for visibility. If * the renderbox and parent's viewport don't overlap, it should not * be rendered. The renderbox is the child's position with an * adjusted margin. */ final int renderBoxTop = childElement.getOffsetTop() - proximity; final int renderBoxBottom = childElement.getOffsetTop() + childElement.getOffsetHeight() + proximity; final int renderBoxLeft = childElement.getOffsetLeft() - proximity; final int renderBoxRight = childElement.getOffsetLeft() + childElement.getOffsetWidth() + proximity; if (!colliding2D(parentTop, parentRight, parentBottom, parentLeft, renderBoxTop, renderBoxRight, renderBoxBottom, renderBoxLeft)) { return false; } /* * see if the original component is visible from the parent. Move * the object around to correspond the relative changes in position. * The offset is always relative to the parent - not the canvas. */ originalTopAdjusted += childElement.getOffsetTop() - childElement.getScrollTop(); originalLeftAdjusted += childElement.getOffsetLeft() - childElement.getScrollLeft(); if (!colliding2D(parentTop, parentRight, parentBottom, parentLeft, originalTopAdjusted - proximity, originalLeftAdjusted + originalWidth + proximity, originalTopAdjusted + originalHeight + proximity, originalLeftAdjusted - proximity)) { return false; } // debug("Menjam Parent element - OVO NE BI TREBALO DA SE DOGODI!!!"); // childElement = parentElement; // parentElement = childElement.getOffsetParent(); // } //TODO MISLIM DA OVO NE TREBA VISE // lastly, check the browser itself. // final int parentTop = Window.getScrollTop(); // final int parentBottom = parentTop + Window.getClientHeight(); // final int parentLeft = Window.getScrollLeft(); // final int parentRight = parentLeft + Window.getClientWidth(); // // final int renderBoxTop = childElement.getOffsetTop() - proximity; // final int renderBoxBottom = childElement.getOffsetTop() + childElement.getClientHeight() + proximity; // // final int renderBoxLeft = childElement.getOffsetLeft() - proximity; // final int renderBoxRight = childElement.getOffsetLeft() + childElement.getClientWidth() + proximity; // // if (!colliding2D(parentTop, parentRight, parentBottom, parentLeft, // renderBoxTop, renderBoxRight, renderBoxBottom, renderBoxLeft)) { // return false; // } // // originalTopAdjusted += childElement.getOffsetTop(); // originalLeftAdjusted += childElement.getOffsetLeft(); // if (!colliding2D(parentTop, parentRight, parentBottom, parentLeft, // originalTopAdjusted - proximity, originalLeftAdjusted // + originalWidth + proximity, originalTopAdjusted // + originalHeight + proximity, originalLeftAdjusted // - proximity)) { // return false; // } return true; }
From source file:edu.caltech.ipac.firefly.ui.imageGrid.BasicImageGrid.java
private void saveScrollPosition() { Element body = getElement(); int scrollX = body.getScrollLeft(); int scrollY = body.getScrollTop(); int viewWidth = DOM.getElementPropertyInt(body, "clientWidth"); int viewHeight = DOM.getElementPropertyInt(body, "clientHeight"); if (currentViewHeight != viewHeight) { currentViewHeight = viewHeight;// w w w. j ava 2s .c om } if (currentViewWidth != viewWidth) { currentViewWidth = viewWidth; } if (currentScrollX != scrollX) { currentScrollX = scrollX; } if (currentScrollY != scrollY) { currentScrollY = scrollY; } if (lockrelated != null && mpwList.size() > 0) { lockrelated = mpwList.get(0).getGroup().getLockRelated(); } }
From source file:edu.caltech.ipac.firefly.ui.imageGrid.BasicImageGrid.java
private void restoreScrollPositions() { Element body = getElement(); int scrollX = body.getScrollLeft(); int scrollY = body.getScrollTop(); int viewWidth = DOM.getElementPropertyInt(body, "clientWidth"); int viewHeight = DOM.getElementPropertyInt(body, "clientHeight"); if (currentViewHeight == viewHeight && currentViewWidth == viewWidth) { if (currentScrollX != scrollX) { setHorizontalScrollPosition(currentScrollX); }//from ww w .j ava2 s. c om if (currentScrollY != scrollY) { setScrollPosition(currentScrollY); } } }
From source file:org.thechiselgroup.biomixer.client.dnd.resources.DragEnabler.java
License:Apache License
public void createTransparentDragProxy(final int absoluteLeft, final int absoluteTop) { createDragWidget(absoluteLeft, absoluteTop); // TODO remove code duplication AbsolutePanel desktopWidget = desktop.asWidget(); int left = absoluteLeft - desktopWidget.getAbsoluteLeft() - 5; int top = absoluteTop - desktopWidget.getAbsoluteTop() - 5; Element element = hiddenAvatar.getElement(); CSS.setLocation(element, left, top); CSS.setSize(element, 10, 10); CSS.setZIndex(element, ZIndex.POPUP - 1); hiddenAvatar.addMouseUpHandler(new MouseUpHandler() { @Override//from ww w. j a v a 2 s. co m public void onMouseUp(MouseUpEvent event) { removeAvatar(); } }); // fake mouse down event on widget MouseDownEvent mouseEvent = new MouseDownEvent() { @Override public int getClientX() { return absoluteLeft; } @Override public int getClientY() { return absoluteTop; } @Override public int getNativeButton() { return NativeEvent.BUTTON_LEFT; } @Override public int getRelativeX(com.google.gwt.dom.client.Element target) { return getClientX() - target.getAbsoluteLeft() + target.getScrollLeft() + target.getOwnerDocument().getScrollLeft(); } @Override public int getRelativeY(com.google.gwt.dom.client.Element target) { return getClientY() - target.getAbsoluteTop() + target.getScrollTop() + target.getOwnerDocument().getScrollTop(); } @Override public Object getSource() { return hiddenAvatar; } @Override public boolean isControlKeyDown() { return false; } @Override public boolean isMetaKeyDown() { return false; } }; mouseEvent.setRelativeElement(element); hiddenAvatar.fireEvent(mouseEvent); }
From source file:org.thechiselgroup.biomixer.client.dnd.resources.DragEnabler.java
License:Apache License
public void forwardMouseMove(final int clientX, final int clientY) { if (hiddenAvatar == null) { return;/*from w ww .j a v a2 s. com*/ } MouseMoveEvent mouseEvent = new MouseMoveEvent() { @Override public int getClientX() { return clientX; } @Override public int getClientY() { return clientY; } @Override public int getRelativeX(com.google.gwt.dom.client.Element target) { return getClientX() - target.getAbsoluteLeft() + target.getScrollLeft() + target.getOwnerDocument().getScrollLeft(); } @Override public int getRelativeY(com.google.gwt.dom.client.Element target) { return getClientY() - target.getAbsoluteTop() + target.getScrollTop() + target.getOwnerDocument().getScrollTop(); } @Override public Object getSource() { return hiddenAvatar; } }; mouseEvent.setRelativeElement(hiddenAvatar.getElement()); hiddenAvatar.fireEvent(mouseEvent); }