I'm trying to tie an animation to a window resize. The idea is as the window open an image moves from right to left. It's extremely un-performant, stuttering and repaints. It won't play in and code emulators. Any suggestions?
$(document).ready(function() {
var $window = $(window).width(); //window size to start
function moveIt() {
var $currentWindow = $(window).width(); //window size during animation
if ($window<=$currentWindow) {
var $deltaWindow = $currentWindow - $window; //one direction on open
}
else {
var $deltaWindow = $window - $currentWindow; //the other on close
}
var $fromRight = $deltaWindow + $deltaWindow * 0.3; //sliding instead of fixed in place
$(".one").animate({right: $fromRight});
}
$(window).resize(moveIt);
});
Aucun commentaire:
Enregistrer un commentaire