创建左/右过渡效果
我正在尝试创建像视频 http://www.youtube 中发布的幻灯片过渡效果.com/watch?v=SZTiJmclaRc。
单击按钮时,当前 div#1 将从左侧滑出并隐藏自身,而另一个 div#2 将从右侧滑动并移动到前一个滑出 div 的位置。
当按钮再次触发时,div#2 将向右滑出,而之前隐藏的 div#1 将从左侧滑出。
我一直在尝试修改 http://jsfiddle.net/qSvDz/ 处的代码,如下所示,但我可以似乎没有得到我想要的结果。
有人可以分享一些关于如何做到这一点的想法吗?
function toggleDivs() {
var $home = $("#home");
var $memberHome = $("#member-home");
var $slideOut, $slideIn;
// See which <divs> should be animated in/out.
if ($home.position().left < 0) {
$slideIn = $home;
$slideOut = $memberHome;
}
else {
$slideIn = $memberHome;
$slideOut = $home;
}
$slideOut.animate({
left: "-" + $slideOut.width() + "px"
}, function() {
$slideIn.animate({ left: "0px" });
});
}
$("button").bind("click", function() {
toggleDivs();
});
谢谢 火
I am trying to create a slide transition effect like the one posted in the video http://www.youtube.com/watch?v=SZTiJmclaRc.
When the button is clicked the current div#1 will be sliding out to the left and hide itself while another div#2 will be sliding from the right and move to the location of of the previous slided out div.
And when the button is trigger again the div#2 will be sliding out to right while the previously hide div#1 will be sliding out from left.
I have been trying to modify the code at http://jsfiddle.net/qSvDz/ as below but I can't seem to get the result I wanted.
Could anyone pls share me some thought on how to do it.
function toggleDivs() {
var $home = $("#home");
var $memberHome = $("#member-home");
var $slideOut, $slideIn;
// See which <divs> should be animated in/out.
if ($home.position().left < 0) {
$slideIn = $home;
$slideOut = $memberHome;
}
else {
$slideIn = $memberHome;
$slideOut = $home;
}
$slideOut.animate({
left: "-" + $slideOut.width() + "px"
}, function() {
$slideIn.animate({ left: "0px" });
});
}
$("button").bind("click", function() {
toggleDivs();
});
Thanks
Fire
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的东西吗?
http://jsfiddle.net/k_rma/VmSX4/
HTML:
JS/JQUERY:
CSS:
Something like this?
http://jsfiddle.net/k_rma/VmSX4/
HTML:
JS/JQUERY:
CSS: