[Sie-announce] SIEコード [2152] animate要素が期限前に終了してしまうバグを修正

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 11月 17日 (水) 23:32:44 JST


Revision: 2152
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2152
Author:   dhrname
Date:     2010-11-17 23:32:44 +0900 (Wed, 17 Nov 2010)

Log Message:
-----------
animate要素が期限前に終了してしまうバグを修正

Modified Paths:
--------------
    branches/06x/064/org/w3c/dom/svg.js

Modified: branches/06x/064/org/w3c/dom/svg.js
===================================================================
--- branches/06x/064/org/w3c/dom/svg.js	2010-11-16 13:43:15 UTC (rev 2151)
+++ branches/06x/064/org/w3c/dom/svg.js	2010-11-17 14:32:44 UTC (rev 2152)
@@ -1516,6 +1516,7 @@
   /*コール関数。全処理を担う*/
   _ca : function() {
     if ((this.xmlhttp.readyState === 4)  &&  (this.xmlhttp.status === 200)) {
+      var dew = +(new Date());
       /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因は不明)、
        *ここでは、responseTextを用いる
        */
@@ -1652,6 +1653,7 @@
         NAIBU.Time.start();
         delete NAIBU.doc;
       }
+      alert(+(new Date()) - dew);
     }
   },
   /*SVGDocument*/  getSVGDocument : function() {
@@ -4634,10 +4636,10 @@
 SVGAnimationElement.prototype._eventRegExp = /(mouse|activ|clic)[a-z]+/;
 SVGAnimationElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)?/;
 SVGAnimationElement.prototype._unit = {
-    "h" : 2880000,
+    "h"   : 2880000,
     "min" : 48000,
-    "s" : 800,
-    "ms" : 0.8
+    "s"   : 800,
+    "ms"  : 0.8
 };
 /*どれだけズレの時間があるかを計測するメソッド
  *tに数値が使われていないときは0を返す
@@ -4690,7 +4692,7 @@
  *決して現在時刻ではない。要素のbeginイベントの発火したときが0sである。
  */
 /*float*/ SVGAnimationElement.prototype.getCurrentTime = function(){
-  return (this._currentFrame * 125 / 0.8);
+  return (this._currentFrame * 125 * 0.8);
 };
 /*float*/ SVGAnimationElement.prototype.getSimpleDuration = function(){
   if (!!!this._simpleDuration && !!!this._end && this._simpleDuration !== 0) {
@@ -4712,7 +4714,7 @@
 /*      try{*/
         var ntc = NAIBU.Time.currentFrame++;
         var nc = NAIBU.Clip;
-        var s = ntc * 125 / 0.8; //フレーム数ntcをミリ秒数sに変換
+        var s = ntc * 125 * 0.8; //フレーム数ntcをミリ秒数sに変換
         if (ntc > NAIBU.Time.Max) {
           clearInterval(NAIBU.stop);
         }
@@ -4736,7 +4738,6 @@
             }
             if (!!nci._frame) {
               nci._frame();
-              nci._currentFrame++;
             }
           }
           nci = null;
@@ -4778,7 +4779,7 @@
         tar._values[0] = ttr.getAttributeNS(null, attrName) || ttr.style.getPropertyValue(attrName);
       }
       if (!!tta) {
-        ttr[attrName].animVal = vi[attrName].baseVal;
+        tta.animVal = vi[attrName].baseVal;
         for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
           var vir = ttr.cloneNode(false); //仮の要素
           delete vir._tar;
@@ -4809,7 +4810,7 @@
         vi = null;
         return;
       }
-      if ((tar._keyTimes[1] === 1) && (tar._valueList.length > 2)) {
+      if ((tar._keyTimes[1] === 1) && (tar._valueList.length > 2)) { //keyTimesが設定されていない場合、均等に時間を割り振る
         for (var i=0,n=0,tvli=tar._valueList.length-1;i<tvli;++i) {
           n += 1 / tvli;
           tar._keyTimes[i+1] = n;
@@ -4839,13 +4840,12 @@
       evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
       if (!!tta) {
         var base = tta.baseVal, tanim = tta.animVal;
-        var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value;
+        var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value, di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
         /*vを求める公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
          * 3.4.2 Specifying the simple animation function f(t)
          *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
          */
-        var v = v1 + (v2-v1) * (tg-tar._keyTimes[ii]*d) / d;
-        console.log(tg);
+        var v = v1 + (v2-v1) * (tg-tar._keyTimes[ii]*d) / di;
         tanim.newValueSpecifiedUnits(tanim.unitType, v);
         tta.baseVal = tanim;
         tanim = null;
@@ -4873,7 +4873,7 @@
         tta.animatedNormalizedPathSegList = tta.normalizedPathSegList;
         tta.normalizedPathSegList = base;
       }
-     evt = v1 = v2 = v = null;
+     evt = v1 = v2 = v = di = d = n = ii = tg = null;
     };
     evt = vir = null;
   }, false);
@@ -4993,7 +4993,7 @@
           tgsd = null;
           return;
         }
-        var st = (tpn.getTotalLength() / tgsd) * _tar.getCurrentTime() / 125 * 0.8;
+        var st = (tpn.getTotalLength() / tgsd) * _tar.getCurrentTime() / 64;
         var p = tpn.getPointAtLength(st), trans = _tar.targetElement.transform;
         p = p.matrixTransform(_tar.targetElement.getScreenCTM())
         trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
@@ -5440,6 +5440,7 @@
       s = null;
     }
   }
+  xmlhttp = null;
 });
 NAIBU.addEvent("load", NAIBU._main);
 NAIBU.utf16 = function ( /*string*/ s)  {




Sie-announce メーリングリストの案内
Back to archive index