Fix initial scroll on macOS.
This commit is contained in:
parent
e20770e256
commit
7913d2a82d
|
@ -44,7 +44,10 @@ var IV = {
|
||||||
jumpToHash: function (hash, instant) {
|
jumpToHash: function (hash, instant) {
|
||||||
var current = IV.computeCurrentState();
|
var current = IV.computeCurrentState();
|
||||||
current.hash = hash;
|
current.hash = hash;
|
||||||
window.history.replaceState(current, '');
|
window.history.replaceState(
|
||||||
|
current,
|
||||||
|
'',
|
||||||
|
'page' + IV.index + '.html');
|
||||||
if (hash == '') {
|
if (hash == '') {
|
||||||
IV.scrollTo(0, instant);
|
IV.scrollTo(0, instant);
|
||||||
return;
|
return;
|
||||||
|
@ -216,11 +219,10 @@ var IV = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
init: function () {
|
init: function () {
|
||||||
IV.platform = window.navigator.platform.toLowerCase();
|
var current = IV.computeCurrentState();
|
||||||
IV.mac = IV.platform.startsWith('mac');
|
window.history.replaceState(current, '', IV.pageUrl(0));
|
||||||
IV.win = IV.platform.startsWith('win');
|
IV.jumpToHash(current.hash, true);
|
||||||
|
|
||||||
window.history.replaceState(IV.computeCurrentState(), '');
|
|
||||||
IV.lastScrollTop = window.history.state.scroll;
|
IV.lastScrollTop = window.history.state.scroll;
|
||||||
IV.findPageScroll().onscroll = IV.frameScrolled;
|
IV.findPageScroll().onscroll = IV.frameScrolled;
|
||||||
|
|
||||||
|
@ -310,6 +312,13 @@ var IV = {
|
||||||
scroll: now ? now.scrollTop : 0
|
scroll: now ? now.scrollTop : 0
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
pageUrl: function (index, hash) {
|
||||||
|
var result = 'page' + index + '.html';
|
||||||
|
if (hash) {
|
||||||
|
result += '#' + hash;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
},
|
||||||
navigateTo: function (index, hash) {
|
navigateTo: function (index, hash) {
|
||||||
if (!index && !IV.index) {
|
if (!index && !IV.index) {
|
||||||
IV.navigateToDOM(IV.index, hash);
|
IV.navigateToDOM(IV.index, hash);
|
||||||
|
@ -401,17 +410,20 @@ var IV = {
|
||||||
navigateToDOM: function (index, hash) {
|
navigateToDOM: function (index, hash) {
|
||||||
IV.pending = null;
|
IV.pending = null;
|
||||||
if (IV.index == index) {
|
if (IV.index == index) {
|
||||||
IV.jumpToHash(hash, IV.mac);
|
IV.jumpToHash(hash);
|
||||||
IV.forceScrollFocus();
|
IV.forceScrollFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.history.replaceState(IV.computeCurrentState(), '');
|
window.history.replaceState(
|
||||||
|
IV.computeCurrentState(),
|
||||||
|
'',
|
||||||
|
IV.pageUrl(IV.index));
|
||||||
|
|
||||||
IV.position = IV.position + 1;
|
IV.position = IV.position + 1;
|
||||||
window.history.pushState(
|
window.history.pushState(
|
||||||
{ position: IV.position, index: index, hash: hash },
|
{ position: IV.position, index: index, hash: hash },
|
||||||
'',
|
'',
|
||||||
'page' + index + '.html' + (hash.length ? '#' + hash : ''));
|
IV.pageUrl(index));
|
||||||
IV.showDOM(index, hash);
|
IV.showDOM(index, hash);
|
||||||
},
|
},
|
||||||
findPageScroll: function () {
|
findPageScroll: function () {
|
||||||
|
@ -492,11 +504,11 @@ var IV = {
|
||||||
IV.updateJumpToTop(true);
|
IV.updateJumpToTop(true);
|
||||||
}
|
}
|
||||||
} else if (scroll !== undefined) {
|
} else if (scroll !== undefined) {
|
||||||
IV.scrollTo(scroll, IV.mac);
|
IV.scrollTo(scroll);
|
||||||
IV.lastScrollTop = scroll;
|
IV.lastScrollTop = scroll;
|
||||||
IV.updateJumpToTop(true);
|
IV.updateJumpToTop(true);
|
||||||
} else {
|
} else {
|
||||||
IV.jumpToHash(hash, IV.mac);
|
IV.jumpToHash(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
IV.forceScrollFocus();
|
IV.forceScrollFocus();
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit cf8ef94d0b12f8484e247d6a2d88dd1c11a6b964
|
Subproject commit 7c346c6b042266b5adb116a2114df1d46b37c03f
|
Loading…
Reference in New Issue