parent
69633f5a00
commit
29bb9849f9
15 changed files with 542 additions and 444 deletions
@ -0,0 +1,74 @@ |
||||
const scrollAction = { |
||||
floatMouseToggle: |
||||
(data = null) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "scroll/page1/floatMouse", data }); |
||||
}, |
||||
handlePage1TopPosition: |
||||
(data = null) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "scroll/page1/top", data }); |
||||
}, |
||||
handlePage2TopPosition: |
||||
(data = null) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "scroll/page2/top", data }); |
||||
}, |
||||
handlePage2RotateX: |
||||
(data = window.scrollY) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "scroll/page2/rotateX", data }); |
||||
}, |
||||
handlePage2BoxPosition: |
||||
(data = window.scrollY) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "scroll/page2/boxPosition", data }); |
||||
}, |
||||
handlePage2MobilePosition: |
||||
(data = window.scrollY) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "scroll/page2/mobilePosition", data }); |
||||
}, |
||||
handlePage2VideoPosition: |
||||
(data = window.scrollY) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "scroll/page2/videoPosition", data }); |
||||
}, |
||||
handlePage2VideoTopPosition: |
||||
(data = window.scrollY) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "scroll/page2/videoTopPosition", data }); |
||||
}, |
||||
handlePage2MobileUnit: |
||||
(data = window.scrollY) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "scroll/page2/mobileUnit", data }); |
||||
}, |
||||
handleVideoTubeTopPosition: |
||||
(data = window.scrollY) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "scroll/videoTube/top", data }); |
||||
}, |
||||
handleTestTranslateY: |
||||
(data = window.scrollY) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "scroll/test/translateY", data }); |
||||
}, |
||||
handlePage3TopPosition: |
||||
(data = window.scrollY) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "scroll/page3/top", data }); |
||||
}, |
||||
handlePage3TestTranslateY: |
||||
(data = window.scrollY) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "scroll/page3/testTranslateY", data }); |
||||
}, |
||||
handlePage4TopPosition: |
||||
(data = window.scrollY) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "scroll/page4/top", data }); |
||||
}, |
||||
}; |
||||
|
||||
export default scrollAction; |
@ -0,0 +1,161 @@ |
||||
import scroll from "../../utils/scroll"; |
||||
const height = window.innerHeight; |
||||
const width = window.innerWidth; |
||||
const prevScroll = localStorage.getItem("prevScroll"); |
||||
|
||||
const initialState = { |
||||
page1TopPosition: scroll.homeScrollHandler(1), |
||||
page2TopPosition: scroll.homeScrollHandler(2), |
||||
page2RotateX: scroll.linearFormula( |
||||
scroll.linearFormula( |
||||
prevScroll > height ? height : prevScroll, |
||||
45, |
||||
0, |
||||
0, |
||||
height |
||||
) |
||||
), |
||||
page2BoxPosition: scroll.initializeBoxPosition(prevScroll), |
||||
page2MobilePosition: scroll.linearFormula( |
||||
prevScroll > 2.5 * height ? 2.5 * height : prevScroll, |
||||
-(((height * 10) / 20 / width) * 100), |
||||
6, |
||||
2 * height, |
||||
2.5 * height |
||||
), |
||||
page2VideoPosition: |
||||
prevScroll > 4 * height |
||||
? scroll.videoLinearFormula(4 * height) |
||||
: scroll.videoLinearFormula(prevScroll), |
||||
page2VideoTopPosition: |
||||
prevScroll > 3 * height |
||||
? scroll.linearFormula(3 * height, 70, 50, 2.8 * height, 3 * height) |
||||
: scroll.linearFormula(prevScroll, 70, 50, 2.8 * height, 3 * height), |
||||
page2MobileUnit: scroll.initializeMobileUnit(prevScroll), |
||||
videoTubeTopPosition: scroll.homeScrollHandler(3), |
||||
testTranslateY: scroll.linearFormula( |
||||
prevScroll > 5 * window.innerHeight ? 5 * window.innerHeight : prevScroll, |
||||
0, |
||||
-101, |
||||
4.5 * height, |
||||
5 * height |
||||
), |
||||
page3TopPosition: scroll.homeScrollHandler(4), |
||||
page3TestTranslateY: |
||||
prevScroll < 6.3 * height |
||||
? 0 |
||||
: scroll.linearFormula( |
||||
prevScroll > 7 * height ? 7 * height : prevScroll, |
||||
0, |
||||
100, |
||||
6.3 * height, |
||||
7 * height |
||||
), |
||||
page4TopPosition: scroll.homeScrollHandler(5), |
||||
}; |
||||
|
||||
export default function scrollAction(state = initialState, action) { |
||||
let { type, data } = action; |
||||
switch (type) { |
||||
case "scroll/page1/floatMouse": |
||||
return { ...state, floatMouseToggle: data }; |
||||
case "scroll/page1/top": |
||||
return { ...state, page1TopPosition: scroll.homeScrollHandler(1) }; |
||||
case "scroll/page2/top": |
||||
return { ...state, page2TopPosition: scroll.homeScrollHandler(2) }; |
||||
case "scroll/page2/rotateX": |
||||
return { |
||||
...state, |
||||
page2RotateX: scroll.linearFormula(window.scrollY, 45, 0, 0, height), |
||||
}; |
||||
case "scroll/page2/boxPosition": |
||||
return { |
||||
...state, |
||||
page2BoxPosition: { |
||||
translateY: scroll.linearFormula( |
||||
data.scrollY, |
||||
data.translateY.pos1, |
||||
data.translateY.pos2, |
||||
data.start, |
||||
data.end |
||||
), |
||||
translateX: scroll.linearFormula( |
||||
data.scrollY, |
||||
data.translateX.pos1, |
||||
data.translateX.pos2, |
||||
data.start, |
||||
data.end |
||||
), |
||||
rotate: scroll.linearFormula( |
||||
data.scrollY, |
||||
data.rotate.pos1, |
||||
data.rotate.pos2, |
||||
data.start, |
||||
data.end |
||||
), |
||||
}, |
||||
}; |
||||
case "scroll/page2/mobilePosition": |
||||
return { |
||||
...state, |
||||
page2MobilePosition: scroll.linearFormula( |
||||
window.scrollY, |
||||
-(((height * 10) / 20 / width) * 100), |
||||
6, |
||||
2 * height, |
||||
2.5 * height |
||||
), |
||||
}; |
||||
case "scroll/page2/videoPosition": |
||||
return { |
||||
...state, |
||||
page2VideoPosition: scroll.videoLinearFormula(window.scrollY), |
||||
}; |
||||
case "scroll/page2/videoTopPosition": |
||||
return { |
||||
...state, |
||||
page2VideoTopPosition: scroll.linearFormula( |
||||
window.scrollY, |
||||
70, |
||||
50, |
||||
2.8 * height, |
||||
3 * height |
||||
), |
||||
}; |
||||
case "scroll/page2/mobileUnit": |
||||
return { |
||||
...state, |
||||
page2MobileUnit: scroll.initializeMobileUnit(window.scrollY), |
||||
}; |
||||
case "scroll/videoTube/top": |
||||
return { ...state, videoTubeTopPosition: scroll.homeScrollHandler(3) }; |
||||
case "scroll/test/translateY": |
||||
return { |
||||
...state, |
||||
testTranslateY: scroll.linearFormula( |
||||
window.scrollY, |
||||
0, |
||||
-101, |
||||
4.5 * height, |
||||
5 * height |
||||
), |
||||
}; |
||||
case "scroll/page3/top": |
||||
return { ...state, page3TopPosition: scroll.homeScrollHandler(4) }; |
||||
case "scroll/page3/testTranslateY": |
||||
return { |
||||
...state, |
||||
page3TestTranslateY: scroll.linearFormula( |
||||
window.scrollY, |
||||
0, |
||||
100, |
||||
6.3 * height, |
||||
7 * height |
||||
), |
||||
}; |
||||
case "scroll/page4/top": |
||||
return { ...state, page4TopPosition: scroll.homeScrollHandler(5) }; |
||||
default: |
||||
return state; |
||||
} |
||||
} |
Loading…
Reference in new issue