Monaca Onsen UI Discord Chat Github Repo

Changing the width of browser window does not change the scroll width of onsen-carousel (onsen ui 2)

  • Hi Folks,

    i would like to use the onsen-carousel for a learning module on mobile devices just the same like in web browsers. Therefor i have testet the component in firefox and google chrome in full screen mode.
    I have found that changing the width of the browser window adjusted the size of the carousel-items. but the scroll width did not change.
    If i change the width from 800px to 1024px, the prev and next functions do scroll 800px furthermore. To swipe over the screen also uses only 800px instead of 1024 …

    How can the scroll width be adjusted to the window width?

    Greetings from Germany!

  • Onsen UI

    @thiudisk Hello!

    ons-carousel is not prepared to be resized in the browser since I guess it’s an uncommon use case. Carousel will probably be reworked after we finish some other stuff. If you really need to fix this, you can try to do myCarousel._currentElementSize = undefined; before prev or next (or on window.onresize). That should force the carousel to recalculate the width of the element. Note that that’s a “private” function that can be changed with any update.

  • @Fran-Diox

    Hi Fran,

    i wrote it in “<body onresize=”…"> and it works.

    Thank you very much!