Swiper - after first cycle the first item is wrongly rendered but data is correctswiper pagination brakes after page change on jquery mobileReact “after render” code?Set focus on input after renderSwiper throws error on destroying swiper every time after the first timeSwiper, swiper-slide background color is not correctReact and Swiper — Items not fully rendering in slidesiDangero.us Swiper update function does not work after show/hide of slidesVueX Getter acting reactively - how to assign non-reactive to variable?iDangerous' Swiper jumps to `initialSlide` on renderMy Vuex getter is not getting automatically updated.. how I can debug it?

To what extent may I customize a demiplane?

expl3-strategy to automatically update the title of a document, depending on its content

Why in a Ethernet LAN, a packet sniffer can obtain all packets sent over the LAN?

Is it a bad idea to replace pull-up resistors with hard pull-ups?

Are there variations of the regular runtimes of the Big-O-Notation?

How do I compare the result of "1d20+x, with advantage" to "1d20+y, without advantage", assuming x < y?

How do I tell my supervisor that he is choosing poor replacements for me while I am on maternity leave?

What did Rocket give Hawkeye in "Avengers: Endgame"?

Would an 8% reduction in drag outweigh the weight addition from this custom CFD-tested winglet?

Why did God specifically target the firstborn in the 10th plague (Exodus 12:29-36)?

Help decide course of action for rotting windows

Ex-manager wants to stay in touch, I don't want to

Understanding basic photoresistor circuit

Looking for a simple way to manipulate one column of a matrix

Is the schwa sound consistent?

Was there ever any real use for a 6800-based Apple I?

On what legal basis did the UK remove the 'European Union' from its passport?

Why was this sacrifice sufficient?

"Fīliolō me auctum scito, salva Terentia"; what is "me" role in this phrase?

Unit Test - Testing API Methods

How to select certain lines (n, n+4, n+8, n+12...) from the file?

Was the Highlands Ranch shooting the 115th mass shooting in the US in 2019

Will change of address affect direct deposit?

On studying Computer Science vs. Software Engineering to become a proficient coder



Swiper - after first cycle the first item is wrongly rendered but data is correct


swiper pagination brakes after page change on jquery mobileReact “after render” code?Set focus on input after renderSwiper throws error on destroying swiper every time after the first timeSwiper, swiper-slide background color is not correctReact and Swiper — Items not fully rendering in slidesiDangero.us Swiper update function does not work after show/hide of slidesVueX Getter acting reactively - how to assign non-reactive to variable?iDangerous' Swiper jumps to `initialSlide` on renderMy Vuex getter is not getting automatically updated.. how I can debug it?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am using the Swiper framework to get slider functionality in Vue. Everything is working fine except that it shows me wrong item if I am filtering my data and after first cycle is over after scroll. The filter returns the correct items but the rendered first item is wrong.



What I discovered was that, it is only so if I slide "down". If I slide "up". Then everything works fine.



I think the problem is with updating. I would like to update it before I return the filtered data in the getter but I do not know how can I reference to my swiper instance? But then the idea of vuex disappears because vuex shouldn't know anything about frontend basically.



This is my vuex getter which filters my data(returns correct data always):



 filterByCategory(state, getters, rootState) 
if (rootState.shared.selectedCategory !== 'All')
return state.items.filter(
item => crypto.decrypt(item.category) === rootState.shared.selectedCategory,
);

return state.items.filter(item => item.title.toLowerCase().indexOf(getters.filters.searchString.toLowerCase()) >= 0);
,


I am using the mapGetter to get my data in computed like so: ...mapGetters('data', ['filterByCategory']),



This is the component which renders slides(first product-slide is rendered wrongly):



 <swiper
ref="productSlider"
:options="swiperOptions"
class="product-slider"
@slideChange="onSlideChange"
>
<product-slide
v-for="item in items"
:key="item.id"
:item="item"
/>
<div
slot="pagination"
class="product-slider__pagination"
/>
</swiper>


And those are my data() and methods to update the swiper:



props: 
items:
type: Array,
default: () => [],
required: true,
,
,
data()
const self = this;
return
swiperOptions:
direction: 'vertical',
loopedSlides: 1,
spaceBetween: 30,
slidesPerView: 1,
effect: 'fade',
loop: true,
mousewheel:
invert: false,
,
// autoHeight: true,
pagination:
el: '.product-slider__pagination',
clickable: true,
dynamicBullets: true,
dynamicMainBullets: 1,
,
,
;
,
computed:
swiper()
return this.$refs.productSlider.swiper;
,
,
updated()
if(this.swiper)
this.swiper.update();
console.log('swiper-updated');

,
beforeDestroy()
if(this.swiper)
console.log('swiper-before-destroy');
this.swiper.destroy();

,
watch:
items(newValue, oldValue)
if (this.swiper)
console.log(this.items);
this.$nextTick(() =>
this.swiper.update();
);

,
,
methods:
onSlideChange()
console.log('Slide did change');
,



I just can't find what I am doing wrong. I tried also using the observer: true to give the updating over to the framework to handle. Even then it is not working. I've tried everything I could find from Google but nothing is working. I want to know if it is me or bug in the framework. Any help is much appreciated.



I created simple CodePen example.










share|improve this question
























  • Let me check the my Pen again!

    – varit05
    Mar 23 at 14:33

















0















I am using the Swiper framework to get slider functionality in Vue. Everything is working fine except that it shows me wrong item if I am filtering my data and after first cycle is over after scroll. The filter returns the correct items but the rendered first item is wrong.



What I discovered was that, it is only so if I slide "down". If I slide "up". Then everything works fine.



I think the problem is with updating. I would like to update it before I return the filtered data in the getter but I do not know how can I reference to my swiper instance? But then the idea of vuex disappears because vuex shouldn't know anything about frontend basically.



This is my vuex getter which filters my data(returns correct data always):



 filterByCategory(state, getters, rootState) 
if (rootState.shared.selectedCategory !== 'All')
return state.items.filter(
item => crypto.decrypt(item.category) === rootState.shared.selectedCategory,
);

return state.items.filter(item => item.title.toLowerCase().indexOf(getters.filters.searchString.toLowerCase()) >= 0);
,


I am using the mapGetter to get my data in computed like so: ...mapGetters('data', ['filterByCategory']),



This is the component which renders slides(first product-slide is rendered wrongly):



 <swiper
ref="productSlider"
:options="swiperOptions"
class="product-slider"
@slideChange="onSlideChange"
>
<product-slide
v-for="item in items"
:key="item.id"
:item="item"
/>
<div
slot="pagination"
class="product-slider__pagination"
/>
</swiper>


And those are my data() and methods to update the swiper:



props: 
items:
type: Array,
default: () => [],
required: true,
,
,
data()
const self = this;
return
swiperOptions:
direction: 'vertical',
loopedSlides: 1,
spaceBetween: 30,
slidesPerView: 1,
effect: 'fade',
loop: true,
mousewheel:
invert: false,
,
// autoHeight: true,
pagination:
el: '.product-slider__pagination',
clickable: true,
dynamicBullets: true,
dynamicMainBullets: 1,
,
,
;
,
computed:
swiper()
return this.$refs.productSlider.swiper;
,
,
updated()
if(this.swiper)
this.swiper.update();
console.log('swiper-updated');

,
beforeDestroy()
if(this.swiper)
console.log('swiper-before-destroy');
this.swiper.destroy();

,
watch:
items(newValue, oldValue)
if (this.swiper)
console.log(this.items);
this.$nextTick(() =>
this.swiper.update();
);

,
,
methods:
onSlideChange()
console.log('Slide did change');
,



I just can't find what I am doing wrong. I tried also using the observer: true to give the updating over to the framework to handle. Even then it is not working. I've tried everything I could find from Google but nothing is working. I want to know if it is me or bug in the framework. Any help is much appreciated.



I created simple CodePen example.










share|improve this question
























  • Let me check the my Pen again!

    – varit05
    Mar 23 at 14:33













0












0








0








I am using the Swiper framework to get slider functionality in Vue. Everything is working fine except that it shows me wrong item if I am filtering my data and after first cycle is over after scroll. The filter returns the correct items but the rendered first item is wrong.



What I discovered was that, it is only so if I slide "down". If I slide "up". Then everything works fine.



I think the problem is with updating. I would like to update it before I return the filtered data in the getter but I do not know how can I reference to my swiper instance? But then the idea of vuex disappears because vuex shouldn't know anything about frontend basically.



This is my vuex getter which filters my data(returns correct data always):



 filterByCategory(state, getters, rootState) 
if (rootState.shared.selectedCategory !== 'All')
return state.items.filter(
item => crypto.decrypt(item.category) === rootState.shared.selectedCategory,
);

return state.items.filter(item => item.title.toLowerCase().indexOf(getters.filters.searchString.toLowerCase()) >= 0);
,


I am using the mapGetter to get my data in computed like so: ...mapGetters('data', ['filterByCategory']),



This is the component which renders slides(first product-slide is rendered wrongly):



 <swiper
ref="productSlider"
:options="swiperOptions"
class="product-slider"
@slideChange="onSlideChange"
>
<product-slide
v-for="item in items"
:key="item.id"
:item="item"
/>
<div
slot="pagination"
class="product-slider__pagination"
/>
</swiper>


And those are my data() and methods to update the swiper:



props: 
items:
type: Array,
default: () => [],
required: true,
,
,
data()
const self = this;
return
swiperOptions:
direction: 'vertical',
loopedSlides: 1,
spaceBetween: 30,
slidesPerView: 1,
effect: 'fade',
loop: true,
mousewheel:
invert: false,
,
// autoHeight: true,
pagination:
el: '.product-slider__pagination',
clickable: true,
dynamicBullets: true,
dynamicMainBullets: 1,
,
,
;
,
computed:
swiper()
return this.$refs.productSlider.swiper;
,
,
updated()
if(this.swiper)
this.swiper.update();
console.log('swiper-updated');

,
beforeDestroy()
if(this.swiper)
console.log('swiper-before-destroy');
this.swiper.destroy();

,
watch:
items(newValue, oldValue)
if (this.swiper)
console.log(this.items);
this.$nextTick(() =>
this.swiper.update();
);

,
,
methods:
onSlideChange()
console.log('Slide did change');
,



I just can't find what I am doing wrong. I tried also using the observer: true to give the updating over to the framework to handle. Even then it is not working. I've tried everything I could find from Google but nothing is working. I want to know if it is me or bug in the framework. Any help is much appreciated.



I created simple CodePen example.










share|improve this question
















I am using the Swiper framework to get slider functionality in Vue. Everything is working fine except that it shows me wrong item if I am filtering my data and after first cycle is over after scroll. The filter returns the correct items but the rendered first item is wrong.



What I discovered was that, it is only so if I slide "down". If I slide "up". Then everything works fine.



I think the problem is with updating. I would like to update it before I return the filtered data in the getter but I do not know how can I reference to my swiper instance? But then the idea of vuex disappears because vuex shouldn't know anything about frontend basically.



This is my vuex getter which filters my data(returns correct data always):



 filterByCategory(state, getters, rootState) 
if (rootState.shared.selectedCategory !== 'All')
return state.items.filter(
item => crypto.decrypt(item.category) === rootState.shared.selectedCategory,
);

return state.items.filter(item => item.title.toLowerCase().indexOf(getters.filters.searchString.toLowerCase()) >= 0);
,


I am using the mapGetter to get my data in computed like so: ...mapGetters('data', ['filterByCategory']),



This is the component which renders slides(first product-slide is rendered wrongly):



 <swiper
ref="productSlider"
:options="swiperOptions"
class="product-slider"
@slideChange="onSlideChange"
>
<product-slide
v-for="item in items"
:key="item.id"
:item="item"
/>
<div
slot="pagination"
class="product-slider__pagination"
/>
</swiper>


And those are my data() and methods to update the swiper:



props: 
items:
type: Array,
default: () => [],
required: true,
,
,
data()
const self = this;
return
swiperOptions:
direction: 'vertical',
loopedSlides: 1,
spaceBetween: 30,
slidesPerView: 1,
effect: 'fade',
loop: true,
mousewheel:
invert: false,
,
// autoHeight: true,
pagination:
el: '.product-slider__pagination',
clickable: true,
dynamicBullets: true,
dynamicMainBullets: 1,
,
,
;
,
computed:
swiper()
return this.$refs.productSlider.swiper;
,
,
updated()
if(this.swiper)
this.swiper.update();
console.log('swiper-updated');

,
beforeDestroy()
if(this.swiper)
console.log('swiper-before-destroy');
this.swiper.destroy();

,
watch:
items(newValue, oldValue)
if (this.swiper)
console.log(this.items);
this.$nextTick(() =>
this.swiper.update();
);

,
,
methods:
onSlideChange()
console.log('Slide did change');
,



I just can't find what I am doing wrong. I tried also using the observer: true to give the updating over to the framework to handle. Even then it is not working. I've tried everything I could find from Google but nothing is working. I want to know if it is me or bug in the framework. Any help is much appreciated.



I created simple CodePen example.







javascript vue.js swiper






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 11:15







Tarvo Mäesepp

















asked Mar 23 at 10:46









Tarvo MäeseppTarvo Mäesepp

2,20311747




2,20311747












  • Let me check the my Pen again!

    – varit05
    Mar 23 at 14:33

















  • Let me check the my Pen again!

    – varit05
    Mar 23 at 14:33
















Let me check the my Pen again!

– varit05
Mar 23 at 14:33





Let me check the my Pen again!

– varit05
Mar 23 at 14:33












1 Answer
1






active

oldest

votes


















0














I finally found the answer to my question from this Github issue!



What I did was following:



I created show variable inside data() and method reRender() with the following in it:



 reRender()
this.show = false
this.$nextTick(() =>
//re-render start
this.show = true
this.swiper.destroy();
this.$nextTick(() =>
//re-render end
this.swiper.update();
)
)



And I added the :v-if="show" to the <swiper></swiper> component.



And in watcher I am calling the reRender() function.



I am not sure how correct it is, however it is working now.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312895%2fswiper-after-first-cycle-the-first-item-is-wrongly-rendered-but-data-is-correc%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I finally found the answer to my question from this Github issue!



    What I did was following:



    I created show variable inside data() and method reRender() with the following in it:



     reRender()
    this.show = false
    this.$nextTick(() =>
    //re-render start
    this.show = true
    this.swiper.destroy();
    this.$nextTick(() =>
    //re-render end
    this.swiper.update();
    )
    )



    And I added the :v-if="show" to the <swiper></swiper> component.



    And in watcher I am calling the reRender() function.



    I am not sure how correct it is, however it is working now.






    share|improve this answer



























      0














      I finally found the answer to my question from this Github issue!



      What I did was following:



      I created show variable inside data() and method reRender() with the following in it:



       reRender()
      this.show = false
      this.$nextTick(() =>
      //re-render start
      this.show = true
      this.swiper.destroy();
      this.$nextTick(() =>
      //re-render end
      this.swiper.update();
      )
      )



      And I added the :v-if="show" to the <swiper></swiper> component.



      And in watcher I am calling the reRender() function.



      I am not sure how correct it is, however it is working now.






      share|improve this answer

























        0












        0








        0







        I finally found the answer to my question from this Github issue!



        What I did was following:



        I created show variable inside data() and method reRender() with the following in it:



         reRender()
        this.show = false
        this.$nextTick(() =>
        //re-render start
        this.show = true
        this.swiper.destroy();
        this.$nextTick(() =>
        //re-render end
        this.swiper.update();
        )
        )



        And I added the :v-if="show" to the <swiper></swiper> component.



        And in watcher I am calling the reRender() function.



        I am not sure how correct it is, however it is working now.






        share|improve this answer













        I finally found the answer to my question from this Github issue!



        What I did was following:



        I created show variable inside data() and method reRender() with the following in it:



         reRender()
        this.show = false
        this.$nextTick(() =>
        //re-render start
        this.show = true
        this.swiper.destroy();
        this.$nextTick(() =>
        //re-render end
        this.swiper.update();
        )
        )



        And I added the :v-if="show" to the <swiper></swiper> component.



        And in watcher I am calling the reRender() function.



        I am not sure how correct it is, however it is working now.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 12:57









        Tarvo MäeseppTarvo Mäesepp

        2,20311747




        2,20311747





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312895%2fswiper-after-first-cycle-the-first-item-is-wrongly-rendered-but-data-is-correc%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해