Skip to content

Instantly share code, notes, and snippets.

@rewish
Created September 15, 2011 11:17
Show Gist options
  • Save rewish/1219025 to your computer and use it in GitHub Desktop.
Save rewish/1219025 to your computer and use it in GitHub Desktop.
jQuery.bgSwitcher - animate
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