1
0
mirror of https://github.com/flarum/core.git synced 2025-01-18 06:38:25 +01: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) {
var $container = $('html, body');
var $container = $('html, body').stop(true);
if ($item.length) {
var marginTop = this.getMarginTop();
var scrollTop = $item.is(':first-child') ? 0 : $item.offset().top - marginTop;
if (scrollTop !== $(document).scrollTop()) {
if (noAnimation) {
$container.stop(true).scrollTop(scrollTop);
} else {
$container.stop(true).animate({scrollTop: scrollTop});
}
if (noAnimation) {
$container.scrollTop(scrollTop);
} else if (scrollTop !== $(document).scrollTop()) {
$container.animate({scrollTop: scrollTop});
}
}
return $container.promise();