mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 13:47:05 +02:00
Fix initial scroll on macOS.
This commit is contained in:
parent
e20770e256
commit
7913d2a82d
2 changed files with 23 additions and 11 deletions
|
@ -44,7 +44,10 @@ var IV = {
|
|||
jumpToHash: function (hash, instant) {
|
||||
var current = IV.computeCurrentState();
|
||||
current.hash = hash;
|
||||
window.history.replaceState(current, '');
|
||||
window.history.replaceState(
|
||||
current,
|
||||
'',
|
||||
'page' + IV.index + '.html');
|
||||
if (hash == '') {
|
||||
IV.scrollTo(0, instant);
|
||||
return;
|
||||
|
@ -216,11 +219,10 @@ var IV = {
|
|||
}
|
||||
},
|
||||
init: function () {
|
||||
IV.platform = window.navigator.platform.toLowerCase();
|
||||
IV.mac = IV.platform.startsWith('mac');
|
||||
IV.win = IV.platform.startsWith('win');
|
||||
var current = IV.computeCurrentState();
|
||||
window.history.replaceState(current, '', IV.pageUrl(0));
|
||||
IV.jumpToHash(current.hash, true);
|
||||
|
||||
window.history.replaceState(IV.computeCurrentState(), '');
|
||||
IV.lastScrollTop = window.history.state.scroll;
|
||||
IV.findPageScroll().onscroll = IV.frameScrolled;
|
||||
|
||||
|
@ -310,6 +312,13 @@ var IV = {
|
|||
scroll: now ? now.scrollTop : 0
|
||||
};
|
||||
},
|
||||
pageUrl: function (index, hash) {
|
||||
var result = 'page' + index + '.html';
|
||||
if (hash) {
|
||||
result += '#' + hash;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
navigateTo: function (index, hash) {
|
||||
if (!index && !IV.index) {
|
||||
IV.navigateToDOM(IV.index, hash);
|
||||
|
@ -401,17 +410,20 @@ var IV = {
|
|||
navigateToDOM: function (index, hash) {
|
||||
IV.pending = null;
|
||||
if (IV.index == index) {
|
||||
IV.jumpToHash(hash, IV.mac);
|
||||
IV.jumpToHash(hash);
|
||||
IV.forceScrollFocus();
|
||||
return;
|
||||
}
|
||||
window.history.replaceState(IV.computeCurrentState(), '');
|
||||
window.history.replaceState(
|
||||
IV.computeCurrentState(),
|
||||
'',
|
||||
IV.pageUrl(IV.index));
|
||||
|
||||
IV.position = IV.position + 1;
|
||||
window.history.pushState(
|
||||
{ position: IV.position, index: index, hash: hash },
|
||||
'',
|
||||
'page' + index + '.html' + (hash.length ? '#' + hash : ''));
|
||||
IV.pageUrl(index));
|
||||
IV.showDOM(index, hash);
|
||||
},
|
||||
findPageScroll: function () {
|
||||
|
@ -492,11 +504,11 @@ var IV = {
|
|||
IV.updateJumpToTop(true);
|
||||
}
|
||||
} else if (scroll !== undefined) {
|
||||
IV.scrollTo(scroll, IV.mac);
|
||||
IV.scrollTo(scroll);
|
||||
IV.lastScrollTop = scroll;
|
||||
IV.updateJumpToTop(true);
|
||||
} else {
|
||||
IV.jumpToHash(hash, IV.mac);
|
||||
IV.jumpToHash(hash);
|
||||
}
|
||||
|
||||
IV.forceScrollFocus();
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit cf8ef94d0b12f8484e247d6a2d88dd1c11a6b964
|
||||
Subproject commit 7c346c6b042266b5adb116a2114df1d46b37c03f
|
Loading…
Add table
Reference in a new issue