@Test public void testGetNewDraggingYPosition() { final MouseEvent event = mock(MouseEvent.class); final HTMLElement draggingElement = mock(HTMLElement.class); final ClientRect rect = mock(ClientRect.class); event.y = 100; rect.top = 25; draggingElement.style = mock(CSSStyleDeclaration.class); dragArea.offsetHeight = 300; when(presenter.getItemHeight()).thenReturn(50); when(dragArea.getBoundingClientRect()).thenReturn(rect); doReturn(draggingElement).when(view).getDragging(); final int actualYPosition = view.getNewDraggingYPosition(event); final int expectedYPosition = 50; assertEquals(expectedYPosition, actualYPosition); }
int getNewDraggingYPosition(final Event event) { final Double absoluteMouseY = getAbsoluteMouseY(event); final Double newYPosition = absoluteMouseY - (getItemHeight() / 2d); final Double maxYPosition = getDragAreaY() + getDragArea().offsetHeight; if (newYPosition > maxYPosition) { return maxYPosition.intValue(); } return newYPosition.intValue(); }
DNDListComponentView implements DNDListComponent.View { int getNewDraggingYPosition(final Event event) { final Double absoluteMouseY = getAbsoluteMouseY(event); final Double newYPosition = absoluteMouseY - (getItemHeight() / 2d); final Double maxYPosition = getDragAreaY() + getDragArea().offsetHeight; if (newYPosition > maxYPosition) { return maxYPosition.intValue(); } return newYPosition.intValue(); } }
DNDListComponentView implements DNDListComponent.View { int getNewDraggingYPosition(final Event event) { final Double absoluteMouseY = getAbsoluteMouseY(event); final Double newYPosition = absoluteMouseY - (getItemHeight() / 2d); final Double maxYPosition = getDragAreaY() + getDragArea().offsetHeight; if (newYPosition > maxYPosition) { return maxYPosition.intValue(); } return newYPosition.intValue(); } @Inject  DNDListComponentView(final HTMLDivElement dragArea); }
DNDListComponentView implements DNDListComponent.View { int getNewDraggingYPosition(final Event event) { final Double absoluteMouseY = getAbsoluteMouseY(event); final Double newYPosition = absoluteMouseY - (getItemHeight() / 2d); final Double maxYPosition = getDragAreaY() + getDragArea().offsetHeight; if (newYPosition > maxYPosition) { return maxYPosition.intValue(); } return newYPosition.intValue(); } @Inject  DNDListComponentView(final HTMLDivElement dragArea); @Override void init(final DNDListComponent presenter); @Override HTMLElement registerItem(final HTMLElement htmlElement); @Override void refreshItemsPosition(); @Override void refreshItemsHTML(); @Override void consolidateHierarchicalLevel(final boolean isElementsDraggedByUser); @Override void consolidateYPosition(); @Override void clear(); @Override Optional<HTMLElement> getPreviousElement(final Element reference); @Override void refreshDragAreaSize(); @Override HTMLDivElement getDragArea(); }
DNDListComponentView implements DNDListComponent.View { int getNewDraggingYPosition(final Event event) { final Double absoluteMouseY = getAbsoluteMouseY(event); final Double newYPosition = absoluteMouseY - (getItemHeight() / 2d); final Double maxYPosition = getDragAreaY() + getDragArea().offsetHeight; if (newYPosition > maxYPosition) { return maxYPosition.intValue(); } return newYPosition.intValue(); } @Inject  DNDListComponentView(final HTMLDivElement dragArea); @Override void init(final DNDListComponent presenter); @Override HTMLElement registerItem(final HTMLElement htmlElement); @Override void refreshItemsPosition(); @Override void refreshItemsHTML(); @Override void consolidateHierarchicalLevel(final boolean isElementsDraggedByUser); @Override void consolidateYPosition(); @Override void clear(); @Override Optional<HTMLElement> getPreviousElement(final Element reference); @Override void refreshDragAreaSize(); @Override HTMLDivElement getDragArea();  }