I have a few functions that based on the scrolling a user does moves elements up and down along a page (imitating a scroll effect.)
In order to make it a little smoother I am using transition: transform 0.7s cubic-bezier(0.49, 0.47, 0.63, 0.85);
(with the proper vender prefixing).
The problem is this works great except for in safari. There -webkit-transition: -webkit-transform 0.7s cubic-bezier(0.49, 0.47, 0.63, 0.85);
causes the animation to jerk around and gives a vibrating effect. I have been reading up on this for ages and have tried setting the perspective property and backface properties but with no luck.
Is there a way to fix this/has anyone seen this? And does Safari not allow transitioning transforms?
Any help in understanding the problem would be amazing.
I found this fiddle http://jsfiddle.net/3yfspjLt/ that shows my problem. If it doesn't blink at first keep scrolling up and down.
For the curious this is my code, however I am more curious about why this bug happens in safari then just my specific use case. (although I am of course trying to find an answer).
JS File
getElementPositions: function(){
var de = document.documentElement;
var windowHight = window.innerHeight;
var page = scrollAnimations.getTopBottom(scrollAnimations.featurePage, de, windowHight);
var profile = scrollAnimations.getTopBottom(scrollAnimations.featureProfile, de, windowHight);
var barOne = scrollAnimations.getTopBottom(scrollAnimations.firstBar, de, windowHight);
var barTwo = scrollAnimations.getTopBottom(scrollAnimations.secondBar, de, windowHight);
var barThree = scrollAnimations.getTopBottom(scrollAnimations.thirdBar, de, windowHight);
scrollAnimations.pageDiff = page.diff;
scrollAnimations.pageStartP = page.top - (page.padding -100);
scrollAnimations.profileDiff = profile.diff;
scrollAnimations.profileStartP = profile.top - (profile.padding/1.3);
scrollAnimations.barOneDiff = barOne.diff;
scrollAnimations.barOneStartTop = barOne.top - (barOne.padding/1.3);
scrollAnimations.barTwoDiff = barTwo.diff;
scrollAnimations.barTwoStartTop = barTwo.top - (barTwo.padding/1.3);
scrollAnimations.barThreeDiff = barThree.diff;
scrollAnimations.barThreeStartTop = barThree.top - (barThree.padding/1.3);
scrollAnimations.startScrollAnimations();
},
getTopBottom: function(el, de, windowHight) {
var result = {};
var box = el.getBoundingClientRect();
result.top = box.top + window.pageYOffset - de.clientTop;
result.bottom = box.bottom + window.pageYOffset - de.clientTop;
result.diff = result.bottom - result.top;
result.padding = windowHight - result.diff;
return result;
},
scrollPage: function(scrollPos){
var pageHeight = scrollAnimations.pageScroll.offsetHeight;
var scrollDiff = scrollPos - scrollAnimations.pageStartP;
var realPos = -scrollDiff/scrollAnimations.pageDiff;
var lengthLeft = pageHeight - scrollAnimations.pageDiff;
if (realPos > 0.09) {
transY = 0.09 * lengthLeft;
} else if(realPos < -1) {
transY = -1 * lengthLeft;
} else {
transY = realPos * lengthLeft;
}
scrollAnimations.pageScroll.setAttribute('style', '-webkit-transform:translate3d(0,' + transY + 'px,0); -moz-transform:translate3d(0,' + transY + 'px,0); -ms-transform:translate3d(0,' + transY + 'px,0); transform:translate3d(0,' + transY + 'px,0);');
if(Modernizr.orientation) {
scrollAnimations.pageScroll.style.transformStyle='preserve-3d';
scrollAnimations.pageScroll.style.webkitTransition='0.4s cubic-bezier(0.49, 0.47, 0.63, 0.85)';
}
},
CSS (I have also tried using all)
#page-scroll {
-webkit-transition: -webkit-transform 0.7s cubic-bezier(0.49, 0.47, 0.63, 0.85);
-moz-transition: transform 0.7s cubic-bezier(0.49, 0.47, 0.63, 0.85);
-ms-transition: transform 0.7s cubic-bezier(0.49, 0.47, 0.63, 0.85);
-o-transition: transform 0.7s cubic-bezier(0.49, 0.47, 0.63, 0.85);
transition: transform 0.7s cubic-bezier(0.49, 0.47, 0.63, 0.85);
}