Search code examples
onsen-ui

Combining <ons-sliding-menu> and <ons-carousel>


I have an app with <ons-sliding-menu> and a page with <ons-toolbar> and a horizontal
<ons-carousel> covering the remaining space.
For the <ons-sliding-menu> the parameter swipe-target-width="50px" is set.

Is there a way to tell the <ons-carousel> to ignore events originating from the most left 50px and let these go to the menu?


Solution

  • Currently there is no option to make the carousel ignore events on one side, but perhaps you can make a trick. You can put a div at the same level than the carousel and let it take the clicks instead of the carousel in the area you need:

    <div class="cover"></div>
    <ons-carousel>
        ...
    </ons-carousel>
    

    You can change these values to fit your case:

    .cover {
      position: absolute;
      left: 0;
      height: 100%;
      width: 200px;
      z-index: 1;
    }
    

    Check it out here: http://codepen.io/frankdiox/pen/YqKOJE

    Hope it helps!