I'm using CSS to make a card flip around and show a kitten. There is a behavior that seems to only exist in Firefox whereby it is constantly shifting / resizing the images by a few pixels. Simply hover over the card back and watch as it moves around a little after the scale animation completes, then flip the card by clicking on it to observe how the kitten readjust its position and size after the animation as well.
Again, this does not happen in Chrome nor Internet Explorer. Can anyone explain what is causing it or provide a remedy?
http://jsfiddle.net/XEDEM/1/
$('.card').mouseover(function() {
$(this).css({
'transform': 'scale(1.2)',
'-webkit-transform': 'scale(1.2)',
'transition': 'transform 500ms',
'-webkit-transition': '-webkit-transform 500ms'
});
}).mouseleave(function() {
$(this).css({
'transform': 'scale(1)',
'-webkit-transform': 'scale(1)',
'transition': 'transform 500ms',
'-webkit-transition': '-webkit-transform 500ms'
});
}).mousedown(function() {
$('div.back').css({
'transform': 'perspective(1000px) rotateY(-180deg) translateZ(0)',
'-webkit-transform': 'perspective(1000px) rotateY(-180deg)',
'transition': 'transform 800ms ease-in-out 300ms',
'-webkit-transition': '-webkit-transform 800ms ease-in-out 300ms'
});
$('.hide').show();
$('div.front').css({
'transform': 'perspective(1000px) rotateY(0) translateZ(0)',
'-webkit-transform': 'perspective(1000px) rotateY(0)',
'transition': 'transform 800ms ease-in-out 300ms',
'-webkit-transition': '-webkit-transform 800ms ease-in-out 300ms',
'backface-visibility': 'hidden',
'-webkit-backface-visibility': 'hidden'
});
});
To pause an element's transition, use getComputedStyle and getPropertyValue at the point in the transition you want to pause it. Then set those CSS properties of that element equal to those values you just got.
Triggering transitions You can trigger CSS transitions directly with pseudo classes like :hover (activates when the mouse goes over an element), :focus (activates when a user tabs onto an element, or when a user clicks into an input element), or :active (activates when user clicks on the element).
-webkit-transition is a non-standard boolean CSS media feature whose value indicates whether vendor-prefixed CSS transition s are supported or not. This media feature is only supported by WebKit. The standards-based alternative is to use a @supports feature query instead.
CSS transitions provide a way to control animation speed when changing CSS properties. Instead of having property changes take effect immediately, you can cause the changes in a property to take place over a period of time.
After some ardent research, this is a known issue with Firefox's sub-pixel rendering. More obvious demonstrations of the effect can be found here and here. The phenomenon is referred to as "pixel snapping" and it occurs rather frequently in Firefox's animation, particularly at the conclusion of a transition.
The solution, which is also proposed in the Bugzilla thread, is to add rotate(0.0001deg)
to the scaling transform. This greatly reduces the effect but does not entirely eliminate it. However, it is the best I can hope for, so I'm accepting it as the answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With