diff --git a/src/App.scss b/src/App.scss
index 0274b78..0c0dbc1 100644
--- a/src/App.scss
+++ b/src/App.scss
@@ -1,6 +1,7 @@
@import "./constants/size.scss";
@import "./views/Home/Page1/index.scss";
@import "./views/Home/Page2/index.scss";
+@import "./views/Home/Page2/Mobile/index";
*{
font-family: Regular;
diff --git a/src/assets/images/qrImage.png b/src/assets/images/qrImage.png
new file mode 100644
index 0000000..713d29b
Binary files /dev/null and b/src/assets/images/qrImage.png differ
diff --git a/src/utils/scroll.js b/src/utils/scroll.js
index db366f0..5b1d532 100644
--- a/src/utils/scroll.js
+++ b/src/utils/scroll.js
@@ -91,6 +91,14 @@ class scroll {
// }
// }
};
+
+ linearFormula = (currentScroll, position1, position2, scroll1, scroll2 ) => {
+ const alpha = (currentScroll - scroll1) / (scroll2 - scroll1);
+ const deltaPosition = position2 - position1;
+ const currectPosition = position1 + deltaPosition * alpha;
+ return currectPosition;
+ }
+
}
const _scroll = new scroll();
diff --git a/src/views/Home/Page2/Mobile/index.js b/src/views/Home/Page2/Mobile/index.js
new file mode 100644
index 0000000..72b5aa4
--- /dev/null
+++ b/src/views/Home/Page2/Mobile/index.js
@@ -0,0 +1,63 @@
+import React, { useEffect, useState } from "react";
+import _ from 'lodash';
+
+export default function Mobile({ mobilePosition }) {
+ const [checked, setChecked] = useState(mobilePosition > 0 ? true : false);
+ useEffect(() => {
+ if (mobilePosition > 0) {
+ setChecked(true);
+ } else {
+ setChecked(false);
+ }
+ }, [mobilePosition]);
+
+ return (
+
+ );
+}
diff --git a/src/views/Home/Page2/Mobile/index.scss b/src/views/Home/Page2/Mobile/index.scss
new file mode 100644
index 0000000..7306440
--- /dev/null
+++ b/src/views/Home/Page2/Mobile/index.scss
@@ -0,0 +1,18 @@
+.scanner{
+ animation-name : scanner;
+ animation-iteration-count: infinite;
+ animation-duration: 1.8s;
+ animation-timing-function: ease;
+}
+
+@keyframes scanner {
+ 0% {
+ top : 10%;
+ }
+ 50%{
+ top : 38%;
+ }
+ 100%{
+ top : 10%;
+ }
+}
\ No newline at end of file
diff --git a/src/views/Home/Page2/index.js b/src/views/Home/Page2/index.js
index 27cf7cd..66b2018 100644
--- a/src/views/Home/Page2/index.js
+++ b/src/views/Home/Page2/index.js
@@ -1,6 +1,8 @@
import React, { useState, useEffect } from "react";
import _ from "lodash";
import scroll from "../../../utils/scroll";
+import Mobile from './Mobile';
+import qrImage from '../../../assets/images/qrImage.png';
export default function Page2({ list, page }) {
const height = window.innerHeight;
@@ -13,33 +15,65 @@ export default function Page2({ list, page }) {
const [mobilePosition, setMobilePosition] = useState(null);
useEffect(() => {
setMobilePosition(
- boxPositionFormula(
+ scroll.linearFormula(
window.scrollY > 3 * height ? 3 * height : window.scrollY,
- -(window.innerHeight * 7) / 20,
- 1.37,
- "increase"
+ -(((window.innerHeight * 10) / 20 / window.innerWidth) * 100),
+ 6,
+ 2 * height,
+ 3 * height
)
);
- setBoxPosition({
- translateY: boxPositionFormula(
- window.scrollY > 2 * height ? 2 * height : window.scrollY,
- 5,
- 7,
- "increase"
- ),
- translateX: boxPositionFormula(
- window.scrollY > 2 * height ? 2 * height : window.scrollY,
- -12,
- 1.5,
- "increase"
- ),
- rotate: boxPositionFormula(
- window.scrollY > 2 * height ? 2 * height : window.scrollY,
- 5,
- 10,
- "decrease"
- ),
- });
+ if (window.scrollY < 2.5 * height) {
+ setBoxPosition({
+ translateY: scroll.linearFormula(
+ window.scrollY > 2 * height ? 2 * height : window.scrollY,
+ -5,
+ 10,
+ height,
+ 2 * height
+ ),
+ translateX: scroll.linearFormula(
+ window.scrollY > 2 * height ? 2 * height : window.scrollY,
+ -5,
+ 32,
+ height,
+ 2 * height
+ ),
+ rotate: scroll.linearFormula(
+ window.scrollY > 2 * height ? 2 * height : window.scrollY,
+ 5,
+ 0,
+ height,
+ 2 * height
+ ),
+ });
+ } else if (window.scrollY > 3 * height) {
+ setBoxPosition({
+ ...boxPosition,
+ translateY: scroll.linearFormula(
+ window.scrollY > 2.5 * height ? 2.5 * height : window.scrollY,
+ -30,
+ -30,
+ 2.5 * height,
+ 3 * height
+ ),
+ translateX: scroll.linearFormula(
+ window.scrollY > 2.5 * height ? 2.5 * height : window.scrollY,
+ 32,
+ 32,
+ 2.5 * height,
+ 3 * height
+ ),
+ rotate: scroll.linearFormula(
+ window.scrollY > 2.5 * height ? 2.5 * height : window.scrollY,
+ 0,
+ 0,
+ 2.5 * height,
+ 3 * height
+ ),
+ });
+ }
+
window.addEventListener("scroll", (e) => {
setTop(scroll.homeScrollHandler(page));
boxPositionHandler(window.scrollY);
@@ -50,56 +84,66 @@ export default function Page2({ list, page }) {
const boxPositionHandler = (scrollY) => {
if (scrollY <= height) {
setBoxPosition({
- translateY: 5,
- translateX: -15,
+ translateY: -5,
+ translateX: -5,
rotate: 5,
});
- } else if (scrollY > height && scrollY <= 2 * height) {
+ }
+ if (scrollY > height && scrollY <= 2 * height) {
+ setBoxPosition({
+ ...boxPosition,
+ translateY: scroll.linearFormula(scrollY, -5, 10, height, 2 * height),
+ translateX: scroll.linearFormula(scrollY, -5, 32, height, 2 * height),
+ rotate: scroll.linearFormula(scrollY, 5, 0, height, 2 * height),
+ });
+ }
+ if (scrollY > 2.5 * height && scrollY <= 3 * height) {
setBoxPosition({
...boxPosition,
- translateY: boxPositionFormula(scrollY, 5, 7, "increase"),
- translateX: boxPositionFormula(scrollY, -12, 1.5, "increase"),
- rotate: boxPositionFormula(scrollY, 5, 10, "decrease"),
+ translateY: scroll.linearFormula(
+ scrollY,
+ 10,
+ -30,
+ 2.5 * height,
+ 3 * height
+ ),
+ translateX: scroll.linearFormula(
+ scrollY,
+ 32,
+ 32,
+ 2.5 * height,
+ 3 * height
+ ),
+ rotate: scroll.linearFormula(scrollY, 0, 0, 2.5 * height, 3 * height),
});
} else {
- // setBoxPosition({
- // translateY: 12,
- // translateX: 15,
- // rotate: 0,
- // });
}
};
const mobilePositionHandler = (scrollY) => {
if (scrollY <= 2 * height) {
- setMobilePosition(-70);
- } else if (scrollY > 2 * height && scrollY <= 3 * height) {
setMobilePosition(
- boxPositionFormula(
- scrollY - height,
- (-(window.innerHeight * 7) / 20 / window.innerWidth) * 100,
- 1.3,
- "increase"
+ -(((window.innerHeight * 10) / 20 / window.innerWidth) * 100)
+ );
+ } else if (scrollY > 2 * height && scrollY <= 2.5 * height) {
+ setMobilePosition(
+ scroll.linearFormula(
+ scrollY,
+ -(((window.innerHeight * 10) / 20 / window.innerWidth) * 100),
+ 6,
+ 2 * height,
+ 2.5 * height
)
);
}
};
- const boxPositionFormula = (scrollY, first, speed, direction) => {
- console.log(scrollY);
- if (direction === "increase") {
- return first + (((scrollY - height) / scrollY) * 100) / speed;
- } else {
- return first - (((scrollY - height) / scrollY) * 100) / speed;
- }
- };
-
- // const mobilePositionFormula = (scrollY) => {
- // return - + ((scrollY - 2 * height) / height * 100);
- // };
return (
{/* mobile phone */}
-
- {mobilePosition}
-
+
);
}