Skip to content

Commit c78075f

Browse files
fix(overlay): set specific offset values in setOffset function
1 parent 64b9203 commit c78075f

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

projects/igniteui-angular/src/lib/services/overlay/overlay.spec.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,6 @@ describe('igxOverlay', () => {
820820
const componentElementRect = componentElement.getBoundingClientRect();
821821
let overlayContentTransform = contentElement.style.transform;
822822
const firstTransform = 'translate(40px, 40px)';
823-
const secondTransform = 'translate(30px, 60px)';
824823

825824
expect(contentElementRect.top).toEqual(componentElementRect.top);
826825
expect(contentElementRect.left).toEqual(componentElementRect.left);
@@ -833,6 +832,7 @@ describe('igxOverlay', () => {
833832
const contentElementRectNew = contentElement.getBoundingClientRect();
834833
const componentElementRectNew = componentElement.getBoundingClientRect();
835834
overlayContentTransform = contentElement.style.transform;
835+
const secondTransform = 'translate(-10px, 20px)';
836836

837837
expect(contentElementRectNew.top).toEqual(componentElementRectNew.top);
838838
expect(contentElementRectNew.left).toEqual(componentElementRectNew.left);
@@ -847,6 +847,29 @@ describe('igxOverlay', () => {
847847
overlayInstance.detachAll();
848848
}));
849849

850+
it('Should set transformX and transformY correctly in setOffset method', fakeAsync(() => {
851+
const fixture = TestBed.createComponent(WidthTestOverlayComponent);
852+
const overlayInstance = fixture.componentInstance.overlay;
853+
854+
const id = fixture.componentInstance.overlay.attach(SimpleRefComponent);
855+
overlayInstance.show(id);
856+
fixture.detectChanges();
857+
tick();
858+
859+
// Set initial offset
860+
overlayInstance.setOffset(id, 20, 20);
861+
const overlayInfo = overlayInstance.getOverlayById(id);
862+
expect(overlayInfo.transformX).toEqual(20);
863+
expect(overlayInfo.transformY).toEqual(20);
864+
865+
// Set new offset
866+
overlayInstance.setOffset(id, 10, 10);
867+
expect(overlayInfo.transformX).toEqual(10);
868+
expect(overlayInfo.transformY).toEqual(10);
869+
870+
overlayInstance.detachAll();
871+
}));
872+
850873
it('#1690 - click on second filter does not close first one.', fakeAsync(() => {
851874
const fixture = TestBed.createComponent(TwoButtonsComponent);
852875
const button1 = fixture.nativeElement.getElementsByClassName('buttonOne')[0];

projects/igniteui-angular/src/lib/services/overlay/overlay.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ export class IgxOverlayService implements OnDestroy {
505505
return;
506506
}
507507

508-
info.transformX += deltaX;
509-
info.transformY += deltaY;
508+
info.transformX = deltaX;
509+
info.transformY = deltaY;
510510

511511
const transformX = info.transformX;
512512
const transformY = info.transformY;

0 commit comments

Comments
 (0)