use of elemental2.dom.DOMRect in project kie-wb-common by kiegroup.
the class StructureTypesTooltipView method isTooltipOverflowing.
private boolean isTooltipOverflowing() {
final DOMRect dataTypesListRect = getListItems().getBoundingClientRect();
final DOMRect tooltipRect = tooltip.getBoundingClientRect();
return tooltipRect.y + tooltipRect.height > dataTypesListRect.y + dataTypesListRect.height;
}
use of elemental2.dom.DOMRect in project kie-wb-common by kiegroup.
the class DNDListComponentViewTest method testGetNewDraggingYPosition.
@Test
public void testGetNewDraggingYPosition() {
final MouseEvent event = mock(MouseEvent.class);
final HTMLElement draggingElement = mock(HTMLElement.class);
final DOMRect rect = mock(DOMRect.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);
}
use of elemental2.dom.DOMRect in project kie-wb-common by kiegroup.
the class DNDListComponentViewTest method testGetNewDraggingYPositionWhenNewYPositionIsGreaterThanMax.
@Test
public void testGetNewDraggingYPositionWhenNewYPositionIsGreaterThanMax() {
final MouseEvent event = mock(MouseEvent.class);
final HTMLElement draggingElement = mock(HTMLElement.class);
final DOMRect rect = mock(DOMRect.class);
event.y = 1000;
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 = 325;
assertEquals(expectedYPosition, actualYPosition);
}
use of elemental2.dom.DOMRect in project kie-wb-common by kiegroup.
the class StructureTypesTooltipViewTest method testUpdateTooltipPosition.
@Test
public void testUpdateTooltipPosition() {
final HTMLElement refElement = mock(HTMLElement.class);
final DOMRect domRect = mock(DOMRect.class);
domRect.x = 2;
domRect.y = 4;
domRect.width = 8;
when(refElement.getBoundingClientRect()).thenReturn(domRect);
view.updateTooltipPosition(refElement);
assertEquals("4.0px", tooltip.style.top);
assertEquals("30.0px", tooltip.style.left);
}
use of elemental2.dom.DOMRect in project kie-wb-common by kiegroup.
the class StructureTypesTooltipViewTest method testUpdateTooltipClassWhenItsOverflowing.
@Test
public void testUpdateTooltipClassWhenItsOverflowing() {
final HTMLElement listItems = mock(HTMLElement.class);
final DOMRect dataTypesListRect = mock(DOMRect.class);
final DOMRect tooltipRect = mock(DOMRect.class);
when(presenter.getListItems()).thenReturn(listItems);
when(listItems.getBoundingClientRect()).thenReturn(dataTypesListRect);
when(tooltip.getBoundingClientRect()).thenReturn(tooltipRect);
tooltipRect.y = 150;
tooltipRect.height = 100;
dataTypesListRect.y = 100;
dataTypesListRect.height = 100;
view.updateTooltipClass();
verify(tooltip.classList).toggle("overflow", true);
}
Aggregations