Permalink
Browse files

license page autoscroll

  • Loading branch information...
tebrandt committed Jul 9, 2012
1 parent aebf2b9 commit 282749c797c7fc5839c14dea0020da1fb14909cb
Showing with 37 additions and 54 deletions.
  1. +0 −10 css/license.css
  2. +0 −2 index.html
  3. +37 −42 js/license.js
View
@@ -68,16 +68,6 @@
background: -webkit-gradient(linear, left top, left bottom, from(#000), to(#444));
}
-#licensebtnu {
- left: 630px;
- width: 50px;
-}
-
-#licensebtnd {
- left: 344px;
- width: 50px;
-}
-
#licensebtnq {
left: 412px;
width: 200px;
View
@@ -22,8 +22,6 @@
<body onselectstart="return false" ondragstart="return false" style="overflow:hidden;">
<div id="licensepage" style="display: none">
<iframe id="licensetext" src="README.txt"></iframe>
- <div id="licensebtnu" class="licensebtn">&uarr;</div>
- <div id="licensebtnd" class="licensebtn">&darr;</div>
<div id="licensebtnq" class="licensebtn">Back</div>
</div>
<div id="open" class="open" >
View
@@ -10,55 +10,50 @@
function license_init(id, hpageid)
{
var lbtn = document.getElementById(id+"btnl");
- var ubtn = document.getElementById(id+"btnu");
- var dbtn = document.getElementById(id+"btnd");
var qbtn = document.getElementById(id+"btnq");
var lpage = document.getElementById(id+"page");
- var ltext = document.getElementById(id+"text").contentWindow;
var hpage = document.getElementById(hpageid);
var frame = window.frames[id+"text"];
- var scroll_y = 0;
- var click_y = 0;
- var isdrag = false;
-
- ltext.ontouchstart = function(e) {};
- ltext.ontouchend = function(e) {};
- ltext.ontouchmove = function(e) {};
-
- ltext.onmousedown = function(e) {
- isdrag = true;
- click_y = e.y;
- scroll_y = frame.scrollY;
- };
-
- ltext.onmouseup = function(e) {
- isdrag = false;
- };
-
- ltext.onmousemove = function(e) {
- if(isdrag)
- {
- frame.scrollTo(0, scroll_y + click_y - e.y);
- }
- };
-
- lbtn.addEventListener('click', function() {
- hpage.style.visibility="hidden";
+ var dY = 1;
+ var t0 = 0;
+ var timer;
+
+ lbtn.onclick = function() {
+ var delay = 0;
+ /* display the license page, hide its parent */
+ hpage.style.display="none";
lpage.style.display="block";
- });
-
- ubtn.onmousedown = function() {
- var val = frame.scrollY - 400
- frame.scrollTo(0, (val < 0)?0:val);
- };
- dbtn.onmousedown = function() {
- var val = frame.scrollY + 400
- frame.scrollTo(0, val);
+ /* start the autoscroll interval */
+ timer = setInterval(function() {
+ /* get the actual interval, in case performance slows us down */
+ var t1 = (new Date()).getTime();
+ var dT = (t0 == 0)?20:(t1-t0);
+ t0 = t1;
+ var old = frame.scrollY;
+ frame.scrollTo(0, frame.scrollY + ((dT/20)*dY));
+
+ /* if the frame has hit the limit, delay and swing */
+ /* the other way */
+ if((frame.scrollY == old)&&(delay++ > ((100*dT)/20)))
+ {
+ delay = 0;
+ if(frame.scrollY > 0)
+ {
+ dY = -20;
+ }
+ else
+ {
+ dY = 1;
+ }
+ }
+ }, 20);
};
- qbtn.addEventListener('click', function() {
- hpage.style.visibility="visible";
+ qbtn.onclick = function() {
+ hpage.style.display="block";
lpage.style.display="none";
- });
+ clearInterval(timer);
+ };
}
+

0 comments on commit 282749c

Please sign in to comment.