iDangerous Swiper initialSlide setting
<p>For the mobile version of our website we use the iDangerous Swiper (2.4.3) to display product images and for the desktop version we use a carousel. </p>

<p>The mobile version uses the same images and order as our dekstop version, because
both versions use the same database query.</p>

<pre><code>    /*
     * Carrousel
     */
    $q = "
        SELECT
            c.id,
            CONCAT('" . Config::get(array("paths","uri-products")) . $product_id . "/',c.image_url) as image_url
        FROM
            product_carrousel c
        WHERE
            c.product_id = '" . $product_id . "'
        ORDER BY
            c.order ASC
        ";

    $r["carrousel"] = $this-&gt;db-&gt;select($q);
</code></pre>

<p>What we want to accomplish: The mobile version we want to display an other start image. Is there a way for the iDangerous Swiper (2.4.3) to have a specific start slide or offset -1 slide (so it starts with the last image). This way i can upload the specific start image for mobile as last image, and have that one displayed first only on mobile.</p>

<p>HTML/PHP Mobile version:</p>

<pre><code>&lt;div class="swiper-container product-slider"&gt;
    &lt;div class="swiper-wrapper"&gt;

    &lt;?php foreach ($product['carrousel'] as $x =&gt; $item):?&gt;

        &lt;div class="swiper-slide"&gt;
            &lt;figure class="swiper-slide-img"&gt;
                &lt;img src="&lt;?php echo $item['image_url']; ?&gt;" alt="&lt;?php echo strip_tags($product['title']); ?&gt;"/&gt;
            &lt;/figure&gt;
        &lt;/div&gt;

    &lt;?php endforeach; ?&gt;
&lt;/div&gt;
</code></pre>

<p></p>

<p>HTML Output Mobile:</p>

<pre><code>    &lt;div class="swiper-container product-slider done"&gt;
        &lt;div class="swiper-wrapper" style="width: 2484px; transform: translate3d(-414px, 0px, 0px); transition-duration: 0s; height: 229px;"&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml" class="swiper-slide swiper-slide-duplicate" style="width: 414px; height: 229px;"&gt;
            &lt;figure class="swiper-slide-img"&gt;
                &lt;img src="" alt=""&gt;
            &lt;/figure&gt;
        &lt;/div&gt;


        &lt;div class="swiper-slide swiper-slide-visible swiper-slide-active" style="width: 414px; height: 229px;"&gt;
            &lt;figure class="swiper-slide-img"&gt;
                &lt;img src="" alt=""&gt;
            &lt;/figure&gt;
        &lt;/div&gt;


        &lt;div class="swiper-slide" style="width: 414px; height: 229px;"&gt;
            &lt;figure class="swiper-slide-img"&gt;
                &lt;img src="" alt=""&gt;
            &lt;/figure&gt;
        &lt;/div&gt;


        &lt;div class="swiper-slide" style="width: 414px; height: 229px;"&gt;
            &lt;figure class="swiper-slide-img"&gt;
                &lt;img src="" alt=""&gt;
            &lt;/figure&gt;
        &lt;/div&gt;


        &lt;div class="swiper-slide" style="width: 414px; height: 229px;"&gt;
            &lt;figure class="swiper-slide-img"&gt;
                &lt;img src="" alt=""&gt;
            &lt;/figure&gt;
        &lt;/div&gt;

        &lt;div xmlns="http://www.w3.org/1999/xhtml" class="swiper-slide swiper-slide-duplicate" style="width: 414px; height: 229px;"&gt;
            &lt;figure class="swiper-slide-img"&gt;
                &lt;img src="" alt=""&gt;
            &lt;/figure&gt;
        &lt;/div&gt;
    &lt;/div&gt;
</code></pre>

<p></p>

<p><strong>Partial solution:</strong></p>

<p>In idangerous.swiper.min.js i found the setting: initialSlide.</p>

<p>Changing that to -1 makes the slider start with the last slide in mobile.</p>

<p>I've added to ui.js the following:</p>

<pre><code>    initSliders: function() {

        $('.swiper-container').each(function(){

            var paginationContainer = '.' + $(this).next().attr('class');

            if($(this).hasClass('product-slider')) {
                var mySwiper = $(this).swiper({
                mode:'horizontal',
                loop: true,
                initialSlide: -1,
                pagination: paginationContainer,
                calculateHeight: true
                });
            } else {
                var mySwiper = $(this).swiper({
                mode:'horizontal',
                loop: true,
                initialSlide: 0,
                pagination: paginationContainer,
                calculateHeight: true
                });
            }

            $(this).addClass('done');
            $(this).next().addClass('swiper-ready');

        });

    },
</code></pre>

<p><strong>Problem:</strong> The last pagination (in this case the active one) doesnt get the active class. Only on swipe it shortly gets the active pagination class, and then immediatly switches to the current active one.</p>

<p>On load:</p>

<pre><code>     &lt;div class="swiper-pagination swiper-ready"&gt;
        &lt;span class="swiper-pagination-switch"&gt;&lt;/span&gt;
        &lt;span class="swiper-pagination-switch"&gt;&lt;/span&gt;
        &lt;span class="swiper-pagination-switch"&gt;&lt;/span&gt;
        &lt;span class="swiper-pagination-switch"&gt;&lt;/span&gt;
    &lt;/div&gt;
</code></pre>

<p>While dragging/swiping:</p>

<pre><code>    &lt;div class="swiper-pagination swiper-ready"&gt;
        &lt;span class="swiper-pagination-switch"&gt;&lt;/span&gt;
        &lt;span class="swiper-pagination-switch"&gt;&lt;/span&gt;
        &lt;span class="swiper-pagination-switch"&gt;&lt;/span&gt;
        &lt;span class="swiper-pagination-switch swiper-visible-switch swiper-active-switch"&gt;&lt;/span&gt;
    &lt;/div&gt;
</code></pre>

<p>After swipe:</p>

<pre><code>    &lt;div class="swiper-pagination swiper-ready"&gt;
        &lt;span class="swiper-pagination-switch"&gt;&lt;/span&gt;
        &lt;span class="swiper-pagination-switch"&gt;&lt;/span&gt;
        &lt;span class="swiper-pagination-switch swiper-visible-switch swiper-active-switch"&gt;&lt;/span&gt;
        &lt;span class="swiper-pagination-switch"&gt;&lt;/span&gt;  
    &lt;/div&gt;
</code></pre>