com.google.gwt.dom.client.Element.getOffsetParent()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(240)

本文整理了Java中com.google.gwt.dom.client.Element.getOffsetParent()方法的一些代码示例,展示了Element.getOffsetParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getOffsetParent()方法的具体详情如下:
包路径:com.google.gwt.dom.client.Element
类名称:Element
方法名:getOffsetParent

Element.getOffsetParent介绍

[英]Returns a reference to the object which is the closest (nearest in the containment hierarchy) positioned containing element.
[中]返回对位于包含元素的最近(在包含层次结构中最近)的对象的引用。

代码示例

代码示例来源:origin: sk.seges.acris/acris-recorder-client-core

  1. private int getSubPixelAbsoluteTop(com.google.gwt.dom.client.Element elem) {
  2. int top = 0;
  3. com.google.gwt.dom.client.Element curr = elem;
  4. while (curr.getOffsetParent() != null) {
  5. top -= curr.getScrollTop();
  6. curr = curr.getParentElement();
  7. }
  8. while (elem != null) {
  9. top += elem.getOffsetTop();
  10. elem = elem.getOffsetParent();
  11. }
  12. return top;
  13. };

代码示例来源:origin: sk.seges.acris/acris-recorder-client-core

  1. private int getSubPixelAbsoluteLeft(com.google.gwt.dom.client.Element elem) {
  2. int left = 0;
  3. com.google.gwt.dom.client.Element curr = elem;
  4. while (curr.getOffsetParent() != null) {
  5. left -= curr.getScrollLeft();
  6. curr = curr.getParentElement();
  7. }
  8. while (elem != null) {
  9. left += elem.getOffsetLeft();
  10. elem = elem.getOffsetParent();
  11. }
  12. return left;
  13. };

代码示例来源:origin: com.googlecode.gwtquery/gwtquery

  1. /**
  2. * Returns a GQuery collection with the positioned parent of the first matched element. This is
  3. * the first parent of the element that has position (as in relative or absolute). This method
  4. * only works with visible elements.
  5. */
  6. public GQuery offsetParent() {
  7. if (isEmpty()) {
  8. return $();
  9. }
  10. Element offParent = JsUtils.or(get(0).getOffsetParent(), body);
  11. while (offParent != null && !"body".equalsIgnoreCase(offParent.getTagName())
  12. && !"html".equalsIgnoreCase(offParent.getTagName())
  13. && "static".equals(getStyleImpl().curCSS(offParent, "position", true))) {
  14. offParent = offParent.getOffsetParent();
  15. }
  16. return new GQuery(offParent);
  17. }

代码示例来源:origin: com.googlecode.mgwt/mgwt

  1. private int[] offSet(com.google.gwt.dom.client.Element el) {
  2. int left = -el.getOffsetLeft();
  3. int top = -el.getOffsetTop();
  4. com.google.gwt.dom.client.Element domElem = el;
  5. while (true) {
  6. domElem = domElem.getOffsetParent();
  7. if (domElem == null)
  8. break;
  9. left -= domElem.getOffsetLeft();
  10. top -= domElem.getOffsetTop();
  11. }
  12. if (el != this.wrapper.getElement()) {
  13. left *= this.scale;
  14. top *= this.scale;
  15. }
  16. return new int[] {left, top};
  17. }

代码示例来源:origin: dankurka/mgwt

  1. private int[] offSet(com.google.gwt.dom.client.Element el) {
  2. int left = -el.getOffsetLeft();
  3. int top = -el.getOffsetTop();
  4. com.google.gwt.dom.client.Element domElem = el;
  5. while (true) {
  6. domElem = domElem.getOffsetParent();
  7. if (domElem == null)
  8. break;
  9. left -= domElem.getOffsetLeft();
  10. top -= domElem.getOffsetTop();
  11. }
  12. if (el != this.wrapper.getElement()) {
  13. left *= this.scale;
  14. top *= this.scale;
  15. }
  16. return new int[] {left, top};
  17. }

代码示例来源:origin: com.googlecode.gwtquery/gwtquery

  1. Element offsetParent = get(0).getOffsetParent();

代码示例来源:origin: com.allen-sauer.gwt.dnd/gwt-dnd

  1. Element p;
  2. while (elem != null && (p = elem.getOffsetParent()) != null) {
  3. if (!"visible".equals(DOMUtil.getEffectiveStyle(elem, "overflow"))) {
  4. int left = elem.getAbsoluteLeft();

代码示例来源:origin: com.extjs/gxt

  1. while (p != null && p != stope) {
  2. ctop += p.getOffsetTop();
  3. p = p.getOffsetParent().cast();

相关文章

Element类方法