diff --git a/sharedComponents/search-input/search-input.component.ts b/sharedComponents/search-input/search-input.component.ts index 705f91a6..af744175 100644 --- a/sharedComponents/search-input/search-input.component.ts +++ b/sharedComponents/search-input/search-input.component.ts @@ -18,7 +18,8 @@ import {ClickEvent} from "../../utils/click/click-outside-or-esc.directive"; selector: '[search-input]', template: `
-
+
-
+
@@ -43,6 +44,7 @@ import {ClickEvent} from "../../utils/click/click-outside-or-esc.directive"; export class SearchInputComponent implements OnInit { @Input() disabled: boolean = false; @Input() searchInputClass: string = 'inner'; + @Input() iconPosition: 'left' | 'right' = 'right'; @Input() searchControl: AbstractControl; @Input() value: string; @Output() valueChange = new EventEmitter(); diff --git a/utils/smooth-scroll.ts b/utils/smooth-scroll.ts index 9a34eace..78cb44e0 100644 --- a/utils/smooth-scroll.ts +++ b/utils/smooth-scroll.ts @@ -10,51 +10,55 @@ export class SmoothScroll { private readonly sub; private lastComponent; private currentComponent: string; + private extraOffset: number = 0; constructor(private router: Router) { if (typeof window !== "undefined") { this.sub = router.events.subscribe(event => { if (event instanceof ActivationStart) { + this.extraOffset = event.snapshot.data.extraOffset?event.snapshot.data.extraOffset:0; if(event.snapshot.component instanceof Type) { this.currentComponent = event.snapshot.component.name; } } else if (event instanceof NavigationEnd) { - if (this.interval) { - clearInterval(this.interval); - } - const fragment = router.parseUrl(router.url).fragment; - if (this.lastComponent !== this.currentComponent) { - window.scrollTo({top: 0}); - } - if (fragment) { - let i = 0; - this.interval = setInterval(() => { - i++; - const element = document.getElementById(fragment); - if (element) { - if (this.interval) { + if(!this.router.getCurrentNavigation().extras?.state?.disableScroll) { + if (this.interval) { + clearInterval(this.interval); + } + const fragment = router.parseUrl(router.url).fragment; + if (this.lastComponent !== this.currentComponent) { + window.scrollTo({top: 0}); + } + if (fragment) { + let i = 0; + this.interval = setInterval(() => { + i++; + const element = document.getElementById(fragment); + if (element) { + if (this.interval) { + clearInterval(this.interval); + } + const yOffset = -100 - this.extraOffset; + let position = 0; + let interval = setInterval(() => { + if (position !== element.getBoundingClientRect().top) { + position = element.getBoundingClientRect().top; + } else { + clearInterval(interval); + const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset; + window.scrollTo({top: y, behavior: 'smooth'}); + } + }, 50); + } + if (i > 4 && this.interval) { clearInterval(this.interval); } - const yOffset = -100; - let position = 0; - let interval = setInterval(() => { - if (position !== element.getBoundingClientRect().top) { - position = element.getBoundingClientRect().top; - } else { - clearInterval(interval); - const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset; - window.scrollTo({top: y, behavior: 'smooth'}); - } - }, 50); - } - if (i > 4 && this.interval) { - clearInterval(this.interval); - } - }, 100); - } else { - setTimeout( () => { - window.scrollTo({top: 0, behavior: 'smooth'}); - }, 0); + }, 100); + } else { + setTimeout( () => { + window.scrollTo({top: 0, behavior: 'smooth'}); + }, 0); + } } this.lastComponent = this.currentComponent; }