Phonegap transitions on CSS transforms not rendering. - html

I'm having a bit of trouble working with CSS transitions on phonegap. We're transitioning a transform: translate3d property to have content views slide in and out of view, as well as sliding to reveal a side bar.
Here's an example of the webapp (note the transitions work in browser):
http://ferriesapp.ca/app/
You will see that the transitions work perfectly in browser both on phone and on desktop. But as soon as I "phonegap" it the transitions just don't render. The final position shows up, for example if I hit a departing list item it will show the corresponding arrival list items. But for some reason the animation just doesn't happen on phone gap. The only exception is that it works on iOS7 when put through phonegap, but not iOS 6 or any version of Android.
Here's a small snippet of the code:
Here is what the CSS on the sliding element looks like
#depart-content {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
transform: translate3d(0,0,0);
-webkit-transform: translate3d(0,0,0);
-moz-transform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
-o-transform: translate3d(0,0,0);
}
Here's the animation class:
.animate {
transition: transform 0.2s ease-out;
transition: -webkit-transform 0.2s ease-out;
transition: -moz-transform 0.2s ease-out;
transition: -ms-transform 0.2s ease-out;
transition: -o-transform 0.2s ease-out;
}
And finally the JS that calls it (note this is not the whole function):
$("#depart-content").css({"transform":"translate3d(-100%,0,0)","-webkit-transform":"translate3d(-100%,0,0)","-moz-transform":"translate3d(-100%,0,0)","-o-transform":"translate3d(-100%,0,0)","-ms-transform":"translate3d(-100%,0,0)"});
If anyone has any suggestions they would be hugely appreciated
Thanks!
P.S. I know there is a CSS3 #keyframes rule that works quite well, but I'd rather avoid that for simplicity of code

Your statement about it working on iOS7 but not on iOS6 leads me to believe that this is happening due to your translate3d statement.
I am assuming you put in this line to enable hardware acceleration -
transform: translate3d(0,0,0);
However, there are several reports that this does NOT infact trigger hardware acceleration in iOS 6 devices.
In the article I quoted, the author mentions that using any one of the following commands, will trigger hardware acceleration.
-webkit-transform: translateZ(0);
-webkit-perspective: 1000;
-webkit-backface-visibility: hidden;

Related

Why does this CSS a::after show transition after hovering?

I found some code for a link hover effect and while it works fine, I don't understand why it works.
Specifically:
#navbar a:after {
content: '';
position: absolute;
left: 0;
display: inline-block;
height: 1em;
width: 100%;
border-bottom: 1px solid;
margin-top: 10px;
opacity: 0;
-webkit-transition: opacity 0.35s, -webkit-transform 0.35s;
transition: opacity 0.35s, transform 0.35s;
-webkit-transform: scale(0,1);
transform: scale(0,1);
}
#navbar a:hover:after {
opacity: 1;
-webkit-transform: scale(1);
transform: scale(0.9);
}
This produces an underline effect on the link when hovering.
My question is:
1.) Why doesn't the transition/transform on the a:after take place when the page loads? Why does it only occur when hovering over the element (even though it's not within the hover)?
Although I can obviously see what is occurring from viewing the page, trying to better understand how exactly this works.
I have added one fiddle where you can go and check the code
[https://jsfiddle.net/vickykumarui/96xw3fzv/][1]
Now let me explain what is happening on hover
Initially you have add this code for pseudo element after
transform: scale(0.1); // The scale() function is specified with either one or two values, which represent the amount of scaling to be applied in each direction.
opacity: 1; // initially after element is not visible
Now on hover this property changes to
transform: scale(0.9);
opacity: 1;
When these properties changes it does not changes suddenly but it changes slowly in .35s in animated way from this code
transition: opacity 0.35s, transform 0.35s;
transition is applied on both property opacity and transform and 0.35s is time of transition
Note: Based on your comment if you change initial property to
opacity: 1;
transform: scale(0.9);
You see that coming initially also
It does happen. Change the opacity to 1 in the first rule. You don't see it because it's technically hidden when the page loads. When you hover, the opacity becomes one and becomes visible.

Transform scale() Safari bug when used on elements with border

CSS transform scale() function appears to have a bug on Safari when it's used on elements with a border.
I'm trying to zoom an image on mouse over using transform: scale() function but if the image has a border then it gets pixelated when scaled.
Here is a sample of the same element with the same CSS rules applied (except the border):
Code example: https://jsfiddle.net/m6g4kw30/
div {
text-align: center;
}
img {
height: 100px;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
transition: all .3s ease;
border: 1px solid #000;
margin: 20px;
}
img.noborder {
border: none;
}
img:hover {
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transform: translateZ(0) scale(5);
-moz-transform: scale(5);
-ms-transform: scale(5);
-o-transform: translateZ(0) scale(5);
transform: translateZ(0) scale(5);
}
<div>
<img src="https://via.placeholder.com/1000.png" alt="">
<img src="https://via.placeholder.com/1000.png" class="noborder" alt="">
</div>
CSS transform scale() function appears to have a bug on Safari when it's used on elements with a border.
You can say that again! Unfortunately, the reported bug(s) for this (and similar) issues go back many years, with the following bug referenced in most:
https://bugs.webkit.org/show_bug.cgi?id=27684 (Opened in 07/2009)
If you didn't catch the date, it's a 10 year old bug that's still causing developers issues today! YIKES.
Basically, the issue comes down to Safari rasterizing the layer. On transform/scale, it resizes the layer, however it does not re-render the rasterized layer. In your use-case, the rasterized image is scaled up, but the text/image is blurry.
As for a workaround/fix? There are a couple ways you can "address" this:
1) Force a re-render
A quick/easy fix is to force Safari to re-render your layer when you transform. One way this can be achieved is by applying a CSS property which you then change after transforming (some people have success changing a background-color, for example). For your specific use case, I had luck with the following combination:
img {
outline: 1px solid #000;
border: none;
}
img:hover {
outline: none;
border: 1px solid #000;
}
By toggling those specific values, I was able to force Safari to re-render the rasterized layer, thus rendering a sharp image (similar to the non-border example). Here's a JSFiddle with the full code example: https://jsfiddle.net/gc56brfh/
2) Scale down, then up
Another workaround, documented here, is to set the element's initial size to the "scaled up" dimensions, and then scale down the element until you're ready to scale it up. That way, the element is rasterized to the correct dimensions.
CSS wise, that may look like:
img {
-webkit-transform: translateZ(0) scale(0.2);
height: 250px;
}
img:hover {
-webkit-transform: translateZ(0) scale(1);
}
In the above, we've set the initial size of the img to 250px (this is based on your original css, with images being 50px and then scaled up 5). We then scale down the image by 0.2, resulting in 50px. On hover, we then scale back up to 250px by setting scale(1).
Here's an updated JSFiddle: https://jsfiddle.net/df2zqgnx/
One thing to note is that other CSS properties might need to be updated with this workaround. For example, you'll notice in the fiddle I also needed to update the border from 1px to 5px to compensate for the scaling down.
Anyway, hope this was helpful and one of the solutions works for you!

simple css animation not smooth in Safari

I have a weird behaviour on a website in Safari. I want to expand a menu from height 0px to height 100% with a css transition. This works properly in Firefox, Chrome and Edge. However, in Safari, there is always a breakpoint where the animation stops for a really short period, causing a laggy animation. I checked that no element is on the same z-index. I found a "fix" on a homepage, which is indicated by a comment in the css, but that does not changes anything.
.dropdown-nav{
position: fixed;
display: block;
z-index: 21;
width: 100%;
height: 0;
left: 0;
background-color: white;
top: 0;
padding: 0;
transition: height 0.6s ease-out;
-webkit-transition: height 0.6s ease-out;
-webkit-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
/* Enable hardware acceleration to fix laggy transitions */
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
-o-transform: translateZ(0);
transform: translateZ(0);
}
.dropdown-nav-visible{
height: 100%;
}
In my js-script, I simply toggle the class .dropdown-nav-visible onto the .drop-down-nav
$('#nav-icon4').click(function(e){
e.preventDefault();
$(".dropdown-nav").toggleClass("dropdown-nav-visible");
$(this).toggleClass('open');
});
Here you find the laggy behaviour: https://magnavoce.ch
and here the same setup, but it works: http://dev5.raphael-rapior.com/.
I also tried using animation-duration like suggested in a similiar question on SO. I also tried removing every other part of the site, still the same.
Edit: safari 9 seems to not have this problem, but safari 12
Height transitions are heavy (they recalculate too many things at each frame), if possible you should use transform instead. Other than that, you may try to add will-change: height
ex:
.myNav {
transform: translateY(-100%);
transition: transform 0.15s;
}
.myNavActive {
transform: translateY(0%);
}

Text & Icons appear blurry and move with css transform effect

So I've done a lot of researching regarding this problem especially going through and trying all of the stuff in this thread:
https://stackoverflow.com/questions/15464055/css-transition-effect-makes-image-blurry-moves-image-1px-in-chrome#=
However, filter:blur(0); transform:translateZ(0) only work on laptop screens and not normal IPS flat screens. You still see the shifting and blurring of text. Does anyone have a solution that works for both laptop, normal monitors and across browser ? Below is an example of what happens on normal monitors, notice the shifting of the icons vertically. Below that is the code we're using.
.article-catalogue {
transition: transform .3s ease, box-shadow .3s ease,border .3s ease;
filter: blur(0);
image-rendering: -webkit-optimize-contrast;
transform: translateZ(0);
}
.article-catalogue:hover {
transform: perspective(1px) translateZ(0) scale(1.02);
box-shadow: 0px 12px 40px -10px rgba(51,51,51,.2);
}
One thought, could it be the rollover elements within the card causing the problem ?

Can CSS3 enabled elements make a position transition?

I was just playing around with my portfolio site and noticed that when my (Google Chrome) screen was zoomed in to 400% and focused on the footer, I have some elements that don't match the fluid grid. I know I need to find a fix for this (if you have any ideas / advice on how to position elements for a fantasticly fluid layout, please post them), but when I used the hotkey for 'View as Actual Size', I noticed that an element that I had two separate CSS3 transition-enabled parameters (opacity and width, code located below) applied to it does a smooth, slow transition from the original placement to the place it holds in the 'Actual Size' view.
http://jsfiddle.net/Asustaba/VLw7k/
Apologies if this is confusing. I can attach a link for a video of the transition if anybody needs a better idea of what is happening.
.grower{
-moz-transform: scale(.85);
-webkit-transform: scale(.85);
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
}
.grower:hover{
-moz-transform: scale(1);
-webkit-transform: scale(1);
}
.grower_big{
-moz-transform: scale(1);
-webkit-transform: scale(1);
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
}
.grower_big:hover{
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
}
Has anybody run into this yet? Is it possible to set a transition based movement (ease-in-out) between absolute, relative, or normal-flow positioning of elements? What about when viewed within a parallax-based web layout?
I think you are asking if you can transition the property position. If this is the case then you cannot. Most elements that can be transitioned are ones that use a numerical value. Here is a list of CSS properties that can be transitioned: http://www.w3.org/TR/css3-transitions/#properties-from-css-