6 changed files with 50 additions and 11 deletions
-
7css/main.css
-
5cube.html
-
5index.html
-
34js/parallax.js
-
5square.html
-
5texture.html
@ -0,0 +1,34 @@ |
|||
/* |
|||
* 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; |
|||
|
|||
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); |
|||
} |
|||
|
|||
function parallax() { |
|||
if (! document.documentElement) return; |
|||
|
|||
var v_scroll = |
|||
(document.documentElement |
|||
&& document.documentElement.scrollTop) |
|||
|| document.body.scrollTop; |
|||
|
|||
var h_scroll = |
|||
(document.documentElement |
|||
&& 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); |
|||
} |
|||
// vim: set ts=2 sw=2:
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue