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:
parent
73d6b17963
commit
46ed231c54
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user