Prevent Phonegap to slide (iFrames) - ios

I've a question.
I wrote a small app in Dreamweaver CS 5.5, to export it using Phonegap's SKD to an iOS app.
But the problem is: How can I prevent the user from moving the screen up and down when he slides with his fingers? I read on the Phonegap wiki that it is possible with DIV tags. But that won't work for me, because I use an index.html who reffers to frames. I don't use the the body. How can I prevent the user from slide the screen up and down?
index.html:
<html>
<frameset cols="625,*" border=0 framespacing=0 frameborder="0">
<frame src="frames/navbar.htm" scrolling=auto name="main">
<frame src="frames/blank.htm" scrolling=auto>
</frameset>
</frameset>
</frameset>
</html>

Have you checked out this helpful web page?
http://wiki.phonegap.com/w/page/16494815/Preventing-Scrolling-on-iPhone-Phonegap-Applications

You may want to check out iScroll http://cubiq.org/iscroll if you want the content under it to be scrollable with momentum.
Also disabling "touchmove" events will prevent any kind of movement from the user.
document.addEventListener('touchmove',function(event){event.preventDefault()});
iOS 5 gave us support for fixed elements and -webkit-overflow-scrolling: touch; but those don't give the best effect and can sometimes not work as expected.

Related

iOS - Native Scrolling in iFrame

So I have an iFrame displaying a Facebook page and I am trying to enable the native 'bounce' type scrolling however can't get anything to work.
I have tried this:
iframe {
overflow-y: scroll !important;
-webkit-overflow-scrolling: touch !important;
}
But have had no luck so far - tested on both simulator and real iOS device.
Any ideas?
I faced the same problem when our team built epub3 reader app on iOS.
Followed EpubJS v0.3 example, we could handle the problem.
Here is an example:
<div style="width:320px;height:570px;-webkit-overflow-scrolling:touch;overflow-y:scroll;">
<iframe scrolling="no" src="..." style="width:320px;height:8071px;"></iframe>
</div>
Note: you have to calculate iFrame height and set the CSS style (ex: 8071px). Using javascript, you can use
iframe.contentDocument.body.scrollHeight
You may ask me why we have to set height style. Followed some suggestions does not help us to handle handle dynamic content problem (you can see the problem here). By setting height, we can dynamically add or remove highlight texts of users.
Hope that helps,
This would be my approach...
Step 1. Increasing the size of the iframe until the scrollbars dissappear, like this: http://davidjbradshaw.github.io/iframe-resizer/
Step 2. Use David Walsh his trick with a parent div that scrolls the iframe: https://davidwalsh.name/scroll-iframes-ios
But I think it will fail, because of the lack of authentication for cross domain iFrames.
UPDATE: What if you would enlarge the iframe based on the scroll position of the parent div? So parent div scrolls 100px and you make the iframe 100px larger... (given the fact that the iframe has infinite height and assuming its scrollbar is hidden)

How to get a smooth and fast scroll in iOS in a Cordova app without JQuery Mobile script

I am developing a Cordova application which previously used the JQuery mobile 1.4.5 script. A previous problem on Android, where transitioning from a page to another caused unnecessary flickering left me no choice but to remove the call to the JQuery mobile script.
<script src="js/jquery.mobile-1.4.5.js"></script>
Instead I simply left the CSS
<link href="js/jquery.mobile-1.4.5.css" rel="stylesheet" />
and used the JQuery mobile classes to change the styles of inputs, buttons, etc, retaining the previous app style (this was highly important especially considering that the app is almost finished and the design in which jquery mobile was heavily used needed to be retained).
When I did this I found out that on iOS the scrolling was no longer fast and smooth as it was before. I tried to revert to the old method, i.e. having the j-query mobile script and the iOS smooth works normally. This proves that J-Query mobile had some specific script that 'fixes' the iOS scroll. I would like to use just this script to fix the scrolling problems. Apart from this problem, the app works and looks just fine.
Below is the 'template' html of every page. As you can see the jquery-mobile classes that are normally automatically wrapped around the components of the app after the page loads are manually assigned to the specific components.
<html class="ui-mobile js csstransitions">
<head>
</head>
<body class="ui-mobile-viewport ui-overlay-a sidy--panels-closed">
<div class="sidy ui-page ui-page-theme-a ui-page-active">
<nav>Menu</nav>
<nav>Search</nav>
<div class="sidy__content">
<div id="wrapper" class="wrapper">
<div>Fixed header</div>
<div>Container</div>
<div>Fixed Footer</div>
</div>
</div>
</div>
<script></script>
</body>
<html>
I tried to search intensively on stackoverflow and other sources. For e.g. this fix did not work when tried on the tag; as the fixed header and footer move with the scrolling and only restore to their original position when the scrolling operation is finished. When trying to assign the class on the container (where the actual scrolling needs to happen); nothing happens.
cssClass{
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
}
What would be most useful to me is to know which part of the Jquery mobile script makes the iOS scrolling look smooth and native and act very fast!
Thank you for your help!
Your css'ed div needs for IOS (Safari) to have a non-dynamic size in the scroll direction, i.e. the height in your example.
Add a height element:
cssClass{
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
height: ...px;
}
and it should work.
I had the same problem, and was able to solve it with this added property. I use React.JS so, I could easily get computed the height so that it was correct for different devices, adjusted for headers and footers etc. With Javascript you can do compute it with the variable window.innerHeight (at least for Cordova, I don't know if this is a standard browser variable).

iOS Safari Vertical Scrolling Feels Sticky (With No Momentum)

I've got a problem with vertical scroll in iOS Safari on a web page: while being scrolled, page moves in a very slow way, with high resistance (such behavior is not usual for iOS browsers)
My attempts to locate the problem:
<!-- piece of HTML listing -->
<body>
<div id="wrapper">
(here goes some content)
</div>
</body>
I detected the problem in the overflow-x:hidden; rule for div#wrapper, changing it to 'overflow:hidden;' or removing it dynamically in web debugging panel.
Is there any chance to fix it without changing the page layout?
Repeats on Safari / iOS 6.1.4 and 7 (both iPad and iPhone), also in iOS Simulator on OS X.
You can try to add the webkit specific css line to you div:
#wrapper{
-webkit-overflow-scrolling: touch;
}
read more about momentum and ios scrolling here: http://css-tricks.com/snippets/css/momentum-scrolling-on-ios-overflow-elements/

IOS 6.0.1 Safari Scroll pdf in iframe

I am using my webpage to show a pdf from App_Data.
I using this html:
<iframe src="" id="iframePDF" style="width:100%; height:93%;z-index:1;></iframe>
And javascript
$('#iframePDF').attr("src", responseData.TempPath + "#zoom=100&page=1");
The zoom isn't zooming the page and I cannot scroll.
Is there any workaround for this or a solution?
You might be able to scroll using two fingers, which is not intuitive for the user. You can not make the area scrollable unless you know the size of the content, which you can't, because iOS doesn't tell you.
Sorry, friend, but then you'd have to look into a native or hybrid app like the solutions offered by Cordova (PhoneGap). It doesn't matter if the file is in .NET App_Data or anywhere else online.
The reason why it works in your browser is because it has a built-in file viewer which is loaded when you open the file in a new window.
Wrap the iframe in a width-constrained element of some kind then apply this CSS to that element:
-webkit-overflow-scrolling: touch

Whole pdf-file is not displayed through iframe in Mobile Safari on iPad 1/2

I have faced a pretty strange issue. I'm trying to display pdf files using iframe. Little documents, consisting of 1-2 pages, are displayed correctly. But when it comes to documents consisting of for example 5 "heavy" pages, the iframe doesn't display the whole document - the document is cropped and as a result about 2-3 pages are displayed only.
Below is my code. As you can see it's pretty straightforward.
<html>
<head>
<title>Testing iFrames on iPad</title>
</head>
<body>
<iframe id="iframe" name="iframe" height="100%" width="100%" scrolling="no" src="https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariWebContent/SafariWebContent.pdf" />
</body>
Can anyone help me to find out what is the reason for such strange behavior?
From what I understand iframe's height is what's responsible for the page cutting off, as you're actually scrolling the frame, and not the pdf inside the frame (i.e. setting height to "400%" will potentially give you the space you need, but it's sloppy).
This solution uses JavaScript to scroll the pdf contents itself, and may help:
how to properly display an iFrame in mobile safari

Resources