|
|
|
@ -2,15 +2,38 @@ |
|
|
|
* OK, this is not really a parallax... I just want to see my content move |
|
|
|
* somewhat faster than the background... hey, ho, let's go |
|
|
|
*/ |
|
|
|
var background, content, content_top, content_left; |
|
|
|
var content, content_top, content_left, content_width, content_height; |
|
|
|
var width_delta, height_delta; |
|
|
|
|
|
|
|
function init() { |
|
|
|
content = document.getElementById("content"); |
|
|
|
content_top = parseFloat(window.getComputedStyle(content).top); |
|
|
|
content_left = parseFloat(window.getComputedStyle(content).left); |
|
|
|
background = document.getElementById("background"); |
|
|
|
background_top = parseFloat(window.getComputedStyle(background).top); |
|
|
|
background_left = parseFloat(window.getComputedStyle(background).left); |
|
|
|
content_width = parseFloat(window.getComputedStyle(content).width); |
|
|
|
content_height = parseFloat(window.getComputedStyle(content).height); |
|
|
|
|
|
|
|
var body = document.body, |
|
|
|
html = document.documentElement; |
|
|
|
|
|
|
|
var doc = Math.max( |
|
|
|
body.scrollHeight, |
|
|
|
body.offsetHeight, |
|
|
|
html.clientHeight, |
|
|
|
html.scrollHeight, |
|
|
|
html.offsetHeight); |
|
|
|
|
|
|
|
height_delta = (doc-window.innerHeight)/2; |
|
|
|
|
|
|
|
doc = Math.max( |
|
|
|
body.scrollWidth, |
|
|
|
body.offsetWidth, |
|
|
|
html.clientWidth, |
|
|
|
html.scrollWidth, |
|
|
|
html.offsetWidth); |
|
|
|
|
|
|
|
width_delta = (doc-window.innerWidth)/2; |
|
|
|
|
|
|
|
window.scrollTo(width_delta, height_delta); |
|
|
|
} |
|
|
|
|
|
|
|
function parallax() { |
|
|
|
@ -26,9 +49,7 @@ function parallax() { |
|
|
|
&& document.documentElement.scrollLeft) |
|
|
|
|| document.body.scrollLeft; |
|
|
|
|
|
|
|
background.style.top = background_top + Math.round(v_scroll/2); |
|
|
|
background.style.left = background_left + Math.round(h_scroll/2); |
|
|
|
content.style.top = content_top + Math.round(v_scroll/3.0); |
|
|
|
content.style.left = content_left + Math.round(h_scroll/3.0); |
|
|
|
content.style.left = content_left - ((h_scroll - width_delta)/16); |
|
|
|
content.style.top = content_top - ((v_scroll - height_delta)/16); |
|
|
|
} |
|
|
|
// vim: set ts=2 sw=2:
|