When using Horizontal Scroll ion-scroll page can't be scrolled down in y-direction

is there any better solution,i also tried to use slick carousel but still i face the same issue

I searched for almost two days, and finally landed at this solution. I didnā€™t find any solution better than this.

anyways thank you. :smile:

Confirmed, still works in v1.1.0

@andmar8 I kind of lose touch of which solution is confirmed to be still working. Is it the solution in this codepen http://codepen.io/walm/pen/wBoReG?

Thanks.

Iā€™m using @bra1n 's solution but like @ferryfax 's app, my app would be based on many horizontal scrolling images.

The navigation is kind of messy and frustrating. :confused:

Bra1nā€™s solution:

ignoreScrollStart: function(e) {
    return //(e.defaultPrevented) ||  // <-- comment out this first condition to have scroll events bubble u

Works perfectly

As I said, Iā€™m using Bra1nā€™s solution, but itā€™s not so perfect.

When you try to scroll in x-direction the page scrolls in y-direction too. Itā€™s impossible to scroll left without page scrolls vertically.

Thatā€™s the trade you make

After trying a few of the solutions listed here, my solution was to abandon ion-scroll all together and set overflow-scroll=true on the ion-content and then use a standard ul with the properties:

overflow-x: auto;
overflow-y: hidden ;
white-space: nowrap;

I actually noticed better performance on Android when I didnā€™t use ion-scroll. And I could still scroll both vertically and horizontally and it performed exactly as expected.

@DaDanny Do you have a codepen example? Iā€™m dying to have a solution for this issue.

Sure, Iā€™ll try and put up an example this evening, just need to take care of a few things first.

In the mean time, what exactly are you stuck on so I know what to point out.

@DaDanny Iā€™m interested to see how your solution is different from the original solution. The original solution didnā€™t work well for me for various reason, like horizontal scroll is not locked when scrolling up and down, getting multiple horizontal scroll regions to work is also quite tricky.

Sorry about the delay, working on a codepen now :slight_smile:

Heres my example.

You can basically ignore anything I do in the controller. Youā€™ll see Iā€™m doing nothing fancy, just setting up a bunch of cards, and adding images to each card to show my solution.

What I would look at is how I did the horizontal scrolling. Instead of using ion-scroll with direction=ā€˜xā€™, I used a ul and ng-repeat for each image. To make the ul scroll horizontally instead of vertically, you can use these properties:

overflow-x: auto;
overflow-y: hidden ;
white-space: nowrap;

I had to open Chrome Dev tools and emulate an iOS device to get the click to scroll events to work, but in an app, you wonā€™t have any trouble.

In my app, Iā€™m able to have hundreds if not thousands of images and cards, with no performance issues on iOS and Android. (Iā€™m also using crosswalk for Android). Its seriously smooth as butter. But when I tried ion-scroll, sometimes Iā€™d get a weird flashing when I would scroll on Android, but not with this solution.

Also, make sure you donā€™t change the z-indexā€™s for any of the images. When I tried that, it seemed like they were detached from the parent element, and I saw weird behavior on scroll events on BOTH ios and Android.

I hope this solution helps you out. Let me know if you have any trouble.

Edit:

Also, with ion-scroll, I noticed that if you tapped inside the horizontal scroller, you were no longer able to scroll up and down, which was super annoying.

If you want to get it so you can touch to scroll without opening Chrome Dev tools, youā€™ll need to copy the code from the original solution up until the suggested Horizontal Scroll Fix. I just didnā€™t find this necessary as it works great on iOS and Android, so why add code you donā€™t need?

2 Likes

@DaDanny Thank you for putting this codepen together. Itā€™s very useful and in my opinion, this seems to be a cleaner and better solution without involving adding much code.

I tried to play around with the example and find that if I remove overflow-scroll from ion-content or set it to false because I want to get the pull and bounce back effect, horizontal scrolling doesnā€™t work anymore.

Did you see the same behavior on iOS or Android? I havenā€™t incorporated your example into my project and tested it out yet.

Are you talking about also having a ā€œpull-down to refreshā€ at the top of the page?

@DaDanny Not sure I did previously to break your example. But I forked and added <ion-refresher> to it. Everything seems to work perfectly.

Again, thank you for providing the example. Itā€™s exactly what I was seeking for a long time.

Hmmmā€¦ that definitely complicates things haha.

I messed around for a little bit but couldnā€™t get it working. Iā€™d try using two ion-contents, one within the other. The outermost one has the ion-refresher and the inner ion-content has the cards (from the example). But when I tried this, you canā€™t scroll horizontally.

Sorry I couldnā€™t help you out with that one.

Danny

Thatā€™s definitely a bummer :frowning: Iā€™ve been struggling with this issue for quite some time.