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

iframe content scroll issue

Open pk1u opened this issue 12 years ago • 23 comments

iframe content doesn't scroll properly when touch is initiated, eg, in the center of the content. It will scroll if touch is initiated on the left or right edge of the content. Not sure if this is related to closed issue iframes block scrolling #306 .

I'm using Ionic v1.0.1-beta, Cordova v3.4.1-0.1.0, iOS 7.1 .

eg, I replaced the tab-dash.html content, generated via ionic start myApp tabs, with:

<ion-view title="Dashboard">
  <ion-content scroll="true" class="has-header padding">
    <h1>Dashboard0</h1>

<iframe src="http://xkcd.com" style="width:100%;height:100%"></iframe>

  </ion-content>
</ion-view>

pk1u avatar Apr 17 '14 00:04 pk1u

To be honest, we have absolutely no idea about this either. iFrames can be really annoying.

I don't know the answer to either of these questions:

  1. Why this happens
  2. If it's possible to fix

Do you have any insight?

ajoslin avatar Apr 29 '14 17:04 ajoslin

May not be an Ionic issue, and may be that iframes need special handling in iOS webkit; 2 semi-fixes ( scrolling can be initiated from within the iframe, but some content is clipped on the left and right sides ). With this, perhaps you can make a final call on whether to close this issue ?

  1. See alexjeen's comment: https://github.com/fancyapps/fancybox/issues/2
<style>
  .iframe-issue {
    -webkit-overflow-scrolling: touch !important;
    overflow: scroll !important;
  }
</style>

<ion-view title="Dashboard">
  <ion-content scroll="true" class="has-header padding iframe-issue">
    <h1>Dashboard0</h1>

<iframe src="http://xkcd.com" style="width:100%;height:100%"></iframe>

  </ion-content>
</ion-view>
  1. Set ion-content overflow-scroll attribute to "true"
<ion-view title="Dashboard">
  <ion-content scroll="true" overflow-scroll="true" class="has-header padding">
    <h1>Dashboard00</h1>

<iframe src="http://xkcd.com" style="width:100%;height:100%"></iframe>

  </ion-content>
</ion-view>

pk1u avatar Apr 29 '14 23:04 pk1u

Hey @pk1u, is this still an issue? Using data-tap-disabled="true" should help.

Seems to be working now. http://codepen.io/perrygovier/pen/eGplD Let me know if that's not the case.

perrygovier avatar Sep 23 '14 22:09 perrygovier

@perrygovier I loaded that codepen in my iPhone, and I can't scroll when I start dragging inside the xkcd frame.

JonathanAquino avatar Nov 13 '14 20:11 JonathanAquino

I'm not sure if this bug is about scrolling the content within the iframe, or scrolling the page outside of the iframe.

I hope it is the latter.

For example, if a page has a YouTube video, then I try to scroll the page, initiating the drag on the YouTube video, the page does not scroll.

JonathanAquino avatar Nov 14 '14 05:11 JonathanAquino

I share the same problem

randavidovitz avatar Dec 02 '14 06:12 randavidovitz

+1

tariq7 avatar Dec 02 '14 15:12 tariq7

+1

jodybrewster avatar Jan 11 '15 22:01 jodybrewster

I had the same issue and I fixed with this example: https://github.com/alexgzhou/brandNewiCYL/commit/6d877424896394f78e7efaeccbbeddfb72b487a9

CSS:

.iframe-wrapper iframe {
   width: 100%;
   height: 100%;
 }

HTML:

<ion-content scroll="true" overflow-scroll="true" class="iframe-wrapper">
   <iframe data-tap-disabled="true" src="{{iframeURL}}"></iframe>
</ion-content>

@JonathanAquino, about the YouTube iframes I guess it's because the video catch the tap event. I recommend you to use directly the video iframe in the correct size, then you don't have to do scroll. This is the full video url: https://www.youtube.com/v/{{videoId}}.

jorgecasar avatar Jan 22 '15 22:01 jorgecasar

@jorgecasar solution works for me. Thanks!

jhjwind avatar Jan 26 '15 19:01 jhjwind

+1 same issue

zckrs avatar Jan 30 '15 15:01 zckrs

+1 I tried the approach from @jorgecasar, but this only shows 30px of the iframe (disqus) and will not be able to resize once the content is loaded.

EyMaddis avatar Feb 07 '15 18:02 EyMaddis

@Maddis1337, can you post an example throw codepen and post it in the forum? http://forum.ionicframework.com/t/iframe-scroll-bug/196

jorgecasar avatar Feb 07 '15 18:02 jorgecasar

We need to use Google DFP to place ads in our app. The problem is that DFP/GPT uses iframes to render ads, and when an ad is visible, the user cannot scroll further.

I cannot get this solution to work, an example of the problem can be seen in this codepen. When starting to scroll from within the black iframe, nothing happens. http://codepen.io/anon/pen/bNLqqw

st3fanp avatar Feb 13 '15 16:02 st3fanp

+1 @jorgecasar ! Thank you

This made my day:

<ion-content scroll="true" overflow-scroll="true" class="iframe-wrapper">
   <iframe data-tap-disabled="true" src="{{iframeURL}}"></iframe>
</ion-content>

brickpop avatar May 27 '15 15:05 brickpop

Thank you @jorgecasar your solution solved my problem too.

gere0018 avatar Jul 08 '15 14:07 gere0018

@jorgecasar :+1: :+1: :+1: :+1: :+1: :+1: :+1: :+1: :+1: Thank you

idhamperdameian avatar Sep 01 '15 04:09 idhamperdameian

Great! Worked very well!

rafasegat avatar Dec 01 '15 22:12 rafasegat

The content doesn't fit on the page the iframe does, but you have to scroll to both sides if there's any content, anybody found a solution to that issue?

sickermanex avatar Jan 21 '16 15:01 sickermanex

overflow-scroll="true"

calevano avatar Mar 09 '16 01:03 calevano