私はJavaスクリプトアニメーションを学ぶしようとしていると私はこのサイトには本当に良い例が見つかりました:http://javascript.info/tutorial/animation#maths-the-function-of-progress-delta単純なアニメーション
をしかし、問題は、初心者として、私はどのように理解していない、あります関数とオブジェクトはお互いに働きます。
質問01私は例をコピーし
「のはそれのベース上の動きのアニメーションを作成してみましょう:」しかし、私のバージョンでは動作しません。
<!DOCTYPE HTML>
<html>
<head>
<style>
.example_path{
position: relative;
width: 600px;
height: 100px;
border-style: solid;
border-width: 5px;
}
.example_block{
position: absolute;
width: 100px;
height: 100px;
background-color: yellow;
}
</style>
</head>
<body>
<div onclick="move(this.children[0])" class="example_path">
<div class="example_block"></div>
</div>
<script>
function move(element, delta, duration) {
var to = 500
animate({
delay: 10,
duration: duration || 1000, // 1 sec by default
delta: delta,
step: function(delta) {
element.style.left = to*delta + "px"
}
})
}
</script>
</body>
</html>
出力コンソール:にReferenceError:アニメーションは、問題が何であるか、誰もが知ってい 定義されていませんか?
質問02
私の第二の願いは、私は両方のコードスニペットをリンクするにはどうすればよい
function makeEaseInOut(delta) {
return function(progress) {
if (progress < .5)
return delta(2*progress)/2
else
return (2 - delta(2*(1-progress)))/2
}
}
bounceEaseInOut = makeEaseInOut(bounce)
easeInOut機能を統合すること、ありますか?このページのコードもhttp://javascript.info/tutorial/animation#maths-the-function-of-progress-delta
あなたは彼らがあなただけの、あなたはリンク先のページまで、さらにアニメーション関数を定義http://javascript.info/files/tutorial/browser/animation/animate.js –
を逃していますあなたのコードでそれを欠いています。 – spaceman