mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 00:56:13 +01:00
fix: #7339
This commit is contained in:
@@ -18,10 +18,12 @@ define('handleBack', [
|
|||||||
function saveClickedIndex() {
|
function saveClickedIndex() {
|
||||||
$('[component="category"]').on('click', '[component="topic/header"]', function () {
|
$('[component="category"]').on('click', '[component="topic/header"]', function () {
|
||||||
var clickedIndex = $(this).parents('[data-index]').attr('data-index');
|
var clickedIndex = $(this).parents('[data-index]').attr('data-index');
|
||||||
|
var windowScrollTop = $(window).scrollTop();
|
||||||
$('[component="category/topic"]').each(function (index, el) {
|
$('[component="category/topic"]').each(function (index, el) {
|
||||||
if ($(el).offset().top - $(window).scrollTop() > 0) {
|
if ($(el).offset().top - windowScrollTop > 0) {
|
||||||
storage.setItem('category:bookmark', $(el).attr('data-index'));
|
storage.setItem('category:bookmark', $(el).attr('data-index'));
|
||||||
storage.setItem('category:bookmark:clicked', clickedIndex);
|
storage.setItem('category:bookmark:clicked', clickedIndex);
|
||||||
|
storage.setItem('category:bookmark:offset', $(el).offset().top - windowScrollTop);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -42,10 +44,6 @@ define('handleBack', [
|
|||||||
bookmarkIndex = Math.max(0, parseInt(bookmarkIndex, 10) || 0);
|
bookmarkIndex = Math.max(0, parseInt(bookmarkIndex, 10) || 0);
|
||||||
clickedIndex = Math.max(0, parseInt(clickedIndex, 10) || 0);
|
clickedIndex = Math.max(0, parseInt(clickedIndex, 10) || 0);
|
||||||
|
|
||||||
if (!bookmarkIndex && !clickedIndex) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.usePagination) {
|
if (config.usePagination) {
|
||||||
var page = Math.ceil((parseInt(bookmarkIndex, 10) + 1) / config.topicsPerPage);
|
var page = Math.ceil((parseInt(bookmarkIndex, 10) + 1) / config.topicsPerPage);
|
||||||
if (parseInt(page, 10) !== ajaxify.data.pagination.currentPage) {
|
if (parseInt(page, 10) !== ajaxify.data.pagination.currentPage) {
|
||||||
@@ -57,7 +55,7 @@ define('handleBack', [
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (bookmarkIndex === 0) {
|
if (bookmarkIndex === 0) {
|
||||||
handleBack.highlightTopic(clickedIndex);
|
handleBack.scrollToTopic(bookmarkIndex, clickedIndex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +86,9 @@ define('handleBack', [
|
|||||||
var scrollTo = components.get('category/topic', 'index', bookmarkIndex);
|
var scrollTo = components.get('category/topic', 'index', bookmarkIndex);
|
||||||
|
|
||||||
if (scrollTo.length) {
|
if (scrollTo.length) {
|
||||||
$(window).scrollTop(scrollTo.offset().top);
|
var offset = storage.getItem('category:bookmark:offset');
|
||||||
|
storage.removeItem('category:bookmark:offset');
|
||||||
|
$(window).scrollTop(scrollTo.offset().top - offset);
|
||||||
handleBack.highlightTopic(clickedIndex);
|
handleBack.highlightTopic(clickedIndex);
|
||||||
navigator.update();
|
navigator.update();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user