Package com.google.gwt.query.client.GQuery

Examples of com.google.gwt.query.client.GQuery.Offset


  @Override
  public Offset calculateRelativeHelperOffset(Element element,
                                              DraggableHandler draggableHandler) {
    // With IE8 we have to remove borderTop and borderLeft of the offsetParent (included in offsetLeft and offsetTop of the element)
    Offset relativeHelperOffset = super.calculateRelativeHelperOffset(element, draggableHandler);
    Element offsetParent = GQuery.$(element).offsetParent().get(0);

    int offsetParentBorderLeft = (int) GQuery.$(offsetParent).cur("borderLeftWidth", true);
    int offsetParentBorderTop = (int) GQuery.$(offsetParent).cur("borderTopWidth", true);

    return new Offset(relativeHelperOffset.left - offsetParentBorderLeft, relativeHelperOffset.top - offsetParentBorderTop);
  }
View Full Code Here


  @Override
  public Offset calculateRelativeHelperOffset(Element element,
                                              DraggableHandler draggableHandler) {
    // With Opera we have to remove borderTop and borderLeft of the offsetParent (included in offsetLeft and offsetTop of the element)
    Offset relativeHelperOffset = super.calculateRelativeHelperOffset(element, draggableHandler);
    Element offsetParent = GQuery.$(element).offsetParent().get(0);

    int offsetParentBorderLeft = (int) GQuery.$(offsetParent).cur("borderLeftWidth", true);
    int offsetParentBorderTop = (int) GQuery.$(offsetParent).cur("borderTopWidth", true);

    return new Offset(relativeHelperOffset.left - offsetParentBorderLeft, relativeHelperOffset.top - offsetParentBorderTop);
  }
View Full Code Here

                finalLeft = oi.left + oi.width;
                placementClass = style.right();
                break;
        }

        Offset additionalOffset = getAdditionalOffset();
        if (additionalOffset != null) {
            finalTop += additionalOffset.top;
            finalLeft += additionalOffset.left;
        }
View Full Code Here

    }

    private static class OffsetInfo {
        private static OffsetInfo from(GQuery element) {
            OffsetInfo oi = new OffsetInfo();
            Offset offset = element.offset();
            oi.left = offset.left;
            oi.top = offset.top;
            oi.width = element.get(0).getOffsetWidth();
            oi.height = element.get(0).getOffsetHeight();
View Full Code Here

  public void testOffset(){
    $(e).html(
        "<div id='id1' style='padding-left:10px; padding-top:20px;'><div id='id2'>Content 1</div></div>");

    Offset parentOffset = $("#id1", e).offset();

    GQuery g = $("#id2", e);
    Offset initialOffset = g.offset();

    assertEquals(10 + parentOffset.left, initialOffset.left);
    assertEquals(20 + parentOffset.top, initialOffset.top);

    g.offset(10, 0);

    Offset offset = g.offset();
    assertEquals(0, offset.left);
    assertEquals(10, offset.top);

    //css control
    String top = g.css("top", true);
View Full Code Here

    return g.css(k, String.valueOf(v));
  }

  @ExportInstanceMethod
  public static JavaScriptObject offset(GQuery instance) {
    Offset o = instance.offset();
    return Properties.create("left: " + o.left + ", top:" + o.top);
  }
View Full Code Here

    return Properties.create("left: " + o.left + ", top:" + o.top);
  }

  @ExportInstanceMethod
  public static GQuery offset(GQuery instance, JsCache o) {
    return instance.offset(new Offset(o.getInt("left"), o.getInt("top")));
  }
View Full Code Here

  public void testEffectsShouldBeQueued() {
    $(e).html("<p id='idtest'>Content 1</p></p>");

    final GQuery g = $("#idtest").css("position", "absolute");
    final Offset o = g.offset();

    final int duration = 1000;
    g.as(Effects).
        animate($$("left: '+=100'"), duration, EasingCurve.linear).
        animate($$("top: '+=100'"), duration, EasingCurve.linear).
        animate($$("left: '-=100'"), duration, EasingCurve.linear).
        animate($$("top: '-=100'"), duration, EasingCurve.linear);

    // Configure the max duration for this test
    delayTestFinish(duration * 4);

    // each timer calls the next one
    final Timer timer1 = new Timer() {
      public void run() {
        assertPosition(g, o.add(0, 99), o.add(0, 1));
        // Last timer should finish the test
        finishTest();
      }
    };
    final Timer timer2 = new Timer() {
      public void run() {
        assertPosition(g, o.add(99, 100), o.add(1, 100));
        timer1.schedule(duration);
      }
    };
    final Timer timer3 = new Timer() {
      public void run() {
        assertPosition(g, o.add(100, 1), o.add(100, 99));
        timer2.schedule(duration);
      }
    };
    final Timer timer4 = new Timer() {
      public void run() {
        assertPosition(g, o.add(1, 0), o.add(99, 0));
        timer3.schedule(duration);
      }
    };
    // Start the first timer
    timer4.schedule(duration/2);
View Full Code Here

                finalLeft = oi.left + oi.width;
                placementClass = style.right();
                break;
        }

        Offset additionalOffset = getAdditionalOffset();
        if (additionalOffset != null) {
            finalTop += additionalOffset.top;
            finalLeft += additionalOffset.left;
        }
View Full Code Here

    }

    private static class OffsetInfo {
        private static OffsetInfo from(GQuery element) {
            OffsetInfo oi = new OffsetInfo();
            Offset offset = element.offset();
            oi.left = offset.left;
            oi.top = offset.top;
            oi.width = element.get(0).getOffsetWidth();
            oi.height = element.get(0).getOffsetHeight();
View Full Code Here

TOP

Related Classes of com.google.gwt.query.client.GQuery.Offset

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.