index.html 2.6 KB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">

<title>iScroll demo: starfield</title>

<script type="text/javascript" src="../../build/iscroll.js"></script>

<script type="text/javascript">

var myScroll;

function loaded () {
	myScroll = new IScroll('#wrapper', {
		mouseWheel: true,
		indicators: [{
			el: document.getElementById('starfield1'),
			resize: false,
			ignoreBoundaries: true,
			speedRatioY: 0.4
		}, {
			el: document.getElementById('starfield2'),
			resize: false,
			ignoreBoundaries: true,
			speedRatioY: 0.2
		}]
	});
}

document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

</script>

<style type="text/css">
* {
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}

html {
	-ms-touch-action: none;
}

body,ul,li {
	padding: 0;
	margin: 0;
	border: 0;
}

body {
	font-size: 12px;
	font-family: ubuntu, helvetica, arial;
	overflow: hidden; /* this is important to prevent the whole page to bounce */
	background: #000;
}

#wrapper {
	position: absolute;
	z-index: 3;
	width: 100%;
	top: 0;
	bottom: 0;
	left: 0;
	overflow: hidden;
}

#scroller {
	position: absolute;
	z-index: 3;
	width: 100%;
	height: 4000px;
	overflow: hidden;
	-webkit-tap-highlight-color: rgba(0,0,0,0);
	-webkit-transform: translateZ(0);
	-moz-transform: translateZ(0);
	-ms-transform: translateZ(0);
	-o-transform: translateZ(0);
	transform: translateZ(0);
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	-webkit-text-size-adjust: none;
	-moz-text-size-adjust: none;
	-ms-text-size-adjust: none;
	-o-text-size-adjust: none;
	text-size-adjust: none;
	background: url(galaxies1.png);
}

.starfield {
	position: absolute;
	width: 100%;
	top: 0;
	left: 0;
	bottom: 0;
	overflow: hidden;
}

.starfield div {
	position: absolute;
	width: 100%;
	overflow: hidden;
	-webkit-transform: translateZ(0);
	-moz-transform: translateZ(0);
	-ms-transform: translateZ(0);
	-o-transform: translateZ(0);
	transform: translateZ(0);
}

#starfield1 {
	z-index: 2;
}

#stars1 {
	z-index: 2;
	height: 3000px;
	background: url(galaxies2.png);
}

#starfield2 {
	z-index: 1;
}

#stars2 {
	z-index: 1;
	height: 2000px;
	background: url(stars.jpg);
}

</style>
</head>
<body onload="loaded()">

<div id="wrapper">
	<div id="scroller"></div>
</div>

<div class="starfield" id="starfield1">
	<div id="stars1"></div>
</div>

<div class="starfield" id="starfield2">
	<div id="stars2"></div>
</div>

</body>
</html>