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

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


        + parentOffset.left
        * mod
        - ("fixed".equals(helperCssPosition) ? -helperScrollParent.scrollLeft()
        : scrollIsRootNode ? 0 : scroll.scrollLeft()) * mod;

    return new Offset(left, top);

  }
View Full Code Here


      helperOffsetParent = $(body);
    }

    setMarginCache(element);

    absPosition = new Offset(element.getAbsoluteLeft(),
        element.getAbsoluteTop());

    offset = new Offset(absPosition.left - margin.left, absPosition.top
        - margin.top);

    offsetClick = new Offset(e.pageX() - offset.left, e.pageY() - offset.top);

    parentOffset = calculateParentOffset(element);
    relativeOffset = calculateRelativeHelperOffset(element);

    originalEventPageX = e.pageX();
    originalEventPageY = e.pageY();

    position = calculateOriginalPosition(element, e);
    originalPosition = new Offset(position.left, position.top);

    if (options.getCursorAt() != null) {
      adjustOffsetFromHelper(options.getCursorAt());
    }
    calculateContainment();
View Full Code Here

  public void setMarginCache(Element element) {
    int marginLeft = (int) GQuery.$(element).cur("marginLeft", true);
    int marginTop = (int) GQuery.$(element).cur("marginTop", true);

    margin = new Offset(marginLeft, marginTop);

  }
View Full Code Here

        (!"hidden".equals($containement.css("overflow"))));

  }

  private Offset calculateParentOffset(Element element) {
    Offset position = helperOffsetParent.offset();

    if ("absolute".equals(helperCssPosition)
        && isOffsetParentIncludedInScrollParent()) {
      position = position.add(helperScrollParent.scrollLeft(),
          helperScrollParent.scrollTop());
    }

    if (impl.resetParentOffsetPosition(helperOffsetParent)) {
      position.left = 0;
      position.top = 0;
    }

    position = position.add((int) helperOffsetParent.cur("borderLeftWidth",
        true), (int) helperOffsetParent.cur("borderTopWidth", true));

    return new Offset(position.left, position.top);

  }
View Full Code Here

   */
  private Offset calculateRelativeHelperOffset(Element element) {
    if ("relative".equals(helperCssPosition)) {
      return impl.calculateRelativeHelperOffset(element, this);
    }
    return new Offset(0, 0);
  }
View Full Code Here

        - offsetClick.left
        - relativeOffset.left
        - parentOffset.left
        + ("fixed".equals(helperCssPosition) ? -helperScrollParent.scrollLeft()
        : scrollIsRootNode ? 0 : scroll.scrollLeft());
    return new Offset(left, top);
  }
View Full Code Here

         * snapElement.setSnapping(false); continue; }
         */

        continue;
      }
      Offset newTopDimension = null;
      Offset newLeftDimension = null;
      if (SnapMode.INNER != snapMode) {
        boolean snapTop = Math.abs(snapElementTop - helperBottom) <= snapTolerance;
        boolean snapBottom = Math.abs(snapElementBottom - helperTop) <= snapTolerance;
        boolean snapLeft = Math.abs(snapElementLeft - helperRight) <= snapTolerance;
        boolean snapRight = Math.abs(snapElementRight - helperLeft) <= snapTolerance;

        if (snapTop) {
          newTopDimension = handler.convertPositionTo(false,
              new Offset(0, snapElementTop
                  - handler.getHelperDimension().getHeight()));
        } else if (snapBottom) {
          newTopDimension = handler.convertPositionTo(false,
              new Offset(0, snapElementBottom));
        }

        if (snapLeft) {
          newLeftDimension = handler.convertPositionTo(false,
              new Offset(snapElementLeft
                  - handler.getHelperDimension().getWidth(), 0));
        } else if (snapRight) {
          newLeftDimension = handler.convertPositionTo(false,
              new Offset(snapElementRight, 0));
        }
      }

      if (SnapMode.OUTER != snapMode) {
        boolean snapTop = Math.abs(snapElementTop - helperTop) <= snapTolerance;
        boolean snapBottom = Math.abs(snapElementBottom - helperBottom) <= snapTolerance;
        boolean snapLeft = Math.abs(snapElementLeft - helperLeft) <= snapTolerance;
        boolean snapRight = Math.abs(snapElementRight - helperRight) <= snapTolerance;

        if (snapTop) {
          newTopDimension = handler.convertPositionTo(false,
              new Offset(0, snapElementTop));
        } else if (snapBottom) {
          newTopDimension = handler.convertPositionTo(false,
              new Offset(0, snapElementBottom
                  - handler.getHelperDimension().getHeight()));
        }

        if (snapLeft) {
          newLeftDimension = handler.convertPositionTo(false,
              new Offset(snapElementLeft, 0));
        } else if (snapRight) {
          newLeftDimension = handler.convertPositionTo(false,
              new Offset(snapElementRight
                  - handler.getHelperDimension().getWidth(), 0));
        }
      }

      if (newTopDimension != null) {
        int newTop = newTopDimension.top - handler.getMargin().top;
        int newLeft = handler.getPosition().left;
        handler.setPosition(new Offset(newLeft, newTop));

      }

      if (newLeftDimension != null) {
        int newTop = handler.getPosition().top;
        int newLeft = newLeftDimension.left
            - handler.getMargin().left;
        handler.setPosition(new Offset(newLeft, newTop));

      }

    }
  }
View Full Code Here

    GQuery $initialDraggable = $(initialDraggable);

    GroupingMode groupingMode = handler.getOptions().getGroupingMode();
    int groupSpacing = handler.getOptions().getGroupSpacing();

    Offset newPosition = null;

    switch (groupingMode) {
      case DOWN:
        HelperInfo lastDown = $initialDraggable.data(LAST_DOWN, HelperInfo.class);
        if (lastDown == null) {
          lastDown = new HelperInfo(initialDragHandler.getAbsolutePosition(),
              initialDragHandler.getHelper());
        }

        newPosition = lastDown.offset.add(0, lastDown.height + groupSpacing);
        HelperInfo newLastDown = new HelperInfo(newPosition, handler.getHelper());
        $initialDraggable.data(LAST_DOWN, newLastDown);

        break;

      case UP:
        HelperInfo lastUp = $initialDraggable.data(LAST_UP, HelperInfo.class);
        if (lastUp == null) {
          lastUp = new HelperInfo(initialDragHandler.getAbsolutePosition(),
              initialDragHandler.getHelper());
        }

        newPosition = lastUp.offset.add(0, -handler.getHelperDimension()
            .getHeight()
            - groupSpacing);
        HelperInfo newLastUp = new HelperInfo(newPosition, handler.getHelper());
        $initialDraggable.data(LAST_UP, newLastUp);
        break;
      case LEFT:
        HelperInfo lastLeft = $initialDraggable.data(LAST_LEFT, HelperInfo.class);
        if (lastLeft == null) {
          lastLeft = new HelperInfo(initialDragHandler.getAbsolutePosition(),
              initialDragHandler.getHelper());
        }

        newPosition = lastLeft.offset.add(-handler.getHelperDimension()
            .getWidth()
            - groupSpacing, 0);
        HelperInfo newLastLeft = new HelperInfo(newPosition, handler.getHelper());
        $initialDraggable.data(LAST_LEFT, newLastLeft);

        break;

      case RIGHT:
        HelperInfo lastRight = $initialDraggable.data(LAST_RIGHT,
            HelperInfo.class);
        if (lastRight == null) {
          lastRight = new HelperInfo(initialDragHandler.getAbsolutePosition(),
              initialDragHandler.getHelper());
        }

        newPosition = lastRight.offset.add(lastRight.width + groupSpacing, 0);
        HelperInfo newLastRight = new HelperInfo(newPosition, handler.getHelper());
        $initialDraggable.data(LAST_RIGHT, newLastRight);

        break;

      default:
        break;
    }

    if (newPosition != null) {

      Offset actualPosition = handler.getAbsolutePosition();
      Offset clickOffset = handler.getOffsetClick();
      Offset newClickOffset = clickOffset.add(actualPosition.left
          - newPosition.left, actualPosition.top - newPosition.top);
      handler.setOffsetClick(newClickOffset);
    }

  }
View Full Code Here

    if (scrollParentElement == null) {
      return;
    }

    AxisOption axis = options.getAxis();
    Offset overflowOffset = $(draggableElement).data(OVERFLOW_OFFSET_KEY,
        Offset.class);
    int scrollSensitivity = options.getScrollSensitivity();
    int scrollSpeed = options.getScrollSpeed();

    boolean scrolled = false;
View Full Code Here

    GQuery scrollParent = handler.getHelperScrollParent();
    Element scrollParentElement = scrollParent.get(0);
    if (scrollParentElement != null
        && scrollParentElement != $(GQuery.document).get(0)
        && !"html".equalsIgnoreCase(scrollParentElement.getTagName())) {
      Offset scrollParentOffset = scrollParent.offset();
      $(ctx.getDraggable()).data(OVERFLOW_OFFSET_KEY, scrollParentOffset);
    }
  }
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.