-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(posts): animate to deselected post on fab click
- Loading branch information
1 parent
f20147a
commit a11a95d
Showing
7 changed files
with
66 additions
and
22 deletions.
There are no files selected for viewing
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
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,18 @@ | ||
import { TestBed, inject } from '@angular/core/testing'; | ||
|
||
import { ScrollService } from './scroll.service'; | ||
|
||
describe('ScrollService', () => { | ||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
providers: [ScrollService] | ||
}); | ||
}); | ||
|
||
it( | ||
'should be created', | ||
inject([ScrollService], (service: ScrollService) => { | ||
expect(service).toBeTruthy(); | ||
}) | ||
); | ||
}); |
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,19 @@ | ||
import { ElementRef, Injectable } from '@angular/core'; | ||
|
||
const TOP_APP_TOOLBAR_OFFSET = 70; | ||
|
||
@Injectable() | ||
export class ScrollService { | ||
constructor() {} | ||
|
||
scrollToElementIfOffscreen(element: ElementRef) { | ||
const { top } = element.nativeElement.getBoundingClientRect(); | ||
if (top < TOP_APP_TOOLBAR_OFFSET || top > window.innerHeight) { | ||
element.nativeElement.scrollIntoView({ | ||
behavior: 'smooth', | ||
block: 'center', | ||
inline: 'center' | ||
}); | ||
} | ||
} | ||
} |
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
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