父の命日

今日は、父の命日。
お墓参りに行って来た。
雪もあるし歩きづらい。
親戚のおばさんが先に来てくれたらしい。

葬式(埋葬)の日、鼻水が凍りつくような寒い日だったことを思い出す。

あ〜あれから25年か〜。

お供えされたリポビタンD、飲んでおくよ。
好きだったコカコーラ、それも飲んでおくよ。
大好きだった魚のお刺身、それは、供えられないね。

あと何が好きだったっけ?
もう、忘れてしまったよ。

それにしても、長いね〜 合掌。


スムーススクロールを書いてみた

しかし、まだIEだとおかしい
今日はもう駄目だ。
http://www39.atwiki.jp/eriax/pub/html/dom/intro-cssom-view.html
diff はもっと複雑だ。

<!DOCTYPE html>
<title></title>
<body>
<style type="text/css">
p { margin-bottom: 1000px; }
</style>
<body>
<p id="TOP"><a href="#HOGE">HOGE</a> / <a href="#LAST">LAST</a></p>

<p id="HOGE"><a href="#TOP">TOP</a> / <a href="#LAST">LAST</a></p>
<p id="LAST"><a href="#TOP">TOP</a> / <a href="#HOGE">HOGE</a></p>

<script>


(function () { //@cc_on

  function SmoothScroll (accell/*Number*/, interval/*Number*/) {
    this.accell       = accell;
    this.interval     = interval;
    this.timerId      = null;
    this.target       = { };
  }

//______________________________________________________________________

  function getAncestorHref (node) {
    var n = node;
    do {
      if ('href' in n)
        if (n.hash.indexOf ('#') === 0)
          return n;
    } while (n = n.parentNode)
    return null;
  }


  function getElementPosition (n) {
    var x = 0;
    var y = 0;

    while (n) { 
      x += n.offsetLeft;
      y += n.offsetTop;
      n = n.offsetParent;
    } 
    return { 'x': x, 'y': y };
  }

//______________________________________________________________________
  
  function SmoothScroll_init (view, accell, interval) {
    var doc = view.document || window.document;
    var scroller = new SmoothScroll (
      accell || 3,
      interval || 30
    );
    
    function onClick (evt) {
      SmoothScroll_click.call (scroller, evt);
    }
    
    function onUnload (evt) {
      doc./*@if (@_jscript) detachEvent ('on' + @else@*/ removeEventListener ( /*@end@*/
        'click', onClick, false);
      view./*@if (@_jscript) detachEvent ('on' + @else@*/ removeEventListener ( /*@end@*/
        'unLoad', arguments.callee, false);
      
      view = doc =
        scroller =
        onClick = onUnload =
          null;
    };

    doc./*@if (@_jscript) attachEvent ('on' + @else@*/ addEventListener (/*@end@*/ 'click', onClick, false);
    view./*@if (@_jscript) attachEvent ('on' + @else@*/ addEventListener (/*@end@*/'unload', onUnload, false);
    
    return scroller;
  }
  
  
  function SmoothScroll_click (evt) {
    var element = evt./*@if (@_jscript) srcElement @else@*/ target /*@end@*/;
    var anchor = getAncestorHref (element);
    var doc = element.ownerDocument;
    var id;
    var target;
    
    if (anchor) {
      id = anchor.hash.substring (1);
      target = doc.getElementById (id) ||
             doc.getElementsByName (id)[0];
      if (target) {
        SmoothScroll_start.call (this, target, anchor.hash);
        evt./*@if (@_jscript) returnValue = false @else@*/ preventDefault() /*@end@*/;
      }
    }
  }


  function SmoothScroll_start (element, hash) {
    var doc = element.ownerDocument;
    var win = doc./*@if (@_jscript) parentWindow @else@*/ defaultView /*@end@*/;
    var position = getElementPosition (element);
    var that = this;
    var cbFunc = function () { SmoothScroll_scroll.call (that) };

    this.target = {
      node : element,
      d    : doc[(doc.compatMode === 'CSS1Compat') ? 'documentElement' : 'body'],
      w    : win,
      x    : position.x,
      y    : position.y,
      hash : hash || null
    };
//alert([position.y, this.target.d.scrollTop]);
    
    if (! this.timerId)
      this.timerId = win.setInterval (cbFunc, this.interval);
  }


  function SmoothScroll_stop () {
    this.target.w.clearInterval (this.timerId);
    this.timerId = null;
  }
  

  function SmoothScroll_scroll () {
    var diff = this.target.y - this.target.d.scrollTop;
    if (diff) {
      diff = Math.floor ((diff / this.accell) + (0 < diff));
      this.target.w.scrollBy (0, diff);
    }
    else {
      SmoothScroll_stop.call (this);
      if (this.target.hash)
        location.hash = this.target.hash;
    }
  }


//______________________________________________________________________

  
  SmoothScroll.init = SmoothScroll_init;
  
  SmoothScroll.prototype.goto = SmoothScroll_start;
  SmoothScroll.prototype.stop = SmoothScroll_stop;
  
  this.SmoothScroll = SmoothScroll;
  
})();


SmoothScroll.init (this, 20, 10);
</script>