-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #333 from statikbe/KarelJanVanHaute/issue301
Block initial transitions
- Loading branch information
Showing
3 changed files
with
24 additions
and
8 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 |
---|---|---|
@@ -1,19 +1,32 @@ | ||
export class GeneralComponent { | ||
constructor() { | ||
const bodyElement = document.getElementsByTagName('BODY')[0] as HTMLBodyElement; | ||
bodyElement.classList.add('js-enabled'); | ||
const bodyElement = document.getElementsByTagName( | ||
"BODY" | ||
)[0] as HTMLBodyElement; | ||
bodyElement.classList.add("js-enabled"); | ||
this.addOutlineForTabbers(); | ||
|
||
const node = document.querySelector(".preload-transitions"); | ||
document.addEventListener("DOMContentLoaded", function () { | ||
node.classList.remove("preload-transitions"); | ||
}); | ||
if ( | ||
document.readyState === "interactive" || | ||
document.readyState === "complete" | ||
) { | ||
node.classList.remove("preload-transitions"); | ||
} | ||
} | ||
|
||
// This adds a class if the user is tabbing and thus using the keyboard, so the focus style will be visible. Otherwise if it's a clicker the focus is removed. | ||
private addOutlineForTabbers() { | ||
function handleFirstTab(e) { | ||
if (e.keyCode === 9) { | ||
// the "I am a keyboard user" key | ||
document.body.classList.add('user-is-tabbing'); | ||
window.removeEventListener('keydown', handleFirstTab); | ||
document.body.classList.add("user-is-tabbing"); | ||
window.removeEventListener("keydown", handleFirstTab); | ||
} | ||
} | ||
window.addEventListener('keydown', handleFirstTab); | ||
window.addEventListener("keydown", handleFirstTab); | ||
} | ||
} |
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