Skip to content

Commit

Permalink
home page (not compeleted)
Browse files Browse the repository at this point in the history
  • Loading branch information
sramezani committed Apr 17, 2020
1 parent 2e10b73 commit 9a1e230
Show file tree
Hide file tree
Showing 16 changed files with 4,029 additions and 1,646 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@component": "./src/component",
"@template": "./src/template",
"@lib": "./src/lib",
"@types": "./src/types",
"@colors": "./src/theme/colors"
}
}],
Expand Down
25 changes: 18 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"test:ci": "jest --ci"
},
"dependencies": {
"@tippyjs/react": "^4.0.0-alpha.4",
"@tippyjs/react": "^4.0.0",
"deep-equal": "^2.0.1",
"downloadjs": "^1.4.7",
"gsap": "^3.2.6",
"next": "^9.3.4",
"react": "16.13.1",
"react-beautiful-dnd": "^13.0.0",
Expand All @@ -33,6 +34,7 @@
"@testing-library/jest-dom": "^5.1.1",
"@testing-library/react": "^10.0.1",
"@types/downloadjs": "^1.4.1",
"@types/gsap": "^1.20.2",
"@types/node": "^13.9.2",
"@types/react": "^16.9.25",
"@types/react-color": "^3.0.1",
Expand Down
3 changes: 3 additions & 0 deletions pages/_app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import withReduxStore from '../../src/lib/with-redux-store';
import { ToastContainer } from 'react-toastify';

import 'tippy.js/dist/tippy.css';
import 'tippy.js/animations/scale.css';

import 'react-tippy/dist/tippy.css';

import 'react-toastify/dist/ReactToastify.css';
import '../../src/theme/main.scss';

Expand Down
1 change: 1 addition & 0 deletions pages/_document/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Document, { DocumentContext } from 'next/document'
import { ServerStyleSheet } from 'styled-components'

// import '@types';
export default class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const sheet = new ServerStyleSheet()
Expand Down
11 changes: 11 additions & 0 deletions pages/home/home.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface IProps {
theme: {
color: string,
fontFamily: string
}
}
export interface IState {
currentPage: number,
activeSlide: number,
canScroll: boolean
}
238 changes: 238 additions & 0 deletions pages/home/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
import React from 'react';
import { connect } from 'react-redux';
import { TweenLite } from "gsap";

import styles from './style.module.scss';

import { IProps, IState } from "./home";

class Home extends React.Component<IProps, IState> {

constructor(props: IProps) {
super(props);
this.state = {
currentPage: 0,
activeSlide: 1,
canScroll: true
};

this.prev = 0;
this.bgImage = null;
this.slide2Text = null;
this.slide3All = null;
this.slide3Img = null;
this.slide3Text = null;
this.myTween = null;
}

prev: number;
bgImage: HTMLDivElement | null;
slide2Text: HTMLDivElement | null;
slide3All: HTMLDivElement | null;
slide3Img: HTMLDivElement | null;
slide3Text: HTMLDivElement | null;
myTween: ReturnType<typeof TweenLite.to> | null;

componentDidMount() {
this.prev = window.scrollY;
// console.log('this.prev', this.prev)
window.addEventListener('scroll', this.handleScroll);
window.addEventListener('keyup', this._handleKeyDown);
// this.myTween = TweenLite.to(this.bgImage, 2, {x: 300 , opacity:0});

}
componentWillUnmount() {
window.removeEventListener('scroll', this.handleScroll);
window.removeEventListener('keyup', this._handleKeyDown);
}

_canScroll = (status: boolean, time: number = 0) => {
setTimeout(() => {
this.setState({
canScroll: status
})
}, time);
}

_animeDown1to2 = () => {
this.myTween = TweenLite.to(this.bgImage, .5, {transform: 'scale(1.8)', top: '45vh', left: '400px'});
this.myTween = TweenLite.to(this.slide2Text, .6, {bottom: '30%', opacity: 1});
this._canScroll(true, 600);
}
_animeDown2to3 = () => {
this.myTween = TweenLite.to(this.bgImage, .5, { top: '-100%', left: '400px', opacity: 0});
this.myTween = TweenLite.to(this.slide2Text, .5, {bottom: '100%', opacity: 0});

// this.myTween = TweenLite.to(this.slide3All, .5, {top: '25%', opacity: 1});
this.myTween = TweenLite.to(this.slide3Text, .7, {bottom: '50%', opacity: 1});
this.myTween = TweenLite.to(this.slide3Img, .5, {bottom: '15%', opacity: 1});
this._canScroll(true, 600);
}

_animeUp2to1 = () => {
this.myTween = TweenLite.to(this.bgImage, .4, {transform: 'scale(1)', top: '15vh', left: '0px'});
this.myTween = TweenLite.to(this.slide2Text, .4, {bottom: '-30%', opacity: 0});
this._canScroll(true, 500);
}

_animeUp3to2 = () => {

this.myTween = TweenLite.to(this.bgImage, .5, { top: '45vh', left: '400px', opacity: 1});
this.myTween = TweenLite.to(this.slide2Text, .5, {bottom: '30%', opacity: 1});

// this.myTween = TweenLite.to(this.slide3All, .5, {top: '100%', opacity: 0});
this.myTween = TweenLite.to(this.slide3Text, .5, {bottom: '-100%', opacity: 0});
this.myTween = TweenLite.to(this.slide3Img, .5, {bottom: '-100%', opacity: 0});
this._canScroll(true, 600);
}

handleScroll = () => {
// if (this.prev > window.scrollY) {
// console.log("scrolling up");
// this._animeSmall();

// }
// else if (this.prev < window.scrollY) {
// console.log("scrolling down");
// this._animeBig()

// }
// this.prev = window.scrollY;
}

_startAnimationDown = () => {
const { activeSlide } = this.state;
console.log('down', activeSlide)
if (activeSlide === 2) {
this._animeDown1to2();
}
else if (activeSlide === 3) {
this._animeDown2to3();
}
}
_startAnimationUp = () => {
const { activeSlide } = this.state;
console.log('up', activeSlide)
if (activeSlide === 1) {
this._animeUp2to1();
}
else if (activeSlide === 2) {
this._animeUp3to2();
}
}

_handleWheel = (e: any) => {
const { activeSlide, canScroll } = this.state;
if (!canScroll) {
return;
}

if (e.deltaY < 0) {
if (activeSlide > 1) {
this.setState({
canScroll: false,
activeSlide: (activeSlide - 1) < 1 ? 1 : activeSlide - 1
}, () => {
this._startAnimationUp()
})
}
}
else {
if (activeSlide < 3) {
this.setState({
canScroll: false,
activeSlide: activeSlide + 1
}, () => {
this._startAnimationDown()
})
}
}
}

_handleKeyDown = (e: any) => {
const { activeSlide, canScroll } = this.state;
if (!canScroll) {
return;
}
if (e.keyCode === 38) {
if (activeSlide > 1) {
this.setState({
canScroll: false,
activeSlide: (activeSlide - 1) < 1 ? 1 : activeSlide - 1
}, () => {
this._startAnimationUp()
})
}
}
else if (e.keyCode === 40) {
if (activeSlide < 3) {
this.setState({
canScroll: false,
activeSlide: activeSlide + 1
}, () => {
this._startAnimationDown()
})
}
}
}

render() {
return (
<div className={styles.homePage}>
{/* <nav className={styles.nav}>
safsa
</nav> */}


<div
className={[styles.slide, styles.slide1].join(' ')}
onWheel={(e) => this._handleWheel(e)}
// onKeyDown={(e) => this._handleKeyDown(e)}
>
<div className={styles.container}>

<div ref={e => this.bgImage = e} className={styles.firstImg}>
<img src="/bg2.png" alt="first slide image home page" />
</div>

<div className={[styles.slide2].join(' ')} ref={e => this.slide2Text = e}>
<h2>Second Component</h2>
<p>
Second Component Second Component Second Component Second Component Second Component
Second Component Second Component Second Component Second Component Second Component
Second Component Second Component Second Component
</p>
</div>

<div className={[styles.slide3].join(' ')} ref={e => this.slide3All = e}>
<div className={styles.slide3ImgBox} ref={e => this.slide3Img = e}>
<img src="/resume.png" alt="resume image" />
</div>
<div ref={e => this.slide3Text = e} className={styles.slide3text}>
<p>
test test test test test test test test test test test test test test test
test test test test test test test test test test test test test test test
</p>
</div>
</div>

</div>


</div>



</div>
);
}
}

const mapStateToProps = (store:any) => ({
theme: store.theme,
});

const mapDispatchToProps = () => ({
});

export default connect(mapStateToProps, mapDispatchToProps)(Home);
Loading

0 comments on commit 9a1e230

Please sign in to comment.