#69 : Update logic

This commit is contained in:
Vadim
2021-09-04 20:51:00 +03:00
parent a27cd3bfdf
commit ff17d083e8
3 changed files with 133 additions and 82 deletions

View File

@@ -19,13 +19,6 @@ function createStore() {
})
}
function setCurrentPageIndex(index) {
update(store => ({
...store,
currentPageIndex: index,
}))
}
function moveToPage({ pageIndex, pagesCount }) {
update(store => {
return {
@@ -35,9 +28,9 @@ function createStore() {
})
}
function next({ infinite, pagesCount }) {
function next({ infinite, pagesCount, pagesToScroll }) {
update(store => {
const newCurrentPageIndex = getNextPageIndexFn(infinite)(store.currentPageIndex, pagesCount)
const newCurrentPageIndex = getNextPageIndexFn(infinite)(store.currentPageIndex, pagesCount, pagesToScroll)
return {
...store,
currentPageIndex: newCurrentPageIndex,
@@ -45,9 +38,9 @@ function createStore() {
})
}
function prev({ infinite, pagesCount }) {
function prev({ infinite, pagesCount, pagesToScroll }) {
update(store => {
const newCurrentPageIndex = getPrevPageIndexFn(infinite)(store.currentPageIndex, pagesCount)
const newCurrentPageIndex = getPrevPageIndexFn(infinite)(store.currentPageIndex, pagesCount, pagesToScroll)
return {
...store,
currentPageIndex: newCurrentPageIndex,
@@ -59,7 +52,6 @@ function createStore() {
subscribe,
next,
prev,
setCurrentPageIndex,
init,
moveToPage,
};