I have an image element (a map specifically) that is too wide and too high to fit in the standard viewport.
I’ve tried to wrap it in a <ion-scroll direction="xy" id="map_content"> element. The horizontal scrolling works, but the vertical one bounces back the content.
Not really sure, but is that image loading asynchronously? If so, perhaps test this idea.
Add a timeout (so the image has plenty of time to load, then :
$scope.$broadcast('scroll.resize')
You might also check if you are defining the dimensions of the image.
I’m thinking that the scroller sees no content on load and defines the scroll region right away before the image loads. Then, it needs to be told about the needed change in scroll region.
I’ve played around with it as well and can’t seem to make a difference.
I did notice you are still including angular-touch and angular-router in you head. Those aren’t required at all anymore. They are throwing errors because they aren’t found.
Oh yeah, that was just a remnant of an old ionic base plunker I found to build this example. I’m using the bundle in my projects already. Following the issue with interest.
@coen_warmer
I’m currently working on the same problem: a map that’s too big for smartphone screens and that needs to be scrollable (and pinch-zoomable, but that’s a battle for another day).
It is quite amusing. If you wrap the map in an <ion-content>, you can scroll vertically, but not horizontally.
If you wrap it in an <ion-scroll>, you can do the opposite (horizontally but not vertically). After the initial laugh, I realized where I would need to dig deeper.
I looked at the directives in ionic-angular.js and noticed that they load different css classes: .scroll-content and .scroll-view for <ion-content> and <ion-scroll> respectively.
After some fiddling (or rather ‘plunkering’), I got it to work.
Short answer:
Take your Plunker (as it is!) and add style=“margin-top:125px;position:fixed;display:inline;top:0;right:0;bottom:0;left:0;” to your <ion-scroll> - et voilà! You can now scroll up/down, right/left and diagonally; if you go too far, it bounces back; both scrollbars included.
Long(ish) answer:
First, I just added display: inline;, which kinda works. You can now scroll, but far beyond the image’s edges, without scrollbars and if you scroll down you overlap your other elements.
Next, I added style=“position:fixed;top:0;right:0;bottom:0;left:0;” which gives you scrollbars and the bouncing, but since it’s now in a fixed position, you’re still faced with the overlap problem.
The solution to this problem depends on your page. In the plunker I just added style=“margin-top:125px;”. Cheap, but gets the job done .
@ionicTeam:
Maybe you could just expand your ionScroll directive and load a different css class if the user sets direction to ‘xy’ or ‘yx’.
Great ! thanks @rek, for me it works without the margin-top (on safari / safari mobile) on chrome you need the margin-top : position:fixed;display:inline;top:0;right:0;bottom:60px;left:0; safari . margin-top:125px;position:fixed;display:inline;top:0;right:0;bottom:60px;left:0; chrome (mobile ?).
I’m very interested in your further developments with the pinch-zoomable feature. I’m working on it too.