Browse Source

Fix Toaster padding-right on mobile

pull/14735/head
Mahmut Gundogdu 4 years ago
parent
commit
5f6c5e01ea
  1. 5
      npm/ng-packs/packages/theme-shared/src/lib/components/toast-container/toast-container.component.scss
  2. 19
      npm/ng-packs/packages/theme-shared/src/lib/components/toast-container/toast-container.component.ts

5
npm/ng-packs/packages/theme-shared/src/lib/components/toast-container/toast-container.component.scss

@ -11,3 +11,8 @@
flex-direction: column-reverse;
}
}
@media only screen and (max-width: 768px) {
.abp-toast-container {
min-width: 100%;
}
}

19
npm/ng-packs/packages/theme-shared/src/lib/components/toast-container/toast-container.component.ts

@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, HostListener, Input, OnInit } from '@angular/core';
import { ReplaySubject } from 'rxjs';
import { toastInOut } from '../../animations/toast.animations';
import { Toaster } from '../../models/toaster';
@ -21,6 +21,8 @@ export class ToastContainerComponent implements OnInit {
@Input()
right = '30px';
defaultRight = '30px';
defaultMobileRight = '0';
@Input()
bottom = '30px';
@ -28,10 +30,13 @@ export class ToastContainerComponent implements OnInit {
@Input()
left?: string;
@Input()
toastKey?: string;
screenWidth: number;
ngOnInit() {
this.setDefaultRight();
this.toasts$.subscribe(toasts => {
this.toasts = this.toastKey
? toasts.filter(t => {
@ -41,6 +46,18 @@ export class ToastContainerComponent implements OnInit {
});
}
@HostListener('window:resize', ['$event'])
onWindowResize() {
this.setDefaultRight();
}
setDefaultRight() {
const screenWidth = window.innerWidth;
if(screenWidth < 768 && this.right == this.defaultRight) {
this.right = this.defaultMobileRight;
}
}
trackByFunc(index: number, toast: Toaster.Toast) {
if (!toast) return null;
return toast.options?.id;

Loading…
Cancel
Save