-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: do not allow fab to overlap footer
- Loading branch information
1 parent
9993ec0
commit 343ee3a
Showing
4 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/app/shared/components/new-event-button/new-event-button.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Directive, ElementRef, HostBinding, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core'; | ||
import { isPlatformBrowser } from '@angular/common'; | ||
|
||
@Directive({ | ||
selector: '[fabPosition]', | ||
}) | ||
export class FabPositionDirective implements OnInit, OnDestroy { | ||
@HostBinding('style.bottom') setBottom?: string; | ||
|
||
constructor( | ||
private el: ElementRef, | ||
@Inject(PLATFORM_ID) private platformId: any, | ||
) { | ||
} | ||
|
||
ngOnInit() { | ||
if (isPlatformBrowser(this.platformId)) { | ||
const that = this; | ||
window.addEventListener('scroll', () => this._checkScroll()); | ||
const observer = new MutationObserver(function (mutationsList, observer) { | ||
for (let mutation of mutationsList) { | ||
if (mutation.type === "childList") { | ||
that._checkScroll(); | ||
break; | ||
} | ||
} | ||
}); | ||
observer.observe(document.body, {childList: true, subtree: true}); | ||
|
||
this._checkScroll(); | ||
} | ||
} | ||
|
||
ngOnDestroy() { | ||
if (isPlatformBrowser(this.platformId)) { | ||
window.removeEventListener('scroll', () => this._checkScroll()); | ||
} | ||
} | ||
|
||
private _checkScroll() { | ||
if (isPlatformBrowser(this.platformId)) { | ||
const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; | ||
const diff = document.documentElement.scrollHeight - window.innerHeight - window.scrollY; | ||
|
||
if (width < 768) { | ||
if (diff < 152) { | ||
this.setBottom = (152 - diff + 20) + 'px'; | ||
} else { | ||
this.setBottom = undefined; | ||
} | ||
} else { | ||
if (diff < 97) { | ||
this.setBottom = (97 - diff + 45) + 'px'; | ||
} else { | ||
this.setBottom = undefined; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters