@Test public void testUpdateDependentsPosition() { final HTMLElement draggingElement = mock(HTMLElement.class); final HTMLElement dependentElement0 = mock(HTMLElement.class); final HTMLElement dependentElement1 = mock(HTMLElement.class); final HTMLElement dependentElement2 = mock(HTMLElement.class); final List<HTMLElement> dependentElements = asList(dependentElement0, dependentElement1, dependentElement2); draggingElement.style = mock(CSSStyleDeclaration.class); dependentElement0.style = mock(CSSStyleDeclaration.class); dependentElement1.style = mock(CSSStyleDeclaration.class); dependentElement2.style = mock(CSSStyleDeclaration.class); when(presenter.getItemHeight()).thenReturn(50); when(presenter.getIndentationSize()).thenReturn(50); when(draggingElement.getAttribute(DATA_X_POSITION)).thenReturn("0"); when(dependentElement0.getAttribute(DATA_X_POSITION)).thenReturn("1"); when(dependentElement1.getAttribute(DATA_X_POSITION)).thenReturn("1"); when(dependentElement2.getAttribute(DATA_X_POSITION)).thenReturn("2"); when(draggingElement.style.getPropertyValue("top")).thenReturn("50px"); when(draggingElement.style.getPropertyValue("width")).thenReturn("calc(100% - 100px)"); doReturn(draggingElement).when(view).getDragging(); doReturn(dependentElements).when(view).getDependentElements(); view.updateDependentsPosition(); verify(dependentElement0.style).setProperty("top", "100px"); verify(dependentElement1.style).setProperty("top", "150px"); verify(dependentElement2.style).setProperty("top", "200px"); verify(dependentElement0.style).setProperty("width", "calc(100% - 100px)"); verify(dependentElement1.style).setProperty("width", "calc(100% - 100px)"); verify(dependentElement2.style).setProperty("width", "calc(100% - 100px)"); }
void updateDependentsPosition() { final List<HTMLElement> elements = Optional.ofNullable(getDependentElements()).orElse(emptyList()); for (int i = 0; i < elements.size(); i++) { final HTMLElement dependent = elements.get(i); final int dependentTop = getCSSTop(getDragging()) + (getItemHeight() * (i + 1)); setCSSTop(dependent, dependentTop); setCSSWidth(dependent, getCSSWidth(getDragging())); } }
DNDListComponentView implements DNDListComponent.View { void updateDependentsPosition() { final List<HTMLElement> elements = Optional.ofNullable(getDependentElements()).orElse(emptyList()); for (int i = 0; i < elements.size(); i++) { final HTMLElement dependent = elements.get(i); final int dependentTop = getCSSTop(getDragging()) + (getItemHeight() * (i + 1)); setCSSTop(dependent, dependentTop); setCSSWidth(dependent, getCSSWidth(getDragging())); } } }
DNDListComponentView implements DNDListComponent.View { void updateDependentsPosition() { final List<HTMLElement> elements = Optional.ofNullable(getDependentElements()).orElse(emptyList()); for (int i = 0; i < elements.size(); i++) { final HTMLElement dependent = elements.get(i); final int dependentTop = getCSSTop(getDragging()) + (getItemHeight() * (i + 1)); setCSSTop(dependent, dependentTop); setCSSWidth(dependent, getCSSWidth(getDragging())); } } @Inject  DNDListComponentView(final HTMLDivElement dragArea); }
DNDListComponentView implements DNDListComponent.View { void updateDependentsPosition() { final List<HTMLElement> elements = Optional.ofNullable(getDependentElements()).orElse(emptyList()); for (int i = 0; i < elements.size(); i++) { final HTMLElement dependent = elements.get(i); final int dependentTop = getCSSTop(getDragging()) + (getItemHeight() * (i + 1)); setCSSTop(dependent, dependentTop); setCSSWidth(dependent, getCSSWidth(getDragging())); } } @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 { void updateDependentsPosition() { final List<HTMLElement> elements = Optional.ofNullable(getDependentElements()).orElse(emptyList()); for (int i = 0; i < elements.size(); i++) { final HTMLElement dependent = elements.get(i); final int dependentTop = getCSSTop(getDragging()) + (getItemHeight() * (i + 1)); setCSSTop(dependent, dependentTop); setCSSWidth(dependent, getCSSWidth(getDragging())); } } @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();  }