Skip to content
Snippets Groups Projects
Commit b4727187 authored by Thomas Hackl's avatar Thomas Hackl
Browse files

Resolve "Barrierefreiheit: "Back to top" ist nicht per Tabulator erreichbar"

Closes #3941

Merge request studip/studip!2800
parent 7336424c
No related branches found
No related tags found
No related merge requests found
...@@ -4,9 +4,9 @@ let fold; ...@@ -4,9 +4,9 @@ let fold;
let was_below_the_fold = false; let was_below_the_fold = false;
const back_to_top = function(scrolltop) { const back_to_top = function(scrolltop) {
var is_below_the_fold = scrolltop > fold; let is_below_the_fold = scrolltop > fold;
if (is_below_the_fold !== was_below_the_fold) { if (is_below_the_fold !== was_below_the_fold) {
$('#scroll-to-top').toggleClass('hide', !is_below_the_fold); document.getElementById('scroll-to-top').classList.toggle('hide', !is_below_the_fold);
was_below_the_fold = is_below_the_fold; was_below_the_fold = is_below_the_fold;
} }
}; };
...@@ -23,15 +23,21 @@ const ScrollToTop = { ...@@ -23,15 +23,21 @@ const ScrollToTop = {
}, },
disable() { disable() {
Scroll.removeHandler('header'); Scroll.removeHandler('header');
$('#scroll-to-top').addClass('hide'); document.getElementById('scroll-to-top').classList.add('hide');
}, },
moveBack() { moveBack() {
$('#scroll-to-top').on('click', function(e) { document.getElementById('scroll-to-top').addEventListener('click', (evt) => {
$('html, body').stop().animate({ evt.preventDefault();
scrollTop: (0) this.toTop();
}, 1000, 'easeInOutExpo');
e.preventDefault();
}); });
document.getElementById('scroll-to-top').addEventListener('keypress', (evt) => {
if (evt.code === 'Space') {
this.toTop();
}
});
},
toTop() {
window.scroll({top: 0, left: 0, behavior: 'smooth'});
} }
}; };
......
...@@ -96,7 +96,7 @@ $lang_attr = str_replace('_', '-', $_SESSION['_language']); ...@@ -96,7 +96,7 @@ $lang_attr = str_replace('_', '-', $_SESSION['_language']);
</main> </main>
<!-- End main content --> <!-- End main content -->
<a id="scroll-to-top" class="hide"> <a id="scroll-to-top" class="hide" tabindex="0" title="<?= _('Zurück zum Seitenanfang') ?>">
<?= Icon::create('arr_1up', 'info_alt')->asImg(24, ['class' => '']) ?> <?= Icon::create('arr_1up', 'info_alt')->asImg(24, ['class' => '']) ?>
</a> </a>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment