Skip to content

Commit

Permalink
use requestAnimationFrame for resizing items
Browse files Browse the repository at this point in the history
 - Fixes issue where images are briefly visible with the incorrect size
   when using setTimeout. This won't work in IE9 but is good for IE10+
   and all other modern browsers.
  • Loading branch information
Isaac Ezer committed Sep 27, 2016
1 parent 0690ec2 commit f139d17
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions jquery.flexslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -922,21 +922,21 @@
// VERTICAL:
if (vertical && !carousel) {
slider.container.height((slider.count + slider.cloneCount) * 200 + "%").css("position", "absolute").width("100%");
setTimeout(function(){
window.requestAnimationFrame(function(){
slider.newSlides.css({"display": "block"});
slider.doMath();
slider.viewport.height(slider.h);
slider.setProps(sliderOffset * slider.h, "init");
}, (type === "init") ? 100 : 0);
});
} else {
slider.container.width((slider.count + slider.cloneCount) * 200 + "%");
slider.setProps(sliderOffset * slider.computedW, "init");
setTimeout(function(){
window.requestAnimationFrame(function(){
slider.doMath();
slider.newSlides.css({"width": slider.computedW, "marginRight" : slider.computedM, "float": "left", "display": "block"});
// SMOOTH HEIGHT:
if (slider.vars.smoothHeight) { methods.smoothHeight(); }
}, (type === "init") ? 100 : 0);
});
}
} else { // FADE:
slider.slides.css({"width": "100%", "float": "left", "marginRight": "-100%", "position": "relative"});
Expand Down

0 comments on commit f139d17

Please sign in to comment.