diff options
Diffstat (limited to 'js/abmahn.js')
-rw-r--r-- | js/abmahn.js | 67 |
1 files changed, 38 insertions, 29 deletions
diff --git a/js/abmahn.js b/js/abmahn.js index 7237901..1b8d7c1 100644 --- a/js/abmahn.js +++ b/js/abmahn.js | |||
@@ -12,40 +12,49 @@ function setText(input, text) { | |||
12 | document.getElementById(input).value = text; | 12 | document.getElementById(input).value = text; |
13 | } | 13 | } |
14 | 14 | ||
15 | function scrollTo(to, duration) { | ||
16 | if (document.body.scrollTop == to) return; | ||
17 | var diff = to - document.body.scrollTop; | ||
18 | var scrollStep = Math.PI / (duration / 10); | ||
19 | var count = 0, currPos; | ||
20 | start = document.body.scrollTop; | ||
21 | scrollInterval = setInterval(function(){ | ||
22 | if (document.body.scrollTop != to) { | ||
23 | count = count + 1; | ||
24 | currPos = start + diff * (0.5 - 0.5 * Math.cos(count * scrollStep)); | ||
25 | document.body.scrollTop = currPos; | ||
26 | } | ||
27 | else { clearInterval(scrollInterval); } | ||
28 | },10); | ||
29 | } | ||
30 | |||
31 | |||
32 | function scroll(id) { | ||
33 | // document.getElementById(id).scrollIntoView(); | ||
34 | scrollTo( document.getElementById(id).offsetTop, 500 ); | ||
35 | } | ||
36 | |||
37 | function setClass(id, classes) { | 15 | function setClass(id, classes) { |
38 | document.getElementById(id).className = classes; | 16 | document.getElementById(id).className = classes; |
39 | } | 17 | } |
40 | 18 | ||
19 | function scrollTo(el) { | ||
20 | if(document.querySelectorAll === void 0 || window.pageYOffset === void 0 || history.pushState === void 0) { | ||
21 | el.scrollIntoView(); | ||
22 | return; | ||
23 | } | ||
24 | var duration = 500; | ||
25 | var start = window.pageYOffset; | ||
26 | var end = document.getElementById(el).getBoundingClientRect().top + window.pageYOffset; | ||
27 | |||
28 | var clock = Date.now(); | ||
29 | var requestAnimationFrame = window.requestAnimationFrame || | ||
30 | window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || | ||
31 | function(fn){window.setTimeout(fn, 15);}; | ||
32 | |||
33 | var step = function(){ | ||
34 | var elapsed = Date.now() - clock; | ||
35 | var t = elapsed / duration; | ||
36 | if (elapsed > duration) | ||
37 | var pos =end; | ||
38 | else | ||
39 | var pos = start + (end - start) * (t<.5 ? 4*t*t*t : (t-1)*(2*t-2)*(2*t-2)+1); | ||
40 | |||
41 | window.scroll(window.pageXOffset, pos); | ||
42 | |||
43 | if (elapsed <= duration) { | ||
44 | requestAnimationFrame(step); | ||
45 | } | ||
46 | } | ||
47 | step(); | ||
48 | } | ||
49 | |||
41 | function step0_cancel() { setClass('wrapper', 'stepcancel'); } | 50 | function step0_cancel() { setClass('wrapper', 'stepcancel'); } |
42 | function step0_done() { setClass('wrapper', 'step1'); scrollTo(document.body, 0, 100); } | 51 | function step0_done() { setClass('wrapper', 'step1'); scrollTo('head1'); } |
43 | function step1_done() { setClass('wrapper', 'step2'); scroll('head1'); } | 52 | function step1_done() { setClass('wrapper', 'step2'); scrollTo('head1'); } |
44 | function step2_done() { setClass('wrapper', 'step3'); scroll('head2'); } | 53 | function step2_done() { setClass('wrapper', 'step3'); scrollTo('head2'); } |
45 | function step3_done() { setClass('wrapper', 'step4'); scroll('head3'); } | 54 | function step3_done() { setClass('wrapper', 'step4'); scrollTo('head3'); } |
46 | function step4_done() { setClass('wrapper', 'step5'); scroll('head4'); } | 55 | function step4_done() { setClass('wrapper', 'step5'); scrollTo('head4'); } |
47 | function step5_done() { setClass('wrapper', 'step6'); scroll('head5'); } | 56 | function step5_done() { setClass('wrapper', 'step6'); scrollTo('head5'); } |
48 | function step6_done() { setClass('wrapper', 'step7'); scroll('head6'); } | 57 | function step6_done() { setClass('wrapper', 'step7'); scrollTo('head6'); } |
49 | 58 | ||
50 | function waldorff() { | 59 | function waldorff() { |
51 | setText('abmahnender_kanzlei', 'Waldorff & Frommer RAe'); | 60 | setText('abmahnender_kanzlei', 'Waldorff & Frommer RAe'); |