Optimize Scroll Speed For Internet Explorer 11
I currently have an agenda-like application where the first column is absolute horizontal and the first row absolute vertical. I am achieving this by catching the scroll effect and
Solution 1:
You could try to throttle the functionality of the scroll function every 100ms or 200ms which is still pretty fast each second.
var planningCol = $('.Planning tr > td:first-child'),
planningHead = $('.Planning thead > tr:first-child');
$(window).scroll(function(){
var self = this;
throttle(function(){
planningCol.css({ left: $(self).scrollLeft() });
planningHead.css('top', $(self).scrollTop() + 50 + 'px');
}(), 200); // call your function directly upon return
});
Or you can use CSS on the body, detecting when a page is scrolled
or scrolling
. Then apply .scrolling { pointer-events: none !important; }
which boosts the UI.
Also try to move the selections out of the scroll function if they are always the same.
var win = $(window),
body = $(document.body),
planning = $('.Planning'),
planningCol = planning.find('tr > td').first(),
planningHead = planning.find('thead > tr').first();
win.scroll(function(){
// scrolled
body.toggleClass('scrolled', !!win.scrollTop());
// scrolling
body.addClass('scrolling');
planningCol.css({ left: win.scrollLeft() });
planningHead.css({ top: win.scrollTop() });
setTimeout(function(){
body.removeClass('scrolling');
}, 200);
});
Post a Comment for "Optimize Scroll Speed For Internet Explorer 11"