strange behavior in use of sliding effect

strange behavior in use of sliding effect

Hey guys,
posted yesterday my problem by creating my slider for some div containers. Well this Code works now but i looks strange when i slide to the next div. Let me explain it a litte precisely. On click the Slider should switch to the next div. The current div is set to hide and the next div is be shown. This works but the animation look strange. The current div switch to the right and the next div come from left. But between this action something is wrong because the next div comes from down and left. I try some things with setting a width for the slider but nothing changed. When you use it without a specific width the slider get thicker during the slide effect and then turn to normal size. Here is my code i implemented. Maybe someone has some idea what's the problem. I'm new to jQuery so maybe my implementation way is stupid or wrong for this Projekt :) 

  1. <body>
  2. <div class="clearfix">
  3. <img src="images/leftarrow.png" id="leftarrow" alt="leftarrow"/>
  4. <div class="slider">
  5. <div class="active">
  6. <img src="images/1.jpg" />
  7. </div>
  8. <div>
  9. <img src="images/2.jpg" />
  10. </div>

  11. <div>
  12. <img src="images/3.jpg" />
  13. </div>

  14. <div>
  15. <img src="images/4.jpg" />
  16. </div>

  17. <div>
  18. <img src="images/5.jpg" />
  19. </div>
  20. </div>
  21. <img src="images/rightarrow.png" id="rightarrow" alt="rightarrow"/>
  22. </div><!--Ende Clearfix-->
  23. </body>

  1. <script type="text/javascript" charset="utf-8">
  2. $(document).ready(function(){
  3. $(".slider").children().hide();
  4. $(".active").show();
  5. $("#rightarrow").click(function(event){
  6. var $current = $(".active"); 
  7. var $next = $current.next(); 
  8. var $first = $(".slider :first-child");
  9. //console.log($first);  #debug
  10. //console.log($current); #debug
  11. //console.log($next.length); #debug
  12. if($next.length != 0){
  13. $current.removeClass("active");
  14. $next.addClass("active");
  15. $current.toggle("slide",{direction:"left"},"fast");
  16. $next.toggle("slide",{direction:"right"},"fast");
  17. }
  18. })
  19. $("#leftarrow").click(function(event){
  20. var $current = $(".active"); 
  21. var $prev = $current.prev(); 
  22. var $last = $(".slider :last-child");
  23. //console.log($first);  #debug
  24. //console.log($current); #debug
  25. //console.log($next.length); #debug
  26. if($prev.length != 0){
  27. $current.removeClass("active");
  28. $prev.addClass("active");
  29. $current.toggle("slide",{direction:"right"},"fast");
  30. $prev.toggle("slide",{direction:"left"},"fast");
  31. }
  32. }) 
  33. })
  34. </script>


  1. body{
  2. margin:0 auto;
  3. background:#141414;
  4. color:#fff;
  5. }

  6. #leftarrow{
  7. float:left;
  8. }

  9. #rightarrow{
  10. margin:10px;
  11. }

  12. .slider{
  13. float:left;
  14. }

  15. /*
  16. *IE patch clearfix 
  17. */
  18. .clearfix {
  19. display: inline-block;
  20. }
  21. /*
  22. *vorm IE5/Mac verstecken
  23. */
  24. * html .clearfix {
  25. height: 1px;
  26. }
  27. .clearfix {
  28. display: block;
  29. }
  30. /*
  31. *ende versteckn IE5/Mac 
  32. */
Sorry for my bad english :) 


Greetings