mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-19 09:20:35 -04:00
Adopt new isElementInView algorithm
Former-commit-id: e720f26808b0f86e1c119d02fc4b9c0a66b6441a [formerly 44a1f338cfb51fd49aefbb03b23cb202efde3ad3] Former-commit-id: d6b54fe49efc2b7c9a45d323c8db12365d32458a
This commit is contained in:
parent
4fb1a58c7e
commit
4aa2abe430
@ -162,7 +162,10 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
||||
activeElement = activeElement.previousElementSibling || activeElement;
|
||||
var previousElement = activeElement.previousElementSibling || activeElement;
|
||||
if (!uiUtil.isElementInView(previousElement, true)) previousElement.scrollIntoView();
|
||||
if (previousElement === activeElement) document.getElementById('top').scrollIntoView();
|
||||
if (previousElement === activeElement) {
|
||||
document.getElementById('articleListWithHeader').scrollIntoView();
|
||||
document.getElementById('top').scrollIntoView();
|
||||
}
|
||||
}
|
||||
activeElement.classList.add('hover');
|
||||
|
||||
@ -2945,7 +2948,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
||||
var lastRemovedPosition = 0;
|
||||
for (var i = 0; i < images.length; i++) {
|
||||
if (images[i].src) {
|
||||
visibleImage = uiUtil.isElementInView(images[i], true) ? lastRemovedPosition : visibleImage;
|
||||
visibleImage = uiUtil.isElementInView(images[i]) ? lastRemovedPosition : visibleImage;
|
||||
images.splice(i, 1);
|
||||
i--; //If we removed an image, reset the index
|
||||
lastRemovedPosition++;
|
||||
@ -3248,7 +3251,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
||||
//Determine first and last visible images in the current window
|
||||
for (var i = 0; i < images.length; i++) {
|
||||
//console.log("Checking #" + i + ": " + images[i].getAttribute("data-kiwixurl"));
|
||||
if (uiUtil.isElementInView(images[i], true)) {
|
||||
if (uiUtil.isElementInView(images[i])) {
|
||||
//console.log("#" + i + " *is* visible");
|
||||
if (firstVisible == null) {
|
||||
firstVisible = i;
|
||||
|
Loading…
x
Reference in New Issue
Block a user