您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

HorizontalDropLocation.java 753B

123456789101112131415161718192021222324252627
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client.ui.dd;
  5. import com.google.gwt.user.client.Element;
  6. public enum HorizontalDropLocation {
  7. LEFT, RIGHT, CENTER;
  8. public static HorizontalDropLocation get(Element element, int clientX,
  9. double leftRightRatio) {
  10. int absoluteLeft = element.getAbsoluteLeft();
  11. int offsetWidth = element.getOffsetWidth();
  12. int fromTop = clientX - absoluteLeft;
  13. float percentageFromTop = (fromTop / (float) offsetWidth);
  14. if (percentageFromTop < leftRightRatio) {
  15. return LEFT;
  16. } else if (percentageFromTop > 1 - leftRightRatio) {
  17. return RIGHT;
  18. } else {
  19. return CENTER;
  20. }
  21. }
  22. }