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

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

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

Element.getClientWidth介绍

[英]Returns the inner width of an element in pixels, including padding but not the vertical scrollbar width, border, or margin.
[中]返回元素的内部宽度(以像素为单位),包括填充,但不包括垂直滚动条宽度、边框或边距。

代码示例

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * The width of the document's client area.
  3. *
  4. * @return the document's client width
  5. */
  6. public final int getClientWidth() {
  7. return getViewportElement().getClientWidth();
  8. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * Get the maximum horizontal scroll position.
  3. *
  4. * @param scrollable the scrollable element
  5. * @return the maximum scroll position
  6. */
  7. public int getMaximumHorizontalScrollPosition(Element scrollable) {
  8. return isRtl(scrollable) ? 0 : scrollable.getScrollWidth() - scrollable.getClientWidth();
  9. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * Get the minimum horizontal scroll position.
  3. *
  4. * @param scrollable the scrollable element
  5. * @return the minimum scroll position
  6. */
  7. public int getMinimumHorizontalScrollPosition(Element scrollable) {
  8. return isRtl(scrollable) ? scrollable.getClientWidth() - scrollable.getScrollWidth() : 0;
  9. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. @Override
  2. public void setScrollLeft(Element elem, int left) {
  3. if (!isGecko19() && isRTL(elem)) {
  4. left += elem.getScrollWidth() - elem.getClientWidth();
  5. }
  6. super.setScrollLeft(elem, left);
  7. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. @Override
  2. public void setScrollLeft(Element elem, int left) {
  3. if (!elem.hasTagName(BodyElement.TAG) && isRTL(elem)) {
  4. left += elem.getScrollWidth() - elem.getClientWidth();
  5. }
  6. super.setScrollLeft(elem, left);
  7. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. @Override
  2. public int getScrollLeft(Element elem) {
  3. if (!elem.hasTagName(BodyElement.TAG) && isRTL(elem)) {
  4. return super.getScrollLeft(elem)
  5. - (elem.getScrollWidth() - elem.getClientWidth());
  6. }
  7. return super.getScrollLeft(elem);
  8. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. @Override
  2. public int getScrollLeft(Element elem) {
  3. if (!isGecko19() && isRTL(elem)) {
  4. return super.getScrollLeft(elem)
  5. - (elem.getScrollWidth() - elem.getClientWidth());
  6. }
  7. return super.getScrollLeft(elem);
  8. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. void scrollToEnd() {
  2. Element elem = getElement();
  3. targetScrollLeft = elem.getScrollWidth() - elem.getClientWidth();
  4. if (LocaleInfo.getCurrentLocale().isRTL()) {
  5. targetScrollLeft *= -1;
  6. }
  7. if (isAnimationEnabled()) {
  8. // Animate the scrolling.
  9. startScrollLeft = elem.getScrollLeft();
  10. run(250, elem);
  11. } else {
  12. // Scroll instantly.
  13. onComplete();
  14. }
  15. }
  16. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. public double getUnitSizeInPixels(
  2. Element parent, Unit unit, boolean vertical) {
  3. if (unit == null) {
  4. return 1;
  5. }
  6. switch (unit) {
  7. case PCT:
  8. return (vertical ? parent.getClientHeight() : parent.getClientWidth())
  9. / 100.0;
  10. case EM:
  11. return relativeRuler.getOffsetWidth() / 10.0;
  12. case EX:
  13. return relativeRuler.getOffsetHeight() / 10.0;
  14. case CM:
  15. return fixedRuler.getOffsetWidth() * 0.1; // 1.0 cm / cm
  16. case MM:
  17. return fixedRuler.getOffsetWidth() * 0.01; // 0.1 cm / mm
  18. case IN:
  19. return fixedRuler.getOffsetWidth() * 0.254; // 2.54 cm / in
  20. case PT:
  21. return fixedRuler.getOffsetWidth() * 0.00353; // 0.0353 cm / pt
  22. case PC:
  23. return fixedRuler.getOffsetWidth() * 0.0423; // 0.423 cm / pc
  24. default:
  25. case PX:
  26. return 1;
  27. }
  28. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. int parentWidth = parentElem.getClientWidth();
  2. int parentHeight = parentElem.getClientHeight();
  3. for (Layer l : layers) {

代码示例来源:origin: net.wetheinter/gwt-user

  1. /**
  2. * The width of the document's client area.
  3. *
  4. * @return the document's client width
  5. */
  6. public final int getClientWidth() {
  7. return getViewportElement().getClientWidth();
  8. }

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

  1. /**
  2. * Get the minimum horizontal scroll position.
  3. *
  4. * @param scrollable the scrollable element
  5. * @return the minimum scroll position
  6. */
  7. public int getMinimumHorizontalScrollPosition(Element scrollable) {
  8. return isRtl(scrollable) ? scrollable.getClientWidth() - scrollable.getScrollWidth() : 0;
  9. }

代码示例来源:origin: net.wetheinter/gwt-user

  1. /**
  2. * Get the maximum horizontal scroll position.
  3. *
  4. * @param scrollable the scrollable element
  5. * @return the maximum scroll position
  6. */
  7. public int getMaximumHorizontalScrollPosition(Element scrollable) {
  8. return isRtl(scrollable) ? 0 : scrollable.getScrollWidth() - scrollable.getClientWidth();
  9. }

代码示例来源:origin: net.wetheinter/gwt-user

  1. /**
  2. * Get the minimum horizontal scroll position.
  3. *
  4. * @param scrollable the scrollable element
  5. * @return the minimum scroll position
  6. */
  7. public int getMinimumHorizontalScrollPosition(Element scrollable) {
  8. return isRtl(scrollable) ? scrollable.getClientWidth() - scrollable.getScrollWidth() : 0;
  9. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * Recalculate the height and width of a native scrollbar.
  3. */
  4. private static void maybeRecalculateNativeScrollbarSize() {
  5. // Check if the size has already been calculated.
  6. if (nativeHeight > -1) {
  7. return;
  8. }
  9. // Create a scrollable element and attach it to the body.
  10. Element scrollable = Document.get().createDivElement();
  11. scrollable.getStyle().setPosition(Position.ABSOLUTE);
  12. scrollable.getStyle().setTop(-1000.0, Unit.PX);
  13. scrollable.getStyle().setLeft(-1000.0, Unit.PX);
  14. scrollable.getStyle().setHeight(100.0, Unit.PX);
  15. scrollable.getStyle().setWidth(100.0, Unit.PX);
  16. scrollable.getStyle().setOverflow(Overflow.SCROLL);
  17. scrollable.getStyle().setProperty("direction", "rtl");
  18. Document.get().getBody().appendChild(scrollable);
  19. // Add some content.
  20. Element content = Document.get().createDivElement();
  21. content.setInnerText("content");
  22. scrollable.appendChild(content);
  23. // Measure the height and width.
  24. nativeHeight = scrollable.getOffsetHeight() - scrollable.getClientHeight();
  25. nativeWidth = scrollable.getOffsetWidth() - scrollable.getClientWidth();
  26. nativeRtl = (content.getAbsoluteLeft() > scrollable.getAbsoluteLeft());
  27. // Detach the scrollable element.
  28. scrollable.removeFromParent();
  29. }

代码示例来源:origin: net.wetheinter/gwt-user

  1. @Override
  2. public void setScrollLeft(Element elem, int left) {
  3. if (!isGecko19() && isRTL(elem)) {
  4. left += elem.getScrollWidth() - elem.getClientWidth();
  5. }
  6. super.setScrollLeft(elem, left);
  7. }

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

  1. public int getWidth(Element e) {
  2. fixInlineElement(e);
  3. return (int) (e.getClientWidth() - num(curCSS(e, "paddingLeft", true)) - num(curCSS(e,
  4. "paddingRight", true)));
  5. }

代码示例来源:origin: net.wetheinter/gwt-user

  1. @Override
  2. public int getScrollLeft(Element elem) {
  3. if (!elem.hasTagName(BodyElement.TAG) && isRTL(elem)) {
  4. return super.getScrollLeft(elem)
  5. - (elem.getScrollWidth() - elem.getClientWidth());
  6. }
  7. return super.getScrollLeft(elem);
  8. }

代码示例来源:origin: playn/playn

  1. @Override public IDimension screenSize () {
  2. // TODO: inverse scale?
  3. screenSize.width = Document.get().getDocumentElement().getClientWidth();
  4. screenSize.height = Document.get().getDocumentElement().getClientHeight();
  5. return screenSize;
  6. }

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

  1. @Override
  2. public int getScrollLeft(Element elem) {
  3. if (!elem.hasTagName(BodyElement.TAG) && isRTL(elem)) {
  4. return super.getScrollLeft(elem)
  5. - (elem.getScrollWidth() - elem.getClientWidth());
  6. }
  7. return super.getScrollLeft(elem);
  8. }

相关文章

Element类方法