summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/abmahn.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/js/abmahn.js b/js/abmahn.js
index 6b26e0b..af8f000 100644
--- a/js/abmahn.js
+++ b/js/abmahn.js
@@ -12,8 +12,23 @@ function setText(input, text) {
12 document.getElementById(input).value = text; 12 document.getElementById(input).value = text;
13} 13}
14 14
15function scrollTo(element, to, duration) {
16 if (duration <= 0) return;
17 var difference = to - element.scrollTop;
18 var perTick = difference / duration * 2;
19
20 setTimeout(function() {
21 element.scrollTop = element.scrollTop + perTick;
22 scrollTo(element, to, duration - 2);
23 }, 10);
24}
25
15function scroll(id) { 26function scroll(id) {
16 document.getElementById(id).scrollIntoView(); 27 // document.getElementById(id).scrollIntoView();
28 var el = document.getElementById(id);
29 var rect = el.getBoundingClientRect();
30 var top = rect.bottom + window.pageYOffset - el.ownerDocument.documentElement.clientTop;
31 scrollTo( document.body, top, 100 );
17} 32}
18 33
19function setClass(id, classes) { 34function setClass(id, classes) {
@@ -21,7 +36,7 @@ function setClass(id, classes) {
21} 36}
22 37
23function step0_cancel() { setClass('wrapper', 'stepcancel'); } 38function step0_cancel() { setClass('wrapper', 'stepcancel'); }
24function step0_done() { setClass('wrapper', 'step1'); scroll('head1'); } 39function step0_done() { setClass('wrapper', 'step1'); scrollTo(document.body, 0, 100); }
25function step1_done() { setClass('wrapper', 'step2'); scroll('head1'); } 40function step1_done() { setClass('wrapper', 'step2'); scroll('head1'); }
26function step2_done() { setClass('wrapper', 'step3'); scroll('head2'); } 41function step2_done() { setClass('wrapper', 'step3'); scroll('head2'); }
27function step3_done() { setClass('wrapper', 'step4'); scroll('head3'); } 42function step3_done() { setClass('wrapper', 'step4'); scroll('head3'); }