ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Ion-scroll should allow content to be scrolled on x and y axis simultaneously

Open CoenWarmer opened this issue 12 years ago • 7 comments

I have an image element that is too wide and too high to fit in the standard viewport. I want to make it scrollable on the x and y axis.

I've tried to wrap it in a <ion-scroll direction="xy"> element. The horizontal scrolling works, but the vertical one bounces back the content.

See http://plnkr.co/edit/oY8Q4hJ8yFoz56RxvF4a?p=preview for an illustration.

When removing scroll=false and adding overflow-scroll="auto" to the ion-content element, it sort of seems to work, but the scrolling is sometimes locked to one axis depending on if you started moving the content up and down or left and right. It should be able to move on both axis simultaneously.

CoenWarmer avatar Mar 16 '14 09:03 CoenWarmer

Forum # 1865 : http://forum.ionicframework.com/t/scrolling-horizontally-and-vertically/1865/8

Possibly related # 2034 : http://forum.ionicframework.com/t/remote-images-reloading/2034

calendee avatar Mar 21 '14 02:03 calendee

A workaround from rek (http://forum.ionicframework.com/t/scrolling-horizontally-and-vertically/1865/9?u=af1)

add position:fixed;display:inline;top:0;right:0;bottom:60px;left:0; for safari . and margin-top:125px;position:fixed;display:inline;top:0;right:0;bottom:60px;left:0; for chrome (mobile ?). To the style of the ios-scroll directive. (values maybe need adjustment)

luxcem avatar Apr 18 '14 10:04 luxcem

the ion scroll is meant to just give you the scrolling attbrute (pull to refresh, infinite-scroll, etc) to an already existing area (well at least to my understanding of it).

That being said, if you don't apply any sizing to it, the scroll-view will just take the size of the content you put in there.

http://plnkr.co/edit/aZpEPdQtZm1Q2W01ORXw?p=preview

.myScroll{
  width:100%; 
  height:90%:
}

mhartington avatar Apr 19 '14 16:04 mhartington

@mhartington There have been many answers in the forum for the core team that suggest that ion-scroll and the old scroll are for controlling scrolling in a specific section of content independent of the main view; so, I think the issue is still valid.

Having said that, your CSS fix does accomplish the desired goal for this scenario. However, I think there are other situations where this might not work. Unfortunately, I can't think of them.

@CoenWarmer do you have another scenario? I know you've done some stuff with maps. Does this solution help?

calendee avatar Apr 21 '14 10:04 calendee

This actually already works. Make sure your scroll area size is smaller than the size of the container element:

<ion-scroll width="500px; height: 500px" direction="xy">
  <img style="width: 1024px; height: 1024px">
</ion-scroll>

This will scroll both in the x and y direction as expected.

mlynch avatar Apr 29 '14 21:04 mlynch

@mlynch with ion-infinite-scroll scrolling horizontally and vertically will call "loadMore()". How to call this only when scrolling vertically?

PedroJusto avatar Oct 28 '14 18:10 PedroJusto

In the below plunker i have some content below the scrollable section. I want to see/scroll-to that content. But i am unable to do so. If i remove scroll="false", i am unable to scroll the image in x and y directions. In android devices it is not working fine. Can some one help on this.

http://plnkr.co/edit/WLWiNo023SRJrSb5UxlH?p=preview

rajeshwarpatlolla avatar Jul 08 '15 06:07 rajeshwarpatlolla