always scrollcontainer by page width on move
This commit is contained in:
parent
01529cc981
commit
5389d4fc13
1 changed files with 8 additions and 6 deletions
|
@ -162,6 +162,7 @@
|
||||||
|
|
||||||
const moveUpButtonCallback = e => {
|
const moveUpButtonCallback = e => {
|
||||||
var imgContainer = e.target;
|
var imgContainer = e.target;
|
||||||
|
const startingPosition = imgContainer.getBoundingClientRect();
|
||||||
while (!imgContainer.classList.contains("page-container")) {
|
while (!imgContainer.classList.contains("page-container")) {
|
||||||
imgContainer = imgContainer.parentNode;
|
imgContainer = imgContainer.parentNode;
|
||||||
}
|
}
|
||||||
|
@ -169,9 +170,10 @@
|
||||||
if (sibling) {
|
if (sibling) {
|
||||||
pagesContainer.removeChild(imgContainer);
|
pagesContainer.removeChild(imgContainer);
|
||||||
pagesContainer.insertBefore(imgContainer, sibling);
|
pagesContainer.insertBefore(imgContainer, sibling);
|
||||||
imgContainer.scrollIntoView({
|
|
||||||
behavior: "instant",
|
const { width } = imgContainer.getBoundingClientRect();
|
||||||
block: "center",
|
pagesContainerWrapper.scroll({
|
||||||
|
left: pagesContainerWrapper.scrollLeft - width,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -188,9 +190,9 @@
|
||||||
} else {
|
} else {
|
||||||
pagesContainer.appendChild(imgContainer)
|
pagesContainer.appendChild(imgContainer)
|
||||||
}
|
}
|
||||||
imgContainer.scrollIntoView({
|
const { width } = imgContainer.getBoundingClientRect();
|
||||||
behavior: "instant",
|
pagesContainerWrapper.scroll({
|
||||||
block: "center",
|
left: pagesContainerWrapper.scrollLeft + width,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue