Created
September 15, 2011 11:17
-
-
Save rewish/1219025 to your computer and use it in GitHub Desktop.
jQuery.bgSwitcher - animate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function($) { | |
$(expr).bgSwitcher({ | |
switchHandler: function() { | |
var | |
// アニメーション対象の要素 | |
node = this.node, | |
// 要素のオフセット | |
offset = node.offset(), | |
// animateに渡すCSS | |
params = { | |
left: -node.width(), | |
top: -node.height(), | |
opacity: 0 | |
}, | |
// animateの持続時間 | |
duration = 1000, | |
// アニメーション終了時の処理 | |
callback = function() { | |
// 非表示にして | |
node.hide(); | |
// アニメーションで変更したスタイルを元に戻す | |
node.css({ | |
left: offset.left, | |
top: offset.top, | |
opacity: 1 | |
}); | |
}; | |
node.animate(params, duration, callback); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment