Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual slides ignore initialSlide in the beginning #2755

Closed
1 of 3 tasks
websirnik opened this issue Aug 17, 2018 · 1 comment
Closed
1 of 3 tasks

Virtual slides ignore initialSlide in the beginning #2755

websirnik opened this issue Aug 17, 2018 · 1 comment

Comments

@websirnik
Copy link
Contributor

websirnik commented Aug 17, 2018

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • Swiper Version: 4.3.5

  • Platform/Target and Browser Versions: CHROME

  • Live Link or JSFiddle/Codepen or website with isssue: https://jsfiddle.net/bqv2137n/11/

What you did

When using initialSlide setting together with virtual, there is extra computing happening. Despite the value of initialSlide, Swiper currently always calls renderSlide with 0&1 indexes before rendering initialSlide slide. This is costly, when my createSlide() function is heavy.

var mySwiper = new Swiper('.swiper-container', {
    initialSlide: 4,
    virtual: {
        slides: ['Slide 1', 'Slide 2', 'Slide 3', 'Slide 4', 'Slide 5', 'Slide 6'],
        renderSlide: function(slide, index){
            console.log(slide);
            return createSlide(slide);
        }
    }
});

Expected Behavior

Console Output:

Slide 4
Slide 5
Slide 6

Actual Behavior

Console Output:

Slide 0
Slide 1
Slide 4
Slide 5
Slide 6
@nolimits4web
Copy link
Owner

Fixed by #2756

@lock lock bot added the outdated label Apr 17, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Apr 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants