Skip to content

Instantly share code, notes, and snippets.

@williammalo williammalo/ forked from 140bytes/LICENSE.txt
Last active Oct 2, 2015

What would you like to do?

Add parallax scrolling to a page's background.

onscroll=function(){"0 "+pageYOffset>>1+"px"}
onscroll=function(){"0 "+pageYOffset>>1+"px"}
"name": "paralaxr",
"description": "Add parallax scrolling to a page's background.",
"keywords": [
<!DOCTYPE html>
<div>Expected value: <b>undefined</b></div>
<div>Actual value: <b id="ret"></b></div>
// write a small example that shows off the API for your example
// and tests it in one fell swoop.
var myFunction = function(){ /* the code here should be identical to the entry. */ }
document.getElementById( "ret" ).innerHTML = myFunction()

This comment has been minimized.

Copy link

commented Apr 5, 2012

Should be (...>>1) instead of (.../2), because .5px can result in problems in older browsers and ~ IEs. Nice idea, anyway.


This comment has been minimized.

Copy link
Owner Author

commented Apr 5, 2012

@atk Good idea! Decimals in pixel based positioning result in crazy antialiasing that probably affect performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.