svnno****@sourc*****
svnno****@sourc*****
2011年 1月 26日 (水) 22:46:43 JST
Revision: 2333 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2333 Author: dhrname Date: 2011-01-26 22:46:42 +0900 (Wed, 26 Jan 2011) Log Message: ----------- アニメーション関連のバグを修正 Modified Paths: -------------- branches/06x/sie.js Modified: branches/06x/sie.js =================================================================== --- branches/06x/sie.js 2011-01-26 13:44:39 UTC (rev 2332) +++ branches/06x/sie.js 2011-01-26 13:46:42 UTC (rev 2333) @@ -6941,7 +6941,7 @@ this._begin = null; this._end = null; this._from = this._to = this._values = this._by = null; - this._keyTimes = [0, 1]; + this._keyTimes = null; this.addEventListener("beginEvent", function(evt) { var tar = evt.target; if (!tar.isRepeat) { @@ -6983,6 +6983,7 @@ tar._by = evt.newValue; } else if (name === "keyTimes") { var s = evt.newValue.split(";"); + tar._keyTimes = []; //_keyTimesプロパティを初期化 for (var i=0;i<s.length;++i) { tar._keyTimes[i] = parseFloat(s[i]); } @@ -7159,9 +7160,10 @@ Max : 7000, start : function() { if (NAIBU.Clip.length > 0) { + screen.updateInterval = 42; //24fpsとして描画処理 window.onscroll = function () { screen.updateInterval = 0; - screen.updateInterval = 42; //24fpsとして描画処理 + screen.updateInterval = 42; } NAIBU.stop = setInterval( (function() { /* try{*/ @@ -7277,12 +7279,6 @@ vi = null; return; } - 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; - } - } evt = tta = vir = vi = null; }, false); }, false); @@ -7291,9 +7287,12 @@ var attrName = tar.getAttributeNS(null, "attributeName"), newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName); var ttr = tar.targetElement, tta = ttr[attrName]; tar._frame = function() { - var d = tar.getSimpleDuration() * 0.8, n = tar._valueList.length - 2, tg = tar.getCurrentTime(); + var d = tar.getSimpleDuration() * 0.8, n = tar._valueList.length-1, tg = tar.getCurrentTime(); if ((n !== -1) && (d !== 0) && (tg <= d)) { var ii = Math.floor((tg*n) / d); + if (ii === n) { //iiが境い目のときは、n-2を適用 + ii -= 1; + } } else { return; } @@ -7305,6 +7304,13 @@ */ var evt = tar.ownerDocument.createEvent("MutationEvents"); evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null); + if (tar._keyTimes) { + var di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d; + var ti = tar._keyTimes[ii]; + } else { + var di = d / n; //keyTimesがなければ均等に時間を配分しておく + var ti = ii / n; + } if (!!tta) { var base = tta.baseVal, tanim = tta.animVal; var v1 = tar._valueList[ii].value; @@ -7313,7 +7319,7 @@ *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction */ if (!tar._isDiscrete) { - var v2 = tar._valueList[ii+1].value, di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d, v = v1 + (v2-v1) * (tg-tar._keyTimes[ii]*d) / di; + var v2 = tar._valueList[ii+1].value, v = v1 + (v2-v1) * (tg-ti*d) / di; } else { var v = v1; } @@ -7329,9 +7335,9 @@ di = null; } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば var base = null; - var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value, di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d; + var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value; if (!tar._isDiscrete) { - var v = v1 + (v2-v1) * (tg-tar._keyTimes[ii]*d) / di; + var v = v1 + (v2-v1) * (tg-ti*d) / di; } else { var v = v1; } @@ -7542,13 +7548,23 @@ } tar._frame = function() { var _tar = tar; - var d = _tar.getSimpleDuration() * 0.8, n = _tar._valueList.length - 2, tg = _tar.getCurrentTime(); + var d = _tar.getSimpleDuration() * 0.8, n = _tar._valueList.length - 1, tg = _tar.getCurrentTime(); if ((n !== -1) && (d !== 0) && (tg <= d)) { var ii = Math.floor((tg*n) / d); + if (ii === n) { //iiが境い目のときは、n-2を適用 + ii -= 1; + } } else { return; } - var fc = _tar._valueList[ii].rgbColor, tc = _tar._valueList[ii+1].rgbColor, di = (_tar._keyTimes[ii+1] - _tar._keyTimes[ii]) * d, durd = (tg-tar._keyTimes[ii]*d) / di, num = CSSPrimitiveValue.CSS_NUMBER; + if (tar._keyTimes) { + var di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d; + var ti = tar._keyTimes[ii]; + } else { + var di = d / n; //keyTimesがなければ均等に時間を配分しておく + var ti = ii / n; + } + var fc = _tar._valueList[ii].rgbColor, tc = _tar._valueList[ii+1].rgbColor, durd = (tg-ti*d) / di, num = CSSPrimitiveValue.CSS_NUMBER; var fr = fc.red.getFloatValue(num), fg = fc.green.getFloatValue(num), fb = fc.blue.getFloatValue(num); var r = fr + (tc.red.getFloatValue(num) - fr) * durd; var g = fg + (tc.green.getFloatValue(num) - fg) * durd;