/*
Paralex scrolling
document.body.scrollTop : to find out how much the scrolling was done for eg. 0 if its at top or 256 at lower.
data-my-stuff="foobar inJS we will write document.body.style.myStuff
everylastdrop.co.uk
*/
window.addEventListener("scroll", function(){
var st = document.body.scrollTop;
var sun = document.querySelector(".circle");
document.body.style.backgroundPosition =
100 + Math.sin(st/50)*20 +"px 0," +
"0 " + Math.floor(100 - 1.5*st) + "px, " + "250px " + Math.floor(200 - 4*st) + "px";
if(st > sun.offsetTop-200){
sun.style.marginleft = st - 700 + "px";
}
//console.log(document.querySelector(".circle").offsetTop);
});
document.querySelector(".circle").addEventListener("mouseenter" , function () {
this.classList.toggle("setting");
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.