LoginSignup
0
3

More than 5 years have passed since last update.

slider V2 メモ

Posted at
  let btn = {
    next: $("btn要素"),
    prev: $("btn要素"),
  }

  let parts = {
    width: 406,
    left: 0,
    index: 0,
    $prent: $("スライドターゲット"),
    slide_anime: function() {
      $child = this.$prent.children();
      len = $child.length - 1;
      parts.$prent.stop().animate({
        left: -parts.width + "px"
      }, 600, function() {
        $child.filter(':first-child').appendTo(parts.$prent);
        parts.$prent.css('left', '');
      });
    },
    slide_prev: function() {
      $child = this.$prent.children();
      len = $child.length - 1;
      parts.$prent.stop().animate({
        left: parts.width + "px"
      }, 600, function() {
        $child.filter(':last-child').prependTo(parts.$prent);
        parts.$prent.css('left', '');
      });
    },

  };

letをvarに変えても同じ動きをします。

ブラウザ側で、見た時に、見えていない所に、要素を置いとくのもとても大事です。
例) 3←見えていない 123←見えている 123←見えていない 12←見えていない。

あとは、コードを見ればだいたいわかっていたがけるかと思います。

では、参考までに

0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3