#69 : Update logic
This commit is contained in:
16
src/store.js
16
src/store.js
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user