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