Fix PostStream endless loading due to broken scroll anchor

This commit is contained in:
Toby Zerner 2015-07-22 09:55:20 +09:30
parent 23cd3320c0
commit 5b8705bfc4

View File

@ -12,11 +12,10 @@
* @param {Function} callback The callback to run that will change page content. * @param {Function} callback The callback to run that will change page content.
*/ */
export default function anchorScroll(element, callback) { export default function anchorScroll(element, callback) {
const $element = $(element);
const $window = $(window); const $window = $(window);
const relativeScroll = $element.offset().top - $window.scrollTop(); const relativeScroll = $(element).offset().top - $window.scrollTop();
callback(); callback();
$window.scrollTop($element.offset().top - relativeScroll); $window.scrollTop($(element).offset().top - relativeScroll);
} }