From: dhrname Date: Fri, 27 Feb 2015 13:13:25 +0000 (+0900) Subject: Support an advance method for the present value X-Git-Tag: version22~288 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=359f0bfdf29136ede38262cf6608fea4009f379c;p=sie%2Fsie.git Support an advance method for the present value --- diff --git a/org/w3c/dom/smil.js b/org/w3c/dom/smil.js index 986a182..1c94175 100644 --- a/org/w3c/dom/smil.js +++ b/org/w3c/dom/smil.js @@ -464,13 +464,34 @@ base("$from").of( { /*$toオブジェクトにこのオブジェクトを適用させる関数*/ call: function() { this.$to.from = this; + /*文字部分の配置パターンは4通りあるので、ここでstrListを処理 + * (1) a 0 の場合 + * (2) 0 a + * (3) a 0 a (ノーマルパターン) + * (4) 0 a 0 + * これらのパターンのうち、(1)(2)(4)を(3)のパターンに変えたのが以下*/ + /*文字列が1aのように、数値で始まるかどうか。始まったら真*/ + if (!this.string || !this.numList || !this.strList) { + return this.$to; + } + var isFirstNum = /^[\-\+]?[\d\.]/.test(this.string), + /*文字列がa1のように、数値で終わるかどうか。終わったら真*/ + isLastNum = /\d$/.test(this.string), + isNormal = (this.numList.length < this.strList.length); + if (isFirstNum && !isNormal) { + this.strList.unshift(""); + } + if (isLastNum && !isNormal) { + this.strList.push(""); + } return this.$to; } } ) .mix( { /*advance メソッド - * アニメーションの進行具合を示す進捗率 t (0 <= t <= 1)をもとに、現在の呈示値を算出するためのもの*/ + * アニメーションの進行具合を示す進捗率 t (0 <= t <= 1)をもとに、現在の呈示値を算出するためのもの + * callメソッドで前もって呼び出されていることが前提となる*/ advance: function(t) { if ( (t < 0) || (1 < t)) { throw new Error("An Invalid Number Error"); @@ -483,11 +504,12 @@ base("$from").of( { strList = this.strList, fromNumList = this.from.numList; for (var i=0,nuli=numList.length;i