JavaScript zindex rotation Safari desktop and iPad - ipad

My program works using the desktop using Chrome, Firefox, Opera. It does work on my Android phone. I want it to work on iPad. It does not work on desktop Safari or Chrome on the iPad, so it is Safari AND Chrome on the iPad.
The program dynamically creates canvas elements. At some point, certain of the elements are rotated in an animation and then re-positioned over other elements. This involves changing zIndex values using JavaScript. The program is here: http://faculty.purchase.edu/jeanine.meyer/twisttest.html
After code doing rotation (that does work):
for (var ci=currentseg;ci<NoS;ci++) {
c = strandCanvases[sB][ci];
c.style.webkitTransform = "rotateY("+degree+"deg)";
c.style.MozTransform = "rotateY("+degree+"deg)";
c.style.msTransform = "rotateY("+degree+"deg)";
c.style.OTransform = "rotateY("+degree+"deg)";
c.style.transform = "rotateY("+degree+"deg)";
}
then this doesn't work appear to change the zIndex values (on desktop Safari or iPad Safari or Chrome)
for(var i=0;i<NoSX;i++) {
sAcanseg = strandCanvases[sAnow][segN+i];
sBcanseg = strandCanvases[sBnow][segN+i];
...
sBcanseg.style.zIndex = "100";
sAcanseg.style.zIndex = "0";
}
Some of the elements are okay and some are not.
Note: the following does work fine on desktop and iPad and Android phone: http://faculty.purchase.edu/jeanine.meyer/braid.html

As another answer points it out, this z-index is not working when 3d transforms are enabled possibly due to this bug.
Possible solution
is to apply -webkit-transform: rotateY(ANG_DEG) translate3d(0,0, Z_IDX) transformation, so you basically will use the z-depth in the 3d space to position your elements.
So in your it should be something like:
c.style.webkitTransform = "rotateY("+degree+"deg) translate3D(0,0, " + zValue + ")";
and only for the ipad.
Note
Chrome on iPad uses the same rendering engine as Safari, so there is not much difference between the two browsers.

Related

Mat-Autocomplete options go under the screen on iOS

I'm facing 2 problems with Angular Material Autocomplete component positioned on the bottom of the browser screen.
The input field is covered by the keyboard, I found this solution that works but I don't know if it's the correct one for this type of issue
document.getElementById("searchInput").onfocus = () => {
window.scrollTo(0, window.outerHeight);
document.body.scrollTop = window.outerHeight;
}
The autocomplete options go under the keyboard so the user cannot make a selection.
I tried with Windows 10 + Chrome 73, also with my Android smartphone Xiaomi Mi A1 + Chrome 74 and all works fine, but with IPhone 7 + Chrome 74 I got troubles.
Here you can find the code that I'm using: Stackblitz - Material autocomplete

-webkit-animation-play-state not working on iOS 8.1 (probably lower too)

I have an animation running on page load and with javascript I add a class containing the
-webkit-animation-play-state:paused;
Working fine on OSX safari and all other browsers (even PC) too but on mobile, only on iOS that the animation doesn't seem to paused when called.
Here's a fiddle on how the animation state is running and paused.
http://jsfiddle.net/uc9c5/2/
Try it on iOS, you'll see that it's totally ignored.
Workaround approach for iOS 8-9 Safari that use -webkit-animation: none !important; instead of -webkit-animation-play-state:paused;
This approach is for GWD, but can apply otherwise
Don't use Pause event in GWD (Google Web Designer)
Create normal event that calls a javascript function, set "-webkit-animation: none !important;" to the <div> (you can add/remove css class)
CSS Style
.no-animation {
-webkit-animation: none !important;
}
Javascript
div.className = div.className + " no-animation";
To resume, remove CSS class
Javascript
div.className = div.className.replace("no-animation", '');
Please note that when remove/pause animation, it will go back to frame 0 (00:00 s), so you may need to calculate the current opacity/position for the div
http://jsfiddle.net/duchuy/pczsufL9/

Is there a bug in the new iOS 7.1 minimal-ui viewport setting?

The new "minimal ui" setting in iOS 7.1 is great for landscape websites. My web app uses a fullscreen, absolute positioned div for its content, to give it an app-like feeling. But Safari seems to add just the height of the URL bar at the bottom. I have tried this on different iPhones, same result...
Here is how it looks after the pages loaded:
Is this a bug or something I am doing wrong or missing?
Click for example (view on iPhone with iOS >= 7.1)
I had same problem with iPhone5+ios7.1+minimal-ui. This code successfully fixes this trouble.
window.addEventListener('scroll', function () {
// Do not scroll when keyboard is visible
if (document.activeElement === document.body && window.scrollY > 0) {
document.body.scrollTop = 0;
}
}, true);
check out this post: Gray area visible when switching from portrait to landscape using iOS 7.1 minimal-ui
this fixed it for me:
window.scrollTo(0,0);
setting every time a resize event occurs.
$(window).resize(function(){
document.body.scrollTop = 0;
})

iframe scaling on ipad: click area corrupted

good day.
on ipad, scaling iframes using -webkit-transform: scale(2) corrupts iframe's clickable area:
click a link fails and shows the marked clicked area
in a different location from the link.
only on ipad. http://jsfiddle.net/adamhor/PCpuV/
.
$("iframe").contents().find("body").html('<br><br>'+
'link1<br>'+
'link2');
$("iframe").css({
'-webkit-transform': 'scale(2)',
'-webkit-transform-origin': '0 0'
});
i saw this solution CSS3 Transform scaling issue on IPad Safari
but i cant access iframe itself because of cross domain (i rather not get into)
thanks in advance!

List of known "Safari on iPad" differences over "Desktop Safari"

In recently testing a web application on Windows/Mac desktop browsers - and then on an iPad I noticed various differences in Safari that I wasn't expecting. Even though the version # is the same.
I'd like to compose a list of those differences (for myself and others) to have as a developer reference.
e.g. in Safari on the iPad
iPad Safari takes full control of Select list/option styling
iPad opens the onscreen keyboard when an input element receives focus, thus inline floating calendar widgets (and the like) may not work as expected (or need to be altered)
iPad Safari doesn't support position:fixed like desktop Safari < iOS 5
iPad Safari (similar to iPhone/iPodTouch Safari) automatically hyperlinks 10 digit numbers to offer phone #/contact options
iPad Safari prompt('long message...','default'); shows only 1 line of the message (though it does provide scrolling of the message
I've heard from others that certain JavaScript doesn't work, etc. etc. but I have yet to fully test it thus I'd be grateful for any discoveries that you may have encountered.
A few more for you:
No Flash
Lousy iFrame support (so facebook like etc. needs a custom implementation for iPad)
Weird caching limitations
HTML textAreas doesn't get a scroll bar (you have to double-finger swipe - which of course, is amazingly intuitive)
In general. Treat it like a scaled up iPhone, not a scaled down Desktop.
I thought this might be useful: Apple's guide to preparing web content for the iPad
Just been caught out by the position:fixed issue my self
Safari on iPad has the same issue with button width/padding as on the iPhone
iPhone <button> padding unchangeable? describes this problem and a solution for removing padding on a button with text, but this does not help you if you want a button to be narrower than the padding itself (e.g. for a button that only has a small icon on it). To do that, I had to surround the button with an outer element with a defined width and overflow: hidden like so:
<span style="border: solid 1px blue; display: block; width: 16px; overflow: hidden">
<button style="-webkit-appearance: none; border-width: 0"> </button>
</span>
(the blue border is to show where the button is, it's not critical to the hack)
jQuery's offset() doesn't work: http://bugs.jquery.com/ticket/6446
It also looks like iPad Safari has issues with elements with overflow:auto; that therefore should show scrollbars (test page with div's and iframe's).
iPad Safari seems to have trouble handling background images in rare cases, showing weird lines of lower lying content.
There's not a lot about this in Google (yet).
iPad browser doesnt support file uploading(even if it supports it will useless as iPad does not have a standard File Browser). The file field appears with a Choose File button grayed out.
Beside doesn't support scrollbar in TextAea, it seems that we can using javascript to make text in TextArea selected automatically too.
This code will only move cursor to the end of text in TextArea.
<div>
<textarea id="text-embed-code" autocapitalize="off" multiline="">
There is a fox running after chrome.
</textarea>
<button onclick="testSelectText(event);">select text</button>
</div>
<script>
function testSelectText(e) {
var box = document.getElementById("text-embed-code");
box.select();
e.preventDefault();
return false;
}
</script>
There appears to be a bug in iPad Safari where a CSS element with both a background image and a background color is rendered with a slight border in the color of the background color. It should fill with the background image all the way to the edge of the rendered element.
I just had the same bug on my site, when trying to view it on an Ipad. The HTML structure is like:
<div class="main"> <!-- background-color: white -->
<div class="left"></div> <!-- background-image: url(some_transparent_png) -->
<div class="content">...</div>
<div class="right"></div> <!-- background-image: url(some_transparent_png) -->
</div>
The left layer uses a background-image, whereas the main layer uses just a background-color. The Ipad view shows a slight border at the edge of the left and right layer.
When i add
-webkit-background-size: 100% 100%;
to the left and right layer, the border disappears.
You can now control the styling of select lists on iOS by resetting it with -webkit-appearance: none;
This rule fixes animation flickering in Safari on iOS devices:
body {-webkit-transform:translate3d(0,0,0);}
There appears to be a bug in iPad Safari where a CSS element with both a background image and a background color is rendered with a slight border in the color of the background color. It should fill with the background image all the way to the edge of the rendered element.
24 bit transparent PNGS ABOVE A CERTAIN FILE SIZE don't render on the iPad2.
I can however get 8 bit ones of the same dimensions to render.
I haven't found out what this maximum file size is in order to get them to render.
I'm currently working on a small responsive web-app which makes heavy use of the iframe youtube api. Apparently the ipad version of safari doesn't support a few html5 methods which I use heavily in this project.
One of them is window.postMessage, which is a way of interacting with scripts on other pages, for example the a script that is used "within" that iframe. Autoplaying videos also doesn't work.
Frame problems. iPad Safari will both hide scrollbars and expand frames to the size of their content.
Changing the frame tag to include scrolling="yes" and noresize="noresize" appears to do nothing.
Some sites look fine on everything, even a Dreamcast browser, but not on iPad. The issue can be fixed using tables and iframes instead of normal framesetting (cols and rows, etc).
I also discovered that contenteditable is not supported in mobile safari, thus using a plain textarea is a better bet. Apple Developer Docs
position: fixed;
Does not work in iOS 4 but does work on iOS 5.

Resources