wp7.html 3.96 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta http-equiv="cleartype" content="on">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1.0;  maximum-scale=1; minimum-scale=1; user-scalable=no;">

<title>jQuery NiceScroll Test 3 - DOJO</title>
<style type="text/css">

#boxscroll {
	padding: 0px;
	height: 220px;
	width: 310px;
	border: 2px solid #0000FF;
	overflow: auto;
	margin: 0px;
}

.mush {
  width:4960px;
  height:4200px;
  background-image:url(img/mariomushrooms.png);
}

.bgm {
  background-image:url(img/mariomushrooms2.png);
}

body {
  font-family: georgia,serif;
  margin:2px;
}

.header {
  width: 320px;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.9);
}

 </style>
</style>

<script src="js/jquery.min.js"></script>
<script src="js/jquery.nicescroll.min.js"></script>

<script src="ext/iphone-style-checkboxes.js" type="text/javascript"></script>
<link rel="stylesheet" href="ext/iphone-style-checkboxes.css" type="text/css" media="screen" />

<script>
  var nice1,nice2;
  var body;
  var off;

  $(window).load(function(){
    off = $("#boxscroll").position();
    off.top+=2;
    off.left+=2;
    $("#boxscroll").scroll();
//    alert($(window).width());
  });
  
  function initScroll() {

    var tb = $('#nctouch').prop("checked");
  
    if (nice1) nice1.remove();
  
    nice1 = $("#boxscroll").niceScroll({touchbehavior:tb,cursorcolor:"#0000FF",cursoropacitymax:0.6,cursorwidth:8,horizrailenabled:true});
    $("#ncver").html(nice1.version);

    $("#boxscroll").scroll(function(e) {
      if (!off) return;
      var px = $("#boxscroll").scrollLeft() - off.left;
      var py = $("#boxscroll").scrollTop() - off.top;
      body.style.backgroundPosition=-px+"px "+-py+"px";
     
      $("#infoscroll1").html($("#boxscroll").scrollLeft()+'x'+$("#boxscroll").scrollTop());
    });
    
    $("#boxscroll").scroll();
  
/*  
    $("#boxscroll2").scroll(function(e) {
      var me = $(this);
      $("#infoscroll2").html(me.scrollLeft()+'x'+me.scrollTop());
    });
*/    

/*    
    nice2.scrollstart(function(info){
      console.log(info);
    });
*/

/*
    nice2.scrollend(function(info){
      console.log(info);
    });
*/    

  }
  
  $(document).ready(function() {
  
    body = document.getElementsByTagName("body")[0];
  
//    $('body').niceScroll({cursoropacitymax:0.8,cursorwidth:8});
    
    $('#nctouch').iphoneStyle().change(function(){      
      initScroll();
    });
    
    initScroll();
    
  });
  
  function getScroll(name) {
    $(name).scrollTop(Math.floor(Math.random()*3000));
  }

  function getScroll2D(name) {
    $(name).getNiceScroll().doScrollPos(Math.floor(Math.random()*4000),Math.floor(Math.random()*4000),150);
  }
  
</script>

<meta name="viewport" content="user-scalable=no" />

</head>

<body class="bgm">

<div style="height:120px" class="header">
  <h2>NICESCROLL - SCROLLING TEST</h2>
  <div>TEST PAGE - Nicescroll version: <span id="ncver"></span></div>
  <table border="0" cellspacing="0" cellpadding="4"><tr><td>Enable touchbehavior option:</td><td><input type="checkbox" id="nctouch" /></td></tr></table>
</div>

<p>&nbsp;</p>
  
<div id="boxscroll"><div class="mush"></div></div>

<div id="debug"></div>

<p>&nbsp;</p>

<input type="button" value="GET SCROLL!" onclick='getScroll("#boxscroll")' />&nbsp;<input type="button" value="GET SCROLL2D!" onclick='getScroll2D("#boxscroll")' />

<p>&nbsp;</p>

<input type="button" value="HIDE ALL!" onclick='$(":nicescroll").getNiceScroll().hide()' />&nbsp;<input type="button" value="SHOW ALL!" onclick='$(":nicescroll").getNiceScroll().show()' />

</body>
</html>