Slider在上一张幻灯片之后创建空白

Slider在上一张幻灯片之后创建空白

本文介绍了Swiper Slider在上一张幻灯片之后创建空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在将Swiper Slider用于混合应用程序,而我正在使用带有Framework 7的Phonegap创建.

I'm using Swiper Slider for a hybrid app i'm creating using Phonegap with Framework 7.

每张幻灯片都是通过Ajax调用带来的动态内容制作的.

Each slide is made with dynamic content that is being brought through an Ajax call.

问题是我在同一页上有两个滑块,当我到达它们上的最后一个幻灯片时,就会出现巨大的空白,并且我们用手指滑动的次数越多,它将创建的空白就越多

The problem is that i have two Sliders in the same page, and when i reach the last slide on both of them, a huge blank space starts appearing and the more we slide with our finger, the more blank space it will create.

我将在此处留下一些印刷品和相关的代码段.

I will leave here some prints and the relevant bits of code.

我的HTML文件:

    <div class="ementa-sobre pl30 mt60">

         <h3 class="titulo-v1">Ementa <div class="circulo-pequeno"></div> <span class="info-complementar-titulo" id="numero-pratos"></span></h3>

        <div class='swiper-container swiper-ementa-home'>
              <div class='swiper-wrapper' id="slider-ementa-home">
              </div>
        </div>


    </div>



 <div class="eventos-sobre pl30 mt60">

          <h3 class="titulo-v1">Eventos <div class="circulo-pequeno"></div> <span class="info-complementar-titulo" id="numero-eventos"></span></h3>

          <div class='swiper-container swiper-eventos-home'>
              <div class='swiper-wrapper' id="slider-eventos-home">
              </div>
          </div>


</div>

我的JS文件:

myApp.onPageInit('home', function (page) {


    $(document).ready(function()
    {

var ajaxurl3="myurl.php";
        $.ajax({
            type: "POST",
            url: ajaxurl3,
            success: function(data) {
                $.each(data, function(i, field){
                    var id=field.id_categoria;
                    var nomeCategoria=field.nome_categoria;
                    var imgCategoria=field.img_categoria;
                    var string = "<div class='swiper-slide' style='background-image:url(https://pizzarte.com/app/img/ementa/"+imgCategoria+")'><a href='pratos.html?idcat="+id+"&cat="+nomeCategoria+"'><p>"+nomeCategoria+"</p></a></div>";
                    $("#slider-ementa-home").append(string);

                })
            },
            complete: function (data) {
                var mySwiper2 = myApp.swiper('.swiper-ementa-home', {
                    spaceBetween: 15
                  });
               }
        });



        var ajaxurl4="myurl2.php";
        $.ajax({
            type: "POST",
            url: ajaxurl4,
            success: function(data) {
                $.each(data, function(i, field){
                    var id=field.id_evento;
                    var nomeEvento=field.nome_evento;
                    var imgEvento=field.img_evento;
                    var string = "<div class='swiper-slide' style='background-image:url(https://pizzarte.com/app/img/eventos/"+imgEvento+")'><a href='eventos.html?idcat="+id+"&cat="+nomeEvento+"'><p>"+nomeEvento+"</p></a></div>";
                    $("#slider-eventos-home").append(string);

                })
            },
            complete: function (data) {
                var mySwiper3 = myApp.swiper('.swiper-eventos-home', {
                    spaceBetween: 15
                  });
               }
        });


 });
})

打印:

滚动到最后一张幻灯片(很多空白): https://gyazo.com/64f5ec3b4d9c2e1f77357d2a040ea153

Scrolling to the last slide (lots of blank space): https://gyazo.com/64f5ec3b4d9c2e1f77357d2a040ea153

如果我们继续滚动(如果继续滚动,它将继续添加空白): https://gyazo.com/f9e1be36eabbcafdd8767b05a29d2259

If we continue to scroll (if we keep scrolling, it will keep adding blank space): https://gyazo.com/f9e1be36eabbcafdd8767b05a29d2259

知道发生了什么事吗?

推荐答案

在刷卡器初始化"部分中,使用 slidesOffsetAfter:0 ,有关更多详细信息,请参见下面的示例:

In your Swiper Initialization portion, use slidesOffsetAfter: 0, See bellow example for more details:

这篇关于Swiper Slider在上一张幻灯片之后创建空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 21:13