diff --git a/libs/ngx-sonner/src/lib/toast.component.ts b/libs/ngx-sonner/src/lib/toast.component.ts index 599660f..93d0555 100644 --- a/libs/ngx-sonner/src/lib/toast.component.ts +++ b/libs/ngx-sonner/src/lib/toast.component.ts @@ -304,7 +304,9 @@ export class ToastComponent implements AfterViewInit, OnDestroy { effect(() => { const heightIndex = this.heightIndex(); const toastsHeightBefore = this.toastsHeightBefore(); - untracked(() => this.offset.set(heightIndex * GAP + toastsHeightBefore)); + untracked(() => + this.offset.set(Math.round(heightIndex * GAP + toastsHeightBefore)) + ); }); effect(() => { diff --git a/libs/ngx-sonner/src/tests/toaster.spec.ts b/libs/ngx-sonner/src/tests/toaster.spec.ts index b285b47..3464d67 100644 --- a/libs/ngx-sonner/src/tests/toaster.spec.ts +++ b/libs/ngx-sonner/src/tests/toaster.spec.ts @@ -44,17 +44,17 @@ describe('Toaster', () => { it('should show a toast with custom duration', async () => { const { user, trigger, queryByText, detectChanges } = await setup({ - cb: toast => toast('Hello world', { duration: 300 }), + cb: toast => toast('Custom duration', { duration: 300 }), }); - expect(queryByText('Hello world')).toBeNull(); + expect(queryByText('Custom duration')).toBeNull(); await user.click(trigger); - expect(queryByText('Hello world')).not.toBeNull(); + expect(queryByText('Custom duration')).not.toBeNull(); await sleep(500); detectChanges(); - expect(queryByText('Hello world')).toBeNull(); + expect(queryByText('Custom duration')).toBeNull(); }); it('should reset duration on a toast update', async () => {