jQueryのアニメーションのスピードにnormalはない
夜中にtwitterで@Takazudoさんが次のような発言をしていました。
jQueryのアニメーションのスピードはソースを見るとslow、fast、ミリ秒のどれかでそれ以外は400になるはずでnormalって言う指定は無いように見えるんだけど、色んなサイトにnormalって値を取れると書いてあるけどなぜなんだこれ。昔ドキュメントにそうあったのかなー
あれスピードにnormalってあったのにと思ってjQueryのリファレンスを確認すると
Duration
Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 milliseconds, respectively.
と確かにnormalの指定について言及がありませんでした。
jQueryソースコードを確認すると、
speeds: {
slow: 600,
fast: 200,
// Default speed
_default: 400
},
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
このようになっており、やはりnormalに関する設定はなし。
normalのようにslowやfast以外のテキストが設定されている場合は_defaultの400ミリ秒のスピードになるようです。
ということはnormalの起源を探すのですが
第二引数にはアニメーションの動作期間を指定します。"slow"、"normal"、"fast"、もしくは完了までの時間をミリ秒単位で指定します。例えば"1500"であれば、1.5秒かけてアニメーションが行われます。
animate - jQuery 日本語リファレンス
jQuery 日本語リファレンスさんには「normal」があります。
A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
jQuery API Browserによるとどうも、1.3.2まで公式のリファレンスに「normal」の記述があったようです。
結論
公式リファレンスの1.3.2までは「normal」の利用が明示されていたが1.4から「normal」の記述がなくなったようです。
普段何気なく使っている値がいつの間にかなくなっていると不安になりますよねというお話でした。
関連エントリー
jQuery基礎文法最速マスター
jQueryを良くする25のTIPS
14のjQueryベストプラクティス
8のjQueryのすごいTIPS
jQueryのコードを良くする5つのTIPS
スポンサードリンク
«Web Designing (ウェブデザイニング)2010年 10月号 発売 | メイン | 現場のプロから学ぶXHTML+CSS 増刷(11刷)決定»