-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding fade and scroll capabilities to focusMode
- Loading branch information
1 parent
0c9eb5e
commit b64b33b
Showing
6 changed files
with
44 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export type FocusModeFade = boolean | number; | ||
|
||
export type FocusMode = boolean | {isScroll?: boolean; fade?: FocusModeFade}; |
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
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 {FocusModeFade} from '../../../../types/focusMode'; | ||
|
||
export class FocusModeUtils { | ||
private static readonly DEFAULT_FADE_MS = 500; | ||
|
||
public static setFade(elementRef: HTMLElement, fade: FocusModeFade) { | ||
elementRef.style.transitionDuration = typeof fade === 'number' ? `${fade}ms` : `${FocusModeUtils.DEFAULT_FADE_MS}ms`; | ||
} | ||
|
||
public static async fadeAnimation(elementRef: HTMLElement, fade: FocusModeFade) { | ||
elementRef.style.opacity = '0'; | ||
const timeoutMS = typeof fade === 'number' ? fade : FocusModeUtils.DEFAULT_FADE_MS; | ||
await new Promise<void>((resolve) => { | ||
setTimeout(() => resolve(), timeoutMS); | ||
}); | ||
elementRef.style.opacity = '1'; | ||
} | ||
} |