简体   繁体   English

Jquery滑出一个相邻的div

[英]Jquery slide out with an adjacent div

If you look to the right side of this page you'll see what I'm talking about. 如果你看到这个页面的右侧,你会看到我在说什么。

Basically, when you click on that little "Tag this Picture/Submit Picture", I want a it to slide out along with a previously hidden div to the right of it. 基本上,当你点击那个“标记这个图片/提交图片”时,我希望它与之前隐藏的div一起向外滑动。 I kind of have that working right now, but as you can see the part you click just jumps over to the ending point instead of being "pushed" out by the new panel sliding out, which is what I want it do do. 我现在有点工作,但你可以看到你点击的部分只是跳到结束点,而不是被新面板滑出“推出”,这就是我想要它做的。

Here's the Jquery I have so far: 这是我到目前为止的Jquery:

<script type="text/javascript">
     $(document).ready(function(){

        $("#right_new").click(function(){
        $("#right_panel").show('slide', {direction: 'right'}, 500);

        });

        });
</script>

If anyone can help me implement a toggle part of it, that would be awesome too, but what I really need for now is just the slide part to work well. 如果有人可以帮我实现它的切换部分,那也很棒,但我现在真正需要的只是滑动部分才能正常工作。 I can probably figure out the if/then part for that eventually. 我最终可能会找出if / then部分。

Thanks in advance. 提前致谢。 Let me know if you need any additional info! 如果您需要任何其他信息,请告诉我们!

Do: 做:

    <script type="text/javascript">
     $(document).ready(function(){

        $("#right_new").click(function(){
          $("#right_side_container").show('slide', {direction: 'right'}, 500);

        });

        });
</script>

The reason your icons are popping out before the slide is happening, is b/c you are hiding the #right_panel , then displaying with the .show() command, will now it's occupying space in the dom and pushing your item to the left. 你的图标在幻灯片发生之前弹出的原因是b / c你正在隐藏#right_panel ,然后用.show()命令显示,现在它将占用dom中的空间并将你的项目推向左边。

What I like to do is animate the whole block in and out using the position:absolute; 我喜欢做的是使用position:absolute;进行整个块的动画制作。

Take a look at these CSS and JS changes http://jsfiddle.net/rtgibbons/jDThJ/ (note: this slides it in and out) 看看这些CSS和JS的变化http://jsfiddle.net/rtgibbons/jDThJ/ (注意:这会滑入和滑出)

I'm using the .animate({right: '' }) to move the entire container left and right. 我正在使用.animate({right: '' })移动整个容器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM