1
0
mirror of https://github.com/flarum/core.git synced 2025-05-09 00:45:25 +02:00

Clean up scrolling code

This commit is contained in:
Toby Zerner 2015-02-06 12:21:24 +10:30
parent 73d6b17963
commit 46ed231c54

View File

@ -180,16 +180,14 @@ export default Ember.Component.extend({
}, },
scrollToItem: function($item, noAnimation) { scrollToItem: function($item, noAnimation) {
var $container = $('html, body'); var $container = $('html, body').stop(true);
if ($item.length) { if ($item.length) {
var marginTop = this.getMarginTop(); var marginTop = this.getMarginTop();
var scrollTop = $item.is(':first-child') ? 0 : $item.offset().top - marginTop; var scrollTop = $item.is(':first-child') ? 0 : $item.offset().top - marginTop;
if (scrollTop !== $(document).scrollTop()) {
if (noAnimation) { if (noAnimation) {
$container.stop(true).scrollTop(scrollTop); $container.scrollTop(scrollTop);
} else { } else if (scrollTop !== $(document).scrollTop()) {
$container.stop(true).animate({scrollTop: scrollTop}); $container.animate({scrollTop: scrollTop});
}
} }
} }
return $container.promise(); return $container.promise();