reza fixed some bugs

temp
Reza_ashrafi 3 years ago
parent 29bb9849f9
commit 669c4732b2
  1. 18
      src/redux/reducers/scroll.js
  2. 40
      src/utils/scroll.js
  3. 1
      src/views/Home/Landscape/index.js

@ -94,6 +94,8 @@ export default function scrollAction(state = initialState, action) {
data.end data.end
), ),
}, },
page2TopPosition: 0,
page2RotateX: 0,
}; };
case "scroll/page2/mobilePosition": case "scroll/page2/mobilePosition":
return { return {
@ -105,11 +107,13 @@ export default function scrollAction(state = initialState, action) {
2 * height, 2 * height,
2.5 * height 2.5 * height
), ),
page2BoxPosition: { translateX: 32, translateY: 10, rotate: 0 },
}; };
case "scroll/page2/videoPosition": case "scroll/page2/videoPosition":
return { return {
...state, ...state,
page2VideoPosition: scroll.videoLinearFormula(window.scrollY), page2VideoPosition: scroll.videoLinearFormula(window.scrollY),
page2VideoTopPosition: 50,
}; };
case "scroll/page2/videoTopPosition": case "scroll/page2/videoTopPosition":
return { return {
@ -121,6 +125,7 @@ export default function scrollAction(state = initialState, action) {
2.8 * height, 2.8 * height,
3 * height 3 * height
), ),
page2MobilePosition: 6,
}; };
case "scroll/page2/mobileUnit": case "scroll/page2/mobileUnit":
return { return {
@ -130,6 +135,7 @@ export default function scrollAction(state = initialState, action) {
case "scroll/videoTube/top": case "scroll/videoTube/top":
return { ...state, videoTubeTopPosition: scroll.homeScrollHandler(3) }; return { ...state, videoTubeTopPosition: scroll.homeScrollHandler(3) };
case "scroll/test/translateY": case "scroll/test/translateY":
const joiRect = JSON.parse(localStorage.getItem("joiRect"));
return { return {
...state, ...state,
testTranslateY: scroll.linearFormula( testTranslateY: scroll.linearFormula(
@ -139,9 +145,16 @@ export default function scrollAction(state = initialState, action) {
4.5 * height, 4.5 * height,
5 * height 5 * height
), ),
videoTubeTopPosition: 0,
page2VideoPosition: {
width: joiRect.width,
height: joiRect.height,
top: joiRect.top,
left: joiRect.left,
},
}; };
case "scroll/page3/top": case "scroll/page3/top":
return { ...state, page3TopPosition: scroll.homeScrollHandler(4) }; return { ...state, page3TopPosition: scroll.homeScrollHandler(4), testTranslateY : -101 };
case "scroll/page3/testTranslateY": case "scroll/page3/testTranslateY":
return { return {
...state, ...state,
@ -152,9 +165,10 @@ export default function scrollAction(state = initialState, action) {
6.3 * height, 6.3 * height,
7 * height 7 * height
), ),
page3TopPosition : 0,
}; };
case "scroll/page4/top": case "scroll/page4/top":
return { ...state, page4TopPosition: scroll.homeScrollHandler(5) }; return { ...state, page4TopPosition: scroll.homeScrollHandler(5), page3TestTranslateY : 100 };
default: default:
return state; return state;
} }

@ -8,51 +8,51 @@ class scroll {
const height = Number(window.innerHeight); const height = Number(window.innerHeight);
const scrollY = Number(window.scrollY); const scrollY = Number(window.scrollY);
if (index === 1) { if (index === 1) {
if (prevScroll === 0) { if (scrollY === 0) {
return 0; return 0;
}else }else
if (prevScroll > 0 && prevScroll <= height) { if (scrollY > 0 && scrollY <= height) {
return -prevScroll; return -scrollY;
} }
if (prevScroll > height) { if (scrollY > height) {
return -height; return -height;
} }
} else if (index === 2) { } else if (index === 2) {
if (prevScroll === 0) { if (scrollY === 0) {
return height; return height;
} }
if (prevScroll > 0 && prevScroll <= height) { if (scrollY > 0 && scrollY <= height) {
return height - prevScroll; return height - scrollY;
} }
if (prevScroll > 10 * height) { if (scrollY > 10 * height) {
return -1 * height; return -1 * height;
} }
} else if (index === 3) { } else if (index === 3) {
if (prevScroll <= 3.5 * height) { if (scrollY <= 3.5 * height) {
return height; return height;
} }
if (prevScroll > 3.5 * height && prevScroll <= 4 * height) { if (scrollY > 3.5 * height && scrollY <= 4 * height) {
return 4 * height - prevScroll; return 4 * height - scrollY;
} }
if (prevScroll > 10 * height) { if (scrollY > 10 * height) {
return -height; return -height;
} }
} else if (index === 4) { } else if (index === 4) {
if (prevScroll <= 5 * height) { if (scrollY <= 5 * height) {
return height; return height;
} else if (prevScroll > 5 * height && prevScroll < 6 * height) { } else if (scrollY > 5 * height && scrollY < 6 * height) {
return 6 * height - prevScroll; return 6 * height - scrollY;
} }
if (prevScroll === 10 * height) { if (scrollY === 10 * height) {
return -height; return -height;
} }
} else if (index === 5) { } else if (index === 5) {
if (prevScroll <= 7.3 * height) { if (scrollY <= 7.3 * height) {
return height; return height;
} else if (prevScroll > 7.3 * height && prevScroll < 8.3 * height) { } else if (scrollY > 7.3 * height && scrollY < 8.3 * height) {
return 8.3 * height - prevScroll; return 8.3 * height - scrollY;
} }
if (prevScroll === 10 * height) { if (scrollY === 10 * height) {
return -height; return -height;
} }
} }

@ -138,7 +138,6 @@ function Home({
<div <div
className=" flex-col bg-white relative w-full rtl hidden lg:flex" className=" flex-col bg-white relative w-full rtl hidden lg:flex"
style={{ height: "950vh" }} style={{ height: "950vh" }}
onScroll={() => console.log(1)}
> >
{/* <Dots /> */} {/* <Dots /> */}
<Page1 page={1} /> <Page1 page={1} />

Loading…
Cancel
Save