app/template/lag/Block/update_itemSlider.twig line 1

Open in your IDE?
  1. {#
  2. #}
  3. {% set Products = StockUpdatedProduct() %}
  4.     <script>
  5.       $(function() {
  6.         // テキストスライダーの初期化時のイベント
  7.         $('.ec-updateItemRole__slider').on('init', function () {
  8.           // 最初のスライドに 'fade-in' クラスを適用
  9.           $('.slick-slide[data-slick-index="0"]').addClass('fade-in');
  10.         });
  11.         // テキストスライダーの設定(メインスライダーと同期)
  12.         $('.ec-updateItemRole__slider').slick({
  13.           autoplay: true,          // 自動再生
  14.           infinite: true,          // 無限ループ
  15.           slidesToShow: 1,         // 1つのスライドを表示
  16.           slidesToScroll: 1,       // スライドを1つずつスクロール
  17.           speed: 600,
  18.           autoplaySpeed: 5000,
  19.           arrows: true,
  20.           pauseOnFocus: false,
  21.           pauseOnHover: false,
  22.           pauseOnDotsHover: false,
  23.         })
  24.         .on({
  25.           beforeChange: function(event, slick, currentSlide, nextSlide) {
  26.             // 次のスライドに 'fade-in' クラスを追加
  27.             $(".ec-updateItemRole__list .slick-slide[data-slick-index='" + nextSlide + "']").addClass("fade-in");
  28.           },
  29.           afterChange: function(event, slick, currentSlide) {
  30.             // 現在のスライド以外のすべてのスライドから 'fade-in' クラスを削除
  31.             $(".ec-updateItemRole__list .slick-slide").not("[data-slick-index='" + currentSlide + "']").not(".slick-cloned").removeClass("fade-in");
  32.             // 現在のスライドにクラスを確実に追加
  33.            $(".ec-updateItemRole__list .slick-slide[data-slick-index='" + currentSlide + "']").addClass("fade-in");
  34.           }
  35.         });
  36.       });
  37.     </script>
  38. {% if Products|length > 0 %}
  39. <div class="ec-role">
  40.     <div class="ec-updateItemRole">
  41.         <div class="ec-updateItemRole__title">
  42.             - 更新があった商品 -
  43.         </div>
  44.         <div class="ec-updateItemRole__slider">
  45.             {% for Product in Products %}
  46.             <div class="ec-updateItemRole__listItem">
  47.                 <a href="{{ url('product_detail', {'id': Product.id}) }}">
  48.                     {% if Product.stock_find %}
  49.                         <div class="ec-updateItemRole__imageArea">
  50.                           <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}">
  51.                         </div>
  52.                         <p class="ec-updateItemRole__listItemTitle">{{ Product.name }}</p>
  53.                         <p class="ec-updateItemRole__detailPrice">
  54.                         {% if Product.hasProductClass %}
  55.                             {% if Product.getPrice02Min == Product.getPrice02Max %}
  56.                                 {{ Product.getPrice02IncTaxMin|price }}
  57.                             {% else %}
  58.                                 {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
  59.                             {% endif %}
  60.                         {% else %}
  61.                             {{ Product.getPrice02IncTaxMin|price }}
  62.                         {% endif %}
  63.                         </p>
  64.                     {% else %}
  65.                         <div class="ec-updateItemRole__imageArea soldout">
  66.                           <img src="{{ asset(Product.main_list_image|no_image_product, 'save_image') }}">
  67.                         </div>
  68.                         <p class="ec-updateItemRole__listItemTitle">{{ Product.name }}</p>
  69.                         <p class="ec-updateItemRole__detailPrice soldout">SOLDOUT</p>
  70.                     {% endif %}
  71.                 </a>
  72.             </div>
  73.             {% endfor %}
  74.         </div>
  75.         <a class="ec-updateItemRole__moreBtn" href="{{ url('product_list') }}?orderby=4">一覧を見る</a>
  76.     </div>
  77. </div>
  78. {% endif %}