[英]CSS translate3d is very jumpy on Safari 8
我正在研究一个简单的视差行为,而像Skrollr这样的库可能就显得过大了。 我已经取得了一些非常了不起的进步,并且在Chrome和Firefox中一切正常,但是在OSX Safari 8中运动似乎非常迅速。
如果有人可以提供一些如何使之更平滑的见解,我很想听听。 我很惊讶Safari中发生了这种情况,因为我期望它的性能与Chrome类似。
Ive在此处发布了一个仅包含重要部分的演示-http: //playground.philsmartdesign.com.au/work/requestAnimationFrame/
Javascript:
(function (window, document, $, undefined) {
"use strict";
var $window = $(window),
$document = $(document);
$document.ready(function () {
var $image = $('#move-me');
// Method 1 : Using requestAnimationFrame - very jumpy in Safari 8
function raf_handler(timestamp) {
move_image();
window.requestAnimationFrame(raf_handler);
}
window.requestAnimationFrame(raf_handler);
// Method 2 : Binding to scroll event - a little bit smoother, but still jumpy in Safari 8
//$window.on('scroll', move_image);
function move_image(){
var transform = 'translate3d(0px,' + ($window.scrollTop() * 1.3) + 'px, 0px)'; // 3d transform
//var transform = 'translate(0px,' + ($window.scrollTop() * 1.3) + 'px)'; // 2d transform
$image[0].style.webkitTransform = transform;
$image[0].style.MozTransform = transform;
$image[0].style.msTransform = transform;
$image[0].style.OTransform = transform;
$image[0].style.transform = transform;
}
});
})(window, document, jQuery);
就像其他任何东西一样,它在Safari中确实非常跳动...我建议尝试以下位置:绝对; 和顶部:* px;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.