スクロールしてもついてくる(iPhone版)

なんでだろう?以前は「サポートで内容を確認中」なんて出にくかったのに基準が変わったのだろうか?
以前書いたものがあったので投稿してみる。
「平仮名」は、続けようと思う。

<!DOCTYPE html>
<html lang="ja">
<head>
  <title></title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=320">
  <style>
#hoge, #huga {
  width : 200px;
  height: 80px;
  border:6px red double;
  padding:2px;
}
p {margin:5em 0}
  </style>
</head>

<body>
<h1>Test</h1>
<p>a<p>b<p>c<p>d<p>e<p>f<p>g<p>h<p>i<p>j<p>k<p>l
<div id="hoge">けっきょくじゅうようなのは、「ひらがな」でなくてぷろぐらむだよな!</div>
<div id="huga">じぶんのべんきょうのためにかいてるのだし、せつめいをもとめられても</div>

<script>

(function () { //@cc_on

  function Elevator (arg) {
    this.view     = arg.view;      // window
    this.body     = arg.body;      // document.documentElement or body
    this.node     = arg.node;      // target node
    this.accell   = arg.accell;    // acceleration (1 < accell)
    this.interval = arg.interval;  // timer interval
    this.offset   = arg.offset;    // target offset position 
    this.timerId  = null;          // timer
  }
  
//______________________________________________________________________

  function Decorator (alpha) {
    if (alpha < 0)
      return this.visibility = 'hidden';
    
    if (100 < alpha)
      alpha = 100;
    
    this.visibility = 'visible';
     
     /*@if (@_jscript)
    this.filter = 'Alpha(opacity=' + alpha + ')'; @else@*/
    this.opacity = String (alpha / 100); /*@end@*/
  }


  function Locator (x, y) {
    this.top = y + 'px';
    this.left = x + 'px';
  }
  

  function Elevator_start () {
    if (! this.timerId) {
      var that = this;
      var cbFunc = function () { Elevator_onTimer.call (that) };
      this.timerId = this.view.setInterval (cbFunc, this.interval);
    }
  };


  function Elevator_stop () {
    if (this.timerId) {
      this.view.clearInterval (this.timerId);
      this.timerId = null;
      Decorator.call (this.style, -1);
    }
  };


  function Elevator_onTimer () {
    var e = this.node;
    var b = this.body;
    var v = this.view;
    var s = e.style;
    var a = this.accell;
    var o = this.offset;
    
    var offsetX = b.clientWidth - e.offsetWidth - o.x;
    var offsetY = b.clientHeight -e.offsetHeight - o.y;

    var pointerX = /*@if (@_jscript) b.scrollLeft @else@*/ v.pageXOffset /*@end@*/ + offsetX;
    var pointerY = /*@if (@_jscript) b.scrollTop  @else@*/ v.pageYOffset /*@end@*/ + offsetY;
    
    var diffX = pointerX - e.offsetLeft;
    var diffY = pointerY - e.offsetTop;
    
    /*
    if (0 === diffX)
      if (0=== diffY)
        Elevator_stop.call (this);
    */
    var x = e.offsetLeft + Math.floor (diffX / a + (0 < diffX));
    var y = e.offsetTop + Math.floor (diffY / a + (0 < diffY));

    Decorator.call (s, y - offsetY);
    Locator.call (s, x, y);
  };


  function Elevator_init (target, accell, interval, offset) {
    if (1 > arguments.length)
      return null;
    
    var doc = target.ownerDocument;
    var view = doc./*@if (@_jscript) parentWindow @else@*/ defaultView /*@end@*/;
    var style = target.style;
    var arg = {
      view     : doc./*@if (@_jscript) parentWindow @else@*/ defaultView /*@end@*/,
      body     : doc[(doc.compatMode == 'CSS1Compat') ? 'documentElement' : 'body'],
      node     : target,
      accell   : accell || 2,
      interval : interval || 50,
      offset   : offset || { x: 20, y: 50 }
    };
    var elevator = new Elevator (arg);
    
    function onScroll (evt) {
      Elevator_start.call (elevator);
    }

    function onUnload (evt) {
      doc./*@if (@_jscript) detachEvent ('on' + @else@*/ removeEventListener ( /*@end@*/ 'scroll', onScroll, false);
      view./*@if (@_jscript) detachEvent ('on' + @else@*/ removeEventListener ( /*@end@*/ 'unload', arguments.callee, false);
      
      view = doc =
        style = arg = elevator
        onScroll = onUnload =
          null;
    }

    doc./*@if (@_jscript) attachEvent ('on' + @else@*/ addEventListener (/*@end@*/ 'scroll', onScroll, false);
    view./*@if (@_jscript) attachEvent ('on' + @else@*/ addEventListener (/*@end@*/ 'unload', onUnload, false);

    style.position = 'absolute';
    elevator.start ();

    return elevator;
  }


//_______________________________________

  Elevator.init = Elevator_init;
  
  Elevator.prototype.start   = Elevator_start;
  Elevator.prototype.stop    = Elevator_stop;
  
  this.Elevator = Elevator;
  
})();

  Elevator.init (document.getElementById ('hoge'),7,30,{x:54, y:0});
  Elevator.init (document.getElementById ('huga'),10,30,{x:54, y:100});
</script>