├── .travis.yml ├── src ├── .eslintrc ├── styles.module.css └── index.js ├── .eslintignore ├── example ├── public │ ├── favicon.ico │ ├── manifest.json │ └── index.html ├── src │ ├── index.js │ ├── index.css │ └── App.js ├── README.md └── package.json ├── .editorconfig ├── .prettierrc ├── .eslintrc ├── .gitignore ├── dist ├── index.css ├── index.modern.js ├── index.js ├── index.modern.js.map └── index.js.map ├── README.md └── package.json /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 12 4 | - 10 5 | -------------------------------------------------------------------------------- /src/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "jest": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | build/ 2 | dist/ 3 | node_modules/ 4 | .snapshots/ 5 | *.min.js -------------------------------------------------------------------------------- /example/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FaisalST32/fullpage-react-fs/HEAD/example/public/favicon.ico -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /example/src/index.js: -------------------------------------------------------------------------------- 1 | import './index.css' 2 | 3 | import React from 'react' 4 | import ReactDOM from 'react-dom' 5 | import App from './App' 6 | 7 | ReactDOM.render(, document.getElementById('root')) 8 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "jsxSingleQuote": true, 4 | "semi": false, 5 | "tabWidth": 2, 6 | "bracketSpacing": true, 7 | "jsxBracketSameLine": false, 8 | "arrowParens": "always", 9 | "trailingComma": "none" 10 | } 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | This example was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | It is linked to the fullpage-react-fs package in the parent directory for development purposes. 4 | 5 | You can run `yarn install` and then `yarn start` to test your package. 6 | -------------------------------------------------------------------------------- /example/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "fullpage-react-fs", 3 | "name": "fullpage-react-fs", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /example/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 5 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 6 | sans-serif; 7 | -webkit-font-smoothing: antialiased; 8 | -moz-osx-font-smoothing: grayscale; 9 | } 10 | 11 | code { 12 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 13 | monospace; 14 | } 15 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "extends": [ 4 | "standard", 5 | "standard-react", 6 | "plugin:prettier/recommended", 7 | "prettier/standard", 8 | "prettier/react" 9 | ], 10 | "env": { 11 | "node": true 12 | }, 13 | "parserOptions": { 14 | "ecmaVersion": 2020, 15 | "ecmaFeatures": { 16 | "legacyDecorators": true, 17 | "jsx": true 18 | } 19 | }, 20 | "settings": { 21 | "react": { 22 | "version": "16" 23 | } 24 | }, 25 | "rules": { 26 | "space-before-function-paren": 0, 27 | "react/prop-types": 0, 28 | "react/jsx-handler-names": 0, 29 | "react/jsx-fragments": 0, 30 | "react/no-unused-prop-types": 0, 31 | "import/export": 0 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | 25 | # dependencies 26 | /example/node_modules 27 | /example/.pnp 28 | .pnp.js/example/ 29 | 30 | # testing 31 | /example/coverage 32 | 33 | # production 34 | /example/build 35 | 36 | # misc 37 | /example/.DS_Store 38 | /example/.env.local 39 | /example/.env.development.local 40 | /example/.env.test.local 41 | /example/.env.production.local 42 | 43 | /example/npm-debug.log* 44 | /example/yarn-debug.log* 45 | /example/yarn-error.log* 46 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fullpage-react-fs-example", 3 | "homepage": "https://FaisalST32.github.io/fullpage-react-fs", 4 | "version": "0.0.0", 5 | "private": true, 6 | "dependencies": { 7 | "react": "link:../node_modules/react", 8 | "react-dom": "link:../node_modules/react-dom", 9 | "react-scripts": "link:../node_modules/react-scripts", 10 | "fullpage-react-fs": "link:.." 11 | }, 12 | "scripts": { 13 | "start": "node ../node_modules/react-scripts/bin/react-scripts.js start", 14 | "build": "node ../node_modules/react-scripts/bin/react-scripts.js build", 15 | "test": "node ../node_modules/react-scripts/bin/react-scripts.js test", 16 | "eject": "node ../node_modules/react-scripts/bin/react-scripts.js eject" 17 | }, 18 | "eslintConfig": { 19 | "extends": "react-app" 20 | }, 21 | "browserslist": [ 22 | ">0.2%", 23 | "not dead", 24 | "not ie <= 11", 25 | "not op_mini all" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /src/styles.module.css: -------------------------------------------------------------------------------- 1 | .fullPanel { 2 | position: relative; 3 | height: 100vh; 4 | display: flex; 5 | align-items: center; 6 | justify-content: center; 7 | width: 100%; 8 | } 9 | 10 | .screenPane { 11 | overflow: hidden; 12 | height: 100vh; 13 | } 14 | 15 | .panelsContainer { 16 | position: relative; 17 | user-select: none; 18 | } 19 | 20 | .panelsContainer.panelTransitioning { 21 | transition: all 1s ease; 22 | } 23 | 24 | 25 | .navIndicators { 26 | position: fixed; 27 | right: 20px; 28 | top: 50vh; 29 | transform: translateY(-50%); 30 | } 31 | 32 | .indicator { 33 | font-size: 0.4rem; 34 | text-align: center; 35 | transition: font-size 200ms ease; 36 | cursor: pointer; 37 | color: purple 38 | } 39 | 40 | .indicator.active { 41 | font-size: 0.8rem; 42 | line-height: 1.5; 43 | } 44 | .indicator:hover:not(.active) { 45 | font-size: 0.6rem; 46 | line-height: 1.5; 47 | } 48 | 49 | body { 50 | overscroll-behavior: none; 51 | } 52 | 53 | .clickMask { 54 | height: 100vh; 55 | width: 100vw; 56 | position: absolute; 57 | left: 0; 58 | top: 0; 59 | z-index: 500 60 | } 61 | 62 | 63 | @media screen and (max-width: 1000px) { 64 | .fullPanel { 65 | min-height: 100vh; 66 | height: auto; 67 | } 68 | 69 | .screenPane { 70 | overflow: auto; 71 | height: auto; 72 | } 73 | 74 | .panelsContainer { 75 | position: static; 76 | transition: all 1s ease; 77 | /* top: -100vh */ 78 | } 79 | 80 | .navIndicators { 81 | display: none; 82 | } 83 | } -------------------------------------------------------------------------------- /dist/index.css: -------------------------------------------------------------------------------- 1 | ._1X2N_ { 2 | position: relative; 3 | height: 100vh; 4 | display: flex; 5 | align-items: center; 6 | justify-content: center; 7 | width: 100%; 8 | } 9 | 10 | ._3cHdp { 11 | overflow: hidden; 12 | height: 100vh; 13 | } 14 | 15 | ._ytvCK { 16 | position: relative; 17 | -webkit-user-select: none; 18 | -moz-user-select: none; 19 | -ms-user-select: none; 20 | user-select: none; 21 | } 22 | 23 | ._ytvCK._13cd7 { 24 | transition: all 1s ease; 25 | } 26 | 27 | 28 | ._2g5Xg { 29 | position: fixed; 30 | right: 20px; 31 | top: 50vh; 32 | transform: translateY(-50%); 33 | } 34 | 35 | ._3klkV { 36 | font-size: 0.4rem; 37 | text-align: center; 38 | transition: font-size 200ms ease; 39 | cursor: pointer; 40 | color: purple 41 | } 42 | 43 | ._3klkV._3sodH { 44 | font-size: 0.8rem; 45 | line-height: 1.5; 46 | } 47 | ._3klkV:hover:not(._3sodH) { 48 | font-size: 0.6rem; 49 | line-height: 1.5; 50 | } 51 | 52 | body { 53 | -ms-scroll-chaining: none; 54 | overscroll-behavior: none; 55 | } 56 | 57 | ._2690c { 58 | height: 100vh; 59 | width: 100vw; 60 | position: absolute; 61 | left: 0; 62 | top: 0; 63 | z-index: 500 64 | } 65 | 66 | 67 | @media screen and (max-width: 1000px) { 68 | ._1X2N_ { 69 | min-height: 100vh; 70 | height: auto; 71 | } 72 | 73 | ._3cHdp { 74 | overflow: auto; 75 | height: auto; 76 | } 77 | 78 | ._ytvCK { 79 | position: static; 80 | transition: all 1s ease; 81 | /* top: -100vh */ 82 | } 83 | 84 | ._2g5Xg { 85 | display: none; 86 | } 87 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fullpage-react-fs 2 | 3 | > A lightweight react library to create fullpage websites 4 | 5 | [![NPM](https://img.shields.io/npm/v/fullpage-react-fs.svg)](https://www.npmjs.com/package/fullpage-react-fs) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) 6 | 7 | Here's a preview 8 | 9 | ![faisalrashid.online](https://apifr.azurewebsites.net/uploads/637241257217983881_faisalrashid.gif 'faisalrashid.online') 10 | 11 | You can check out a live demo [here](https://faisalst32.github.io/fullpage-react-fs/) 12 | 13 | View it being used in my personal blog at [faisalrashid.online](https://www.faisalrashid.online) 14 | 15 | ## Install 16 | 17 | ```bash 18 | npm install --save fullpage-react-fs 19 | or 20 | yarn add fullpage-react-fs 21 | ``` 22 | 23 | ## Usage 24 | 25 | ```jsx 26 | import React from 'react' 27 | 28 | import { FullPageContainer, FullPagePanel } from 'fullpage-react-fs' 29 | import 'fullpage-react-fs/dist/index.css' 30 | 31 | export const App = () => { 32 | return ( 33 | 34 | 35 | {/* Panel 1 */} 36 | 37 | Your Content 38 | 39 | 40 | {/* Panel 2 */} 41 | 42 |
Goes
43 |
44 | 45 | {/* Panel 3 */} 46 | 47 |

here

48 |
49 | 50 |
51 | ) 52 | } 53 | ``` 54 | 55 | As shown in the sample code above do not forget to import the CSS file. 56 | 57 | ## License 58 | 59 | MIT © [FaisalST32](https://github.com/FaisalST32) 60 | -------------------------------------------------------------------------------- /example/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 12 | 16 | 17 | 18 | 27 | fullpage-react-fs 28 | 29 | 30 | 31 | 34 | 35 |
36 | 37 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /example/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | import { FullPageContainer, FullPagePanel } from 'fullpage-react-fs' 4 | import 'fullpage-react-fs/dist/index.css' 5 | 6 | const App = () => { 7 | return ( 8 | 9 | 10 |
11 | Use{' '} 12 | 17 | fullpage-react-fs 18 | {' '} 19 | to create beautiful webpages because 20 |
21 |
22 | Sometimes 23 |
all you need in Life 24 |
25 |
26 | 27 |
28 | is a little bit of 29 |
30 | Color 31 |
32 |
33 | 34 |
37 | and a little less 38 |
39 | Scroll 40 |
41 | Touch or Drag to switch slides.


42 | 47 | View on GitHub 48 | 49 |
50 |
51 |
52 | ) 53 | } 54 | 55 | export default App 56 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fullpage-react-fs", 3 | "version": "1.0.4", 4 | "description": "A lightweight react library to create fullpage websites", 5 | "keywords": [ 6 | "fullpage", 7 | "fullpagejs", 8 | "fullpage-react", 9 | "reactjs", 10 | "react", 11 | "faisal" 12 | ], 13 | "author": "FaisalST32", 14 | "license": "MIT", 15 | "repository": "FaisalST32/fullpage-react-fs", 16 | "homepage": "https://faisalst32.github.io/fullpage-react-fs/", 17 | "main": "dist/index.js", 18 | "module": "dist/index.modern.js", 19 | "source": "src/index.js", 20 | "engines": { 21 | "node": ">=10" 22 | }, 23 | "scripts": { 24 | "build": "microbundle-crl --no-compress --format modern,cjs", 25 | "start": "microbundle-crl watch --no-compress --format modern,cjs", 26 | "prepublish": "run-s build", 27 | "test": "run-s test:unit test:lint test:build", 28 | "test:build": "run-s build", 29 | "test:lint": "eslint .", 30 | "test:unit": "cross-env CI=1 react-scripts test --env=jsdom", 31 | "test:watch": "react-scripts test --env=jsdom", 32 | "predeploy": "cd example && yarn install && yarn run build", 33 | "deploy": "gh-pages -d example/build" 34 | }, 35 | "peerDependencies": { 36 | "react": "^16.0.0" 37 | }, 38 | "devDependencies": { 39 | "microbundle-crl": "^0.13.10", 40 | "babel-eslint": "^10.0.3", 41 | "cross-env": "^7.0.2", 42 | "eslint": "^6.8.0", 43 | "eslint-config-prettier": "^6.7.0", 44 | "eslint-config-standard": "^14.1.0", 45 | "eslint-config-standard-react": "^9.2.0", 46 | "eslint-plugin-import": "^2.18.2", 47 | "eslint-plugin-node": "^11.0.0", 48 | "eslint-plugin-prettier": "^3.1.1", 49 | "eslint-plugin-promise": "^4.2.1", 50 | "eslint-plugin-react": "^7.17.0", 51 | "eslint-plugin-standard": "^4.0.1", 52 | "gh-pages": "^2.2.0", 53 | "npm-run-all": "^4.1.5", 54 | "prettier": "^2.0.4", 55 | "react": "^16.13.1", 56 | "react-dom": "^16.13.1", 57 | "react-scripts": "^3.4.1" 58 | }, 59 | "files": [ 60 | "dist" 61 | ] 62 | } 63 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect, useRef } from 'react' 2 | import styles from './styles.module.css' 3 | 4 | export const FullPageContainer = ({ showIndicators = true, ...props }) => { 5 | const panelsCount = React.Children.count(props.children) 6 | 7 | const windowHeight = useRef(window.innerHeight) 8 | 9 | const [viewState, setViewState] = useState({ 10 | currentPanel: 1, 11 | transitioning: false, 12 | currentTop: 0 13 | }) 14 | const prevSection = () => { 15 | setViewState((prev) => { 16 | if (prev.transitioning) return prev 17 | if (prev.currentPanel <= 1) 18 | return { 19 | ...prev, 20 | currentTop: 0 21 | } 22 | setTimeout(() => { 23 | setViewState((prev) => ({ ...prev, transitioning: false })) 24 | }, 1000) 25 | return { 26 | transitioning: true, 27 | currentPanel: prev.currentPanel - 1, 28 | currentTop: -windowHeight.current * (prev.currentPanel - 2) 29 | } 30 | }) 31 | } 32 | 33 | const nextSection = () => { 34 | setViewState((prev) => { 35 | if (prev.transitioning) return prev 36 | 37 | if (prev.currentPanel >= panelsCount) 38 | return { 39 | ...prev, 40 | currentTop: -windowHeight.current * (panelsCount - 1) 41 | } 42 | setTimeout(() => { 43 | setViewState((prev) => ({ ...prev, transitioning: false })) 44 | }, 1000) 45 | return { 46 | transitioning: true, 47 | currentPanel: prev.currentPanel + 1, 48 | currentTop: -windowHeight.current * prev.currentPanel 49 | } 50 | }) 51 | } 52 | 53 | const restoreSection = () => { 54 | setViewState((prev) => { 55 | return { 56 | ...prev, 57 | currentTop: -windowHeight.current * (prev.currentPanel - 1) 58 | } 59 | }) 60 | } 61 | 62 | const handleScroll = (e) => { 63 | if (e.deltaY > 40 && viewState.currentPanel < panelsCount) { 64 | nextSection() 65 | } else if (e.deltaY < -40 && viewState.currentPanel > 0) { 66 | prevSection() 67 | } 68 | } 69 | 70 | const onSetSection = (sectionNumber) => { 71 | setViewState((prev) => { 72 | setTimeout(() => { 73 | setViewState((prev) => ({ ...prev, transitioning: false })) 74 | }, 1000) 75 | return { 76 | transitioning: true, 77 | currentPanel: sectionNumber, 78 | currentTop: -windowHeight.current * (sectionNumber - 1) 79 | } 80 | }) 81 | } 82 | 83 | const removeEventListeners = () => { 84 | window.removeEventListener('wheel', (e) => { 85 | handleScroll(e) 86 | }) 87 | window.removeEventListener('touchstart', (e) => { 88 | handleSwipe(e, true) 89 | }) 90 | window.removeEventListener('touchend', (e) => { 91 | handleSwipe(e, false) 92 | }) 93 | window.removeEventListener('pointerdown', (e) => { 94 | handleSwipe(e.changedTouches[0].screenY, true) 95 | }) 96 | window.removeEventListener('pointerup', (e) => { 97 | handleSwipe(e.changedTouches[0].screenY, false) 98 | }) 99 | window.removeEventListener('pointermove', (e) => { 100 | handleDrag(e.screenY) 101 | }) 102 | 103 | window.removeEventListener('resize', () => { 104 | windowHeight.current = window.innerHeight 105 | }) 106 | } 107 | 108 | useEffect(() => { 109 | removeEventListeners() 110 | window.addEventListener('wheel', (e) => { 111 | handleScroll(e) 112 | }) 113 | window.addEventListener('touchstart', (e) => { 114 | handleSwipe(e.changedTouches[0].screenY, true, e) 115 | }) 116 | window.addEventListener('touchend', (e) => { 117 | handleSwipe(e.changedTouches[0].screenY, false, e) 118 | }) 119 | window.addEventListener('pointerdown', (e) => { 120 | handleSwipe(e.screenY, true, e) 121 | }) 122 | window.addEventListener('pointerup', (e) => { 123 | handleSwipe(e.screenY, false, e) 124 | }) 125 | 126 | window.addEventListener('pointermove', (e) => { 127 | handleDrag(e.screenY) 128 | }) 129 | window.addEventListener('touchmove', (e) => { 130 | handleDrag(e.changedTouches[0].screenY) 131 | }) 132 | 133 | window.addEventListener('resize', () => { 134 | windowHeight.current = window.innerHeight 135 | }) 136 | return () => { 137 | removeEventListeners() 138 | } 139 | }, []) 140 | 141 | const touchStartY = useRef(0) 142 | 143 | const [currentPointer, setCurrentPointer] = useState(0) 144 | 145 | const handleDrag = (screenY) => { 146 | if (touchStartY.current === 0) { 147 | return 148 | } 149 | 150 | let initialSet = false 151 | let difference = 0 152 | setCurrentPointer((prev) => { 153 | if (prev === 0) { 154 | initialSet = true 155 | return screenY 156 | } 157 | 158 | difference = prev - screenY 159 | 160 | if ( 161 | (difference < 0 && difference > -2) || 162 | (difference > 0 && difference < 2) 163 | ) { 164 | initialSet = true 165 | return prev 166 | } 167 | return screenY 168 | }) 169 | if (initialSet) return 170 | 171 | setViewState((prev) => { 172 | if (prev.transitioning) { 173 | return prev 174 | } 175 | return { ...prev, currentTop: prev.currentTop - difference } 176 | }) 177 | } 178 | 179 | const handleSwipe = (screenY, isStart, event) => { 180 | if (isStart) { 181 | touchStartY.current = screenY 182 | return 183 | } 184 | 185 | const touchEndY = screenY 186 | 187 | const touchDifference = touchStartY.current - touchEndY 188 | 189 | if (touchDifference < -100) { 190 | prevSection() 191 | } else if (touchDifference > 100) { 192 | nextSection() 193 | } else { 194 | restoreSection() 195 | } 196 | 197 | touchStartY.current = 0 198 | setCurrentPointer(0) 199 | } 200 | 201 | const panelsstyles = [styles.panelsContainer] 202 | if (viewState.transitioning) { 203 | panelsstyles.push(styles.panelTransitioning) 204 | } 205 | 206 | return ( 207 |
208 | {currentPointer !== 0 &&
} 209 |
213 | {props.children} 214 | {showIndicators && ( 215 | 220 | )} 221 |
222 |
223 | ) 224 | } 225 | 226 | const NavIndicators = ({ count, activeIndex, setIndicator }) => { 227 | let indicatorHtml = null 228 | if (count) { 229 | indicatorHtml = Array(count) 230 | .fill(0) 231 | .map((item, i) => { 232 | const indicatorstyles = [styles.indicator] 233 | if (i === activeIndex - 1) { 234 | indicatorstyles.push(styles.active) 235 | } 236 | return ( 237 |
{ 241 | setIndicator(i + 1) 242 | }} 243 | > 244 | ⬤ 245 |
246 | ) 247 | }) 248 | } 249 | return
{indicatorHtml}
250 | } 251 | 252 | export const FullPagePanel = ({ bgColor, ...props }) => { 253 | return ( 254 |
255 |
{props.children}
256 |
257 | ) 258 | } 259 | -------------------------------------------------------------------------------- /dist/index.modern.js: -------------------------------------------------------------------------------- 1 | import React, { useRef, useState, useEffect } from 'react'; 2 | 3 | function _extends() { 4 | _extends = Object.assign || function (target) { 5 | for (var i = 1; i < arguments.length; i++) { 6 | var source = arguments[i]; 7 | 8 | for (var key in source) { 9 | if (Object.prototype.hasOwnProperty.call(source, key)) { 10 | target[key] = source[key]; 11 | } 12 | } 13 | } 14 | 15 | return target; 16 | }; 17 | 18 | return _extends.apply(this, arguments); 19 | } 20 | 21 | function _objectWithoutPropertiesLoose(source, excluded) { 22 | if (source == null) return {}; 23 | var target = {}; 24 | var sourceKeys = Object.keys(source); 25 | var key, i; 26 | 27 | for (i = 0; i < sourceKeys.length; i++) { 28 | key = sourceKeys[i]; 29 | if (excluded.indexOf(key) >= 0) continue; 30 | target[key] = source[key]; 31 | } 32 | 33 | return target; 34 | } 35 | 36 | var styles = {"fullPanel":"_1X2N_","screenPane":"_3cHdp","panelsContainer":"_ytvCK","panelTransitioning":"_13cd7","navIndicators":"_2g5Xg","indicator":"_3klkV","active":"_3sodH","clickMask":"_2690c"}; 37 | 38 | var FullPageContainer = function FullPageContainer(_ref) { 39 | var _ref$showIndicators = _ref.showIndicators, 40 | showIndicators = _ref$showIndicators === void 0 ? true : _ref$showIndicators, 41 | props = _objectWithoutPropertiesLoose(_ref, ["showIndicators"]); 42 | 43 | var panelsCount = React.Children.count(props.children); 44 | var windowHeight = useRef(window.innerHeight); 45 | 46 | var _useState = useState({ 47 | currentPanel: 1, 48 | transitioning: false, 49 | currentTop: 0 50 | }), 51 | viewState = _useState[0], 52 | setViewState = _useState[1]; 53 | 54 | var prevSection = function prevSection() { 55 | setViewState(function (prev) { 56 | if (prev.transitioning) return prev; 57 | if (prev.currentPanel <= 1) return _extends(_extends({}, prev), {}, { 58 | currentTop: 0 59 | }); 60 | setTimeout(function () { 61 | setViewState(function (prev) { 62 | return _extends(_extends({}, prev), {}, { 63 | transitioning: false 64 | }); 65 | }); 66 | }, 1000); 67 | return { 68 | transitioning: true, 69 | currentPanel: prev.currentPanel - 1, 70 | currentTop: -windowHeight.current * (prev.currentPanel - 2) 71 | }; 72 | }); 73 | }; 74 | 75 | var nextSection = function nextSection() { 76 | setViewState(function (prev) { 77 | if (prev.transitioning) return prev; 78 | if (prev.currentPanel >= panelsCount) return _extends(_extends({}, prev), {}, { 79 | currentTop: -windowHeight.current * (panelsCount - 1) 80 | }); 81 | setTimeout(function () { 82 | setViewState(function (prev) { 83 | return _extends(_extends({}, prev), {}, { 84 | transitioning: false 85 | }); 86 | }); 87 | }, 1000); 88 | return { 89 | transitioning: true, 90 | currentPanel: prev.currentPanel + 1, 91 | currentTop: -windowHeight.current * prev.currentPanel 92 | }; 93 | }); 94 | }; 95 | 96 | var restoreSection = function restoreSection() { 97 | setViewState(function (prev) { 98 | return _extends(_extends({}, prev), {}, { 99 | currentTop: -windowHeight.current * (prev.currentPanel - 1) 100 | }); 101 | }); 102 | }; 103 | 104 | var handleScroll = function handleScroll(e) { 105 | if (e.deltaY > 40 && viewState.currentPanel < panelsCount) { 106 | nextSection(); 107 | } else if (e.deltaY < -40 && viewState.currentPanel > 0) { 108 | prevSection(); 109 | } 110 | }; 111 | 112 | var onSetSection = function onSetSection(sectionNumber) { 113 | setViewState(function (prev) { 114 | setTimeout(function () { 115 | setViewState(function (prev) { 116 | return _extends(_extends({}, prev), {}, { 117 | transitioning: false 118 | }); 119 | }); 120 | }, 1000); 121 | return { 122 | transitioning: true, 123 | currentPanel: sectionNumber, 124 | currentTop: -windowHeight.current * (sectionNumber - 1) 125 | }; 126 | }); 127 | }; 128 | 129 | var removeEventListeners = function removeEventListeners() { 130 | window.removeEventListener('wheel', function (e) { 131 | handleScroll(e); 132 | }); 133 | window.removeEventListener('touchstart', function (e) { 134 | handleSwipe(e, true); 135 | }); 136 | window.removeEventListener('touchend', function (e) { 137 | handleSwipe(e, false); 138 | }); 139 | window.removeEventListener('pointerdown', function (e) { 140 | handleSwipe(e.changedTouches[0].screenY, true); 141 | }); 142 | window.removeEventListener('pointerup', function (e) { 143 | handleSwipe(e.changedTouches[0].screenY, false); 144 | }); 145 | window.removeEventListener('pointermove', function (e) { 146 | handleDrag(e.screenY); 147 | }); 148 | window.removeEventListener('resize', function () { 149 | windowHeight.current = window.innerHeight; 150 | }); 151 | }; 152 | 153 | useEffect(function () { 154 | removeEventListeners(); 155 | window.addEventListener('wheel', function (e) { 156 | handleScroll(e); 157 | }); 158 | window.addEventListener('touchstart', function (e) { 159 | handleSwipe(e.changedTouches[0].screenY, true); 160 | }); 161 | window.addEventListener('touchend', function (e) { 162 | handleSwipe(e.changedTouches[0].screenY, false); 163 | }); 164 | window.addEventListener('pointerdown', function (e) { 165 | handleSwipe(e.screenY, true); 166 | }); 167 | window.addEventListener('pointerup', function (e) { 168 | handleSwipe(e.screenY, false); 169 | }); 170 | window.addEventListener('pointermove', function (e) { 171 | handleDrag(e.screenY); 172 | }); 173 | window.addEventListener('touchmove', function (e) { 174 | handleDrag(e.changedTouches[0].screenY); 175 | }); 176 | window.addEventListener('resize', function () { 177 | windowHeight.current = window.innerHeight; 178 | }); 179 | return function () { 180 | removeEventListeners(); 181 | }; 182 | }, []); 183 | var touchStartY = useRef(0); 184 | 185 | var _useState2 = useState(0), 186 | currentPointer = _useState2[0], 187 | setCurrentPointer = _useState2[1]; 188 | 189 | var handleDrag = function handleDrag(screenY) { 190 | if (touchStartY.current === 0) { 191 | return; 192 | } 193 | 194 | var initialSet = false; 195 | var difference = 0; 196 | setCurrentPointer(function (prev) { 197 | if (prev === 0) { 198 | initialSet = true; 199 | return screenY; 200 | } 201 | 202 | difference = prev - screenY; 203 | 204 | if (difference < 0 && difference > -2 || difference > 0 && difference < 2) { 205 | initialSet = true; 206 | return prev; 207 | } 208 | 209 | return screenY; 210 | }); 211 | if (initialSet) return; 212 | setViewState(function (prev) { 213 | if (prev.transitioning) { 214 | return prev; 215 | } 216 | 217 | return _extends(_extends({}, prev), {}, { 218 | currentTop: prev.currentTop - difference 219 | }); 220 | }); 221 | }; 222 | 223 | var handleSwipe = function handleSwipe(screenY, isStart, event) { 224 | if (isStart) { 225 | touchStartY.current = screenY; 226 | return; 227 | } 228 | 229 | var touchEndY = screenY; 230 | var touchDifference = touchStartY.current - touchEndY; 231 | 232 | if (touchDifference < -100) { 233 | prevSection(); 234 | } else if (touchDifference > 100) { 235 | nextSection(); 236 | } else { 237 | restoreSection(); 238 | } 239 | 240 | touchStartY.current = 0; 241 | setCurrentPointer(0); 242 | }; 243 | 244 | var panelsstyles = [styles.panelsContainer]; 245 | 246 | if (viewState.transitioning) { 247 | panelsstyles.push(styles.panelTransitioning); 248 | } 249 | 250 | return /*#__PURE__*/React.createElement("div", { 251 | className: styles.screenPane 252 | }, currentPointer !== 0 && /*#__PURE__*/React.createElement("div", { 253 | className: styles.clickMask 254 | }), /*#__PURE__*/React.createElement("div", { 255 | className: panelsstyles.join(' '), 256 | style: { 257 | top: viewState.currentTop + "px" 258 | } 259 | }, props.children, showIndicators && /*#__PURE__*/React.createElement(NavIndicators, { 260 | count: panelsCount, 261 | activeIndex: viewState.currentPanel, 262 | setIndicator: onSetSection 263 | }))); 264 | }; 265 | 266 | var NavIndicators = function NavIndicators(_ref2) { 267 | var count = _ref2.count, 268 | activeIndex = _ref2.activeIndex, 269 | setIndicator = _ref2.setIndicator; 270 | var indicatorHtml = null; 271 | 272 | if (count) { 273 | indicatorHtml = Array(count).fill(0).map(function (item, i) { 274 | var indicatorstyles = [styles.indicator]; 275 | 276 | if (i === activeIndex - 1) { 277 | indicatorstyles.push(styles.active); 278 | } 279 | 280 | return /*#__PURE__*/React.createElement("div", { 281 | key: i, 282 | className: indicatorstyles.join(' '), 283 | onClick: function onClick() { 284 | setIndicator(i + 1); 285 | } 286 | }, "\u2B24"); 287 | }); 288 | } 289 | 290 | return /*#__PURE__*/React.createElement("div", { 291 | className: styles.navIndicators 292 | }, indicatorHtml); 293 | }; 294 | 295 | var FullPagePanel = function FullPagePanel(_ref3) { 296 | var bgColor = _ref3.bgColor, 297 | props = _objectWithoutPropertiesLoose(_ref3, ["bgColor"]); 298 | 299 | return /*#__PURE__*/React.createElement("div", { 300 | className: styles.fullPanel, 301 | style: { 302 | backgroundColor: bgColor 303 | } 304 | }, /*#__PURE__*/React.createElement("div", { 305 | className: styles.panelContent 306 | }, props.children)); 307 | }; 308 | 309 | export { FullPageContainer, FullPagePanel }; 310 | //# sourceMappingURL=index.modern.js.map 311 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } 2 | 3 | var React = require('react'); 4 | var React__default = _interopDefault(React); 5 | 6 | function _extends() { 7 | _extends = Object.assign || function (target) { 8 | for (var i = 1; i < arguments.length; i++) { 9 | var source = arguments[i]; 10 | 11 | for (var key in source) { 12 | if (Object.prototype.hasOwnProperty.call(source, key)) { 13 | target[key] = source[key]; 14 | } 15 | } 16 | } 17 | 18 | return target; 19 | }; 20 | 21 | return _extends.apply(this, arguments); 22 | } 23 | 24 | function _objectWithoutPropertiesLoose(source, excluded) { 25 | if (source == null) return {}; 26 | var target = {}; 27 | var sourceKeys = Object.keys(source); 28 | var key, i; 29 | 30 | for (i = 0; i < sourceKeys.length; i++) { 31 | key = sourceKeys[i]; 32 | if (excluded.indexOf(key) >= 0) continue; 33 | target[key] = source[key]; 34 | } 35 | 36 | return target; 37 | } 38 | 39 | var styles = {"fullPanel":"_1X2N_","screenPane":"_3cHdp","panelsContainer":"_ytvCK","panelTransitioning":"_13cd7","navIndicators":"_2g5Xg","indicator":"_3klkV","active":"_3sodH","clickMask":"_2690c"}; 40 | 41 | var FullPageContainer = function FullPageContainer(_ref) { 42 | var _ref$showIndicators = _ref.showIndicators, 43 | showIndicators = _ref$showIndicators === void 0 ? true : _ref$showIndicators, 44 | props = _objectWithoutPropertiesLoose(_ref, ["showIndicators"]); 45 | 46 | var panelsCount = React__default.Children.count(props.children); 47 | var windowHeight = React.useRef(window.innerHeight); 48 | 49 | var _useState = React.useState({ 50 | currentPanel: 1, 51 | transitioning: false, 52 | currentTop: 0 53 | }), 54 | viewState = _useState[0], 55 | setViewState = _useState[1]; 56 | 57 | var prevSection = function prevSection() { 58 | setViewState(function (prev) { 59 | if (prev.transitioning) return prev; 60 | if (prev.currentPanel <= 1) return _extends(_extends({}, prev), {}, { 61 | currentTop: 0 62 | }); 63 | setTimeout(function () { 64 | setViewState(function (prev) { 65 | return _extends(_extends({}, prev), {}, { 66 | transitioning: false 67 | }); 68 | }); 69 | }, 1000); 70 | return { 71 | transitioning: true, 72 | currentPanel: prev.currentPanel - 1, 73 | currentTop: -windowHeight.current * (prev.currentPanel - 2) 74 | }; 75 | }); 76 | }; 77 | 78 | var nextSection = function nextSection() { 79 | setViewState(function (prev) { 80 | if (prev.transitioning) return prev; 81 | if (prev.currentPanel >= panelsCount) return _extends(_extends({}, prev), {}, { 82 | currentTop: -windowHeight.current * (panelsCount - 1) 83 | }); 84 | setTimeout(function () { 85 | setViewState(function (prev) { 86 | return _extends(_extends({}, prev), {}, { 87 | transitioning: false 88 | }); 89 | }); 90 | }, 1000); 91 | return { 92 | transitioning: true, 93 | currentPanel: prev.currentPanel + 1, 94 | currentTop: -windowHeight.current * prev.currentPanel 95 | }; 96 | }); 97 | }; 98 | 99 | var restoreSection = function restoreSection() { 100 | setViewState(function (prev) { 101 | return _extends(_extends({}, prev), {}, { 102 | currentTop: -windowHeight.current * (prev.currentPanel - 1) 103 | }); 104 | }); 105 | }; 106 | 107 | var handleScroll = function handleScroll(e) { 108 | if (e.deltaY > 40 && viewState.currentPanel < panelsCount) { 109 | nextSection(); 110 | } else if (e.deltaY < -40 && viewState.currentPanel > 0) { 111 | prevSection(); 112 | } 113 | }; 114 | 115 | var onSetSection = function onSetSection(sectionNumber) { 116 | setViewState(function (prev) { 117 | setTimeout(function () { 118 | setViewState(function (prev) { 119 | return _extends(_extends({}, prev), {}, { 120 | transitioning: false 121 | }); 122 | }); 123 | }, 1000); 124 | return { 125 | transitioning: true, 126 | currentPanel: sectionNumber, 127 | currentTop: -windowHeight.current * (sectionNumber - 1) 128 | }; 129 | }); 130 | }; 131 | 132 | var removeEventListeners = function removeEventListeners() { 133 | window.removeEventListener('wheel', function (e) { 134 | handleScroll(e); 135 | }); 136 | window.removeEventListener('touchstart', function (e) { 137 | handleSwipe(e, true); 138 | }); 139 | window.removeEventListener('touchend', function (e) { 140 | handleSwipe(e, false); 141 | }); 142 | window.removeEventListener('pointerdown', function (e) { 143 | handleSwipe(e.changedTouches[0].screenY, true); 144 | }); 145 | window.removeEventListener('pointerup', function (e) { 146 | handleSwipe(e.changedTouches[0].screenY, false); 147 | }); 148 | window.removeEventListener('pointermove', function (e) { 149 | handleDrag(e.screenY); 150 | }); 151 | window.removeEventListener('resize', function () { 152 | windowHeight.current = window.innerHeight; 153 | }); 154 | }; 155 | 156 | React.useEffect(function () { 157 | removeEventListeners(); 158 | window.addEventListener('wheel', function (e) { 159 | handleScroll(e); 160 | }); 161 | window.addEventListener('touchstart', function (e) { 162 | handleSwipe(e.changedTouches[0].screenY, true); 163 | }); 164 | window.addEventListener('touchend', function (e) { 165 | handleSwipe(e.changedTouches[0].screenY, false); 166 | }); 167 | window.addEventListener('pointerdown', function (e) { 168 | handleSwipe(e.screenY, true); 169 | }); 170 | window.addEventListener('pointerup', function (e) { 171 | handleSwipe(e.screenY, false); 172 | }); 173 | window.addEventListener('pointermove', function (e) { 174 | handleDrag(e.screenY); 175 | }); 176 | window.addEventListener('touchmove', function (e) { 177 | handleDrag(e.changedTouches[0].screenY); 178 | }); 179 | window.addEventListener('resize', function () { 180 | windowHeight.current = window.innerHeight; 181 | }); 182 | return function () { 183 | removeEventListeners(); 184 | }; 185 | }, []); 186 | var touchStartY = React.useRef(0); 187 | 188 | var _useState2 = React.useState(0), 189 | currentPointer = _useState2[0], 190 | setCurrentPointer = _useState2[1]; 191 | 192 | var handleDrag = function handleDrag(screenY) { 193 | if (touchStartY.current === 0) { 194 | return; 195 | } 196 | 197 | var initialSet = false; 198 | var difference = 0; 199 | setCurrentPointer(function (prev) { 200 | if (prev === 0) { 201 | initialSet = true; 202 | return screenY; 203 | } 204 | 205 | difference = prev - screenY; 206 | 207 | if (difference < 0 && difference > -2 || difference > 0 && difference < 2) { 208 | initialSet = true; 209 | return prev; 210 | } 211 | 212 | return screenY; 213 | }); 214 | if (initialSet) return; 215 | setViewState(function (prev) { 216 | if (prev.transitioning) { 217 | return prev; 218 | } 219 | 220 | return _extends(_extends({}, prev), {}, { 221 | currentTop: prev.currentTop - difference 222 | }); 223 | }); 224 | }; 225 | 226 | var handleSwipe = function handleSwipe(screenY, isStart, event) { 227 | if (isStart) { 228 | touchStartY.current = screenY; 229 | return; 230 | } 231 | 232 | var touchEndY = screenY; 233 | var touchDifference = touchStartY.current - touchEndY; 234 | 235 | if (touchDifference < -100) { 236 | prevSection(); 237 | } else if (touchDifference > 100) { 238 | nextSection(); 239 | } else { 240 | restoreSection(); 241 | } 242 | 243 | touchStartY.current = 0; 244 | setCurrentPointer(0); 245 | }; 246 | 247 | var panelsstyles = [styles.panelsContainer]; 248 | 249 | if (viewState.transitioning) { 250 | panelsstyles.push(styles.panelTransitioning); 251 | } 252 | 253 | return /*#__PURE__*/React__default.createElement("div", { 254 | className: styles.screenPane 255 | }, currentPointer !== 0 && /*#__PURE__*/React__default.createElement("div", { 256 | className: styles.clickMask 257 | }), /*#__PURE__*/React__default.createElement("div", { 258 | className: panelsstyles.join(' '), 259 | style: { 260 | top: viewState.currentTop + "px" 261 | } 262 | }, props.children, showIndicators && /*#__PURE__*/React__default.createElement(NavIndicators, { 263 | count: panelsCount, 264 | activeIndex: viewState.currentPanel, 265 | setIndicator: onSetSection 266 | }))); 267 | }; 268 | 269 | var NavIndicators = function NavIndicators(_ref2) { 270 | var count = _ref2.count, 271 | activeIndex = _ref2.activeIndex, 272 | setIndicator = _ref2.setIndicator; 273 | var indicatorHtml = null; 274 | 275 | if (count) { 276 | indicatorHtml = Array(count).fill(0).map(function (item, i) { 277 | var indicatorstyles = [styles.indicator]; 278 | 279 | if (i === activeIndex - 1) { 280 | indicatorstyles.push(styles.active); 281 | } 282 | 283 | return /*#__PURE__*/React__default.createElement("div", { 284 | key: i, 285 | className: indicatorstyles.join(' '), 286 | onClick: function onClick() { 287 | setIndicator(i + 1); 288 | } 289 | }, "\u2B24"); 290 | }); 291 | } 292 | 293 | return /*#__PURE__*/React__default.createElement("div", { 294 | className: styles.navIndicators 295 | }, indicatorHtml); 296 | }; 297 | 298 | var FullPagePanel = function FullPagePanel(_ref3) { 299 | var bgColor = _ref3.bgColor, 300 | props = _objectWithoutPropertiesLoose(_ref3, ["bgColor"]); 301 | 302 | return /*#__PURE__*/React__default.createElement("div", { 303 | className: styles.fullPanel, 304 | style: { 305 | backgroundColor: bgColor 306 | } 307 | }, /*#__PURE__*/React__default.createElement("div", { 308 | className: styles.panelContent 309 | }, props.children)); 310 | }; 311 | 312 | exports.FullPageContainer = FullPageContainer; 313 | exports.FullPagePanel = FullPagePanel; 314 | //# sourceMappingURL=index.js.map 315 | -------------------------------------------------------------------------------- /dist/index.modern.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.modern.js","sources":["../src/index.js"],"sourcesContent":["import React, { useState, useEffect, useRef } from 'react'\nimport styles from './styles.module.css'\n\nexport const FullPageContainer = ({ showIndicators = true, ...props }) => {\n const panelsCount = React.Children.count(props.children)\n\n const windowHeight = useRef(window.innerHeight)\n\n const [viewState, setViewState] = useState({\n currentPanel: 1,\n transitioning: false,\n currentTop: 0\n })\n const prevSection = () => {\n setViewState((prev) => {\n if (prev.transitioning) return prev\n if (prev.currentPanel <= 1)\n return {\n ...prev,\n currentTop: 0\n }\n setTimeout(() => {\n setViewState((prev) => ({ ...prev, transitioning: false }))\n }, 1000)\n return {\n transitioning: true,\n currentPanel: prev.currentPanel - 1,\n currentTop: -windowHeight.current * (prev.currentPanel - 2)\n }\n })\n }\n\n const nextSection = () => {\n setViewState((prev) => {\n if (prev.transitioning) return prev\n\n if (prev.currentPanel >= panelsCount)\n return {\n ...prev,\n currentTop: -windowHeight.current * (panelsCount - 1)\n }\n setTimeout(() => {\n setViewState((prev) => ({ ...prev, transitioning: false }))\n }, 1000)\n return {\n transitioning: true,\n currentPanel: prev.currentPanel + 1,\n currentTop: -windowHeight.current * prev.currentPanel\n }\n })\n }\n\n const restoreSection = () => {\n setViewState((prev) => {\n return {\n ...prev,\n currentTop: -windowHeight.current * (prev.currentPanel - 1)\n }\n })\n }\n\n const handleScroll = (e) => {\n if (e.deltaY > 40 && viewState.currentPanel < panelsCount) {\n nextSection()\n } else if (e.deltaY < -40 && viewState.currentPanel > 0) {\n prevSection()\n }\n }\n\n const onSetSection = (sectionNumber) => {\n setViewState((prev) => {\n setTimeout(() => {\n setViewState((prev) => ({ ...prev, transitioning: false }))\n }, 1000)\n return {\n transitioning: true,\n currentPanel: sectionNumber,\n currentTop: -windowHeight.current * (sectionNumber - 1)\n }\n })\n }\n\n const removeEventListeners = () => {\n window.removeEventListener('wheel', (e) => {\n handleScroll(e)\n })\n window.removeEventListener('touchstart', (e) => {\n handleSwipe(e, true)\n })\n window.removeEventListener('touchend', (e) => {\n handleSwipe(e, false)\n })\n window.removeEventListener('pointerdown', (e) => {\n handleSwipe(e.changedTouches[0].screenY, true)\n })\n window.removeEventListener('pointerup', (e) => {\n handleSwipe(e.changedTouches[0].screenY, false)\n })\n window.removeEventListener('pointermove', (e) => {\n handleDrag(e.screenY)\n })\n\n window.removeEventListener('resize', () => {\n windowHeight.current = window.innerHeight\n })\n }\n\n useEffect(() => {\n removeEventListeners()\n window.addEventListener('wheel', (e) => {\n handleScroll(e)\n })\n window.addEventListener('touchstart', (e) => {\n handleSwipe(e.changedTouches[0].screenY, true, e)\n })\n window.addEventListener('touchend', (e) => {\n handleSwipe(e.changedTouches[0].screenY, false, e)\n })\n window.addEventListener('pointerdown', (e) => {\n handleSwipe(e.screenY, true, e)\n })\n window.addEventListener('pointerup', (e) => {\n handleSwipe(e.screenY, false, e)\n })\n\n window.addEventListener('pointermove', (e) => {\n handleDrag(e.screenY)\n })\n window.addEventListener('touchmove', (e) => {\n handleDrag(e.changedTouches[0].screenY)\n })\n\n window.addEventListener('resize', () => {\n windowHeight.current = window.innerHeight\n })\n return () => {\n removeEventListeners()\n }\n }, [])\n\n const touchStartY = useRef(0)\n\n const [currentPointer, setCurrentPointer] = useState(0)\n\n const handleDrag = (screenY) => {\n if (touchStartY.current === 0) {\n return\n }\n\n let initialSet = false\n let difference = 0\n setCurrentPointer((prev) => {\n if (prev === 0) {\n initialSet = true\n return screenY\n }\n\n difference = prev - screenY\n\n if (\n (difference < 0 && difference > -2) ||\n (difference > 0 && difference < 2)\n ) {\n initialSet = true\n return prev\n }\n return screenY\n })\n if (initialSet) return\n\n setViewState((prev) => {\n if (prev.transitioning) {\n return prev\n }\n return { ...prev, currentTop: prev.currentTop - difference }\n })\n }\n\n const handleSwipe = (screenY, isStart, event) => {\n if (isStart) {\n touchStartY.current = screenY\n return\n }\n\n const touchEndY = screenY\n\n const touchDifference = touchStartY.current - touchEndY\n\n if (touchDifference < -100) {\n prevSection()\n } else if (touchDifference > 100) {\n nextSection()\n } else {\n restoreSection()\n }\n\n touchStartY.current = 0\n setCurrentPointer(0)\n }\n\n const panelsstyles = [styles.panelsContainer]\n if (viewState.transitioning) {\n panelsstyles.push(styles.panelTransitioning)\n }\n\n return (\n
\n {currentPointer !== 0 &&
}\n \n {props.children}\n {showIndicators && (\n \n )}\n
\n
\n )\n}\n\nconst NavIndicators = ({ count, activeIndex, setIndicator }) => {\n let indicatorHtml = null\n if (count) {\n indicatorHtml = Array(count)\n .fill(0)\n .map((item, i) => {\n const indicatorstyles = [styles.indicator]\n if (i === activeIndex - 1) {\n indicatorstyles.push(styles.active)\n }\n return (\n {\n setIndicator(i + 1)\n }}\n >\n ⬤\n
\n )\n })\n }\n return
{indicatorHtml}
\n}\n\nexport const FullPagePanel = ({ bgColor, ...props }) => {\n return (\n
\n
{props.children}
\n
\n )\n}\n"],"names":["FullPageContainer","showIndicators","props","panelsCount","React","Children","count","children","windowHeight","useRef","window","innerHeight","useState","currentPanel","transitioning","currentTop","viewState","setViewState","prevSection","prev","setTimeout","current","nextSection","restoreSection","handleScroll","e","deltaY","onSetSection","sectionNumber","removeEventListeners","removeEventListener","handleSwipe","changedTouches","screenY","handleDrag","useEffect","addEventListener","touchStartY","currentPointer","setCurrentPointer","initialSet","difference","isStart","event","touchEndY","touchDifference","panelsstyles","styles","panelsContainer","push","panelTransitioning","screenPane","clickMask","join","top","NavIndicators","activeIndex","setIndicator","indicatorHtml","Array","fill","map","item","i","indicatorstyles","indicator","active","navIndicators","FullPagePanel","bgColor","fullPanel","backgroundColor","panelContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGaA,iBAAiB,GAAG,SAApBA,iBAAoB,OAAyC;AAAA,iCAAtCC,cAAsC;AAAA,MAAtCA,cAAsC,oCAArB,IAAqB;AAAA,MAAZC,KAAY;;AACxE,MAAMC,WAAW,GAAGC,KAAK,CAACC,QAAN,CAAeC,KAAf,CAAqBJ,KAAK,CAACK,QAA3B,CAApB;AAEA,MAAMC,YAAY,GAAGC,MAAM,CAACC,MAAM,CAACC,WAAR,CAA3B;;AAHwE,kBAKtCC,QAAQ,CAAC;AACzCC,IAAAA,YAAY,EAAE,CAD2B;AAEzCC,IAAAA,aAAa,EAAE,KAF0B;AAGzCC,IAAAA,UAAU,EAAE;AAH6B,GAAD,CAL8B;AAAA,MAKjEC,SALiE;AAAA,MAKtDC,YALsD;;AAUxE,MAAMC,WAAW,GAAG,SAAdA,WAAc,GAAM;AACxBD,IAAAA,YAAY,CAAC,UAACE,IAAD,EAAU;AACrB,UAAIA,IAAI,CAACL,aAAT,EAAwB,OAAOK,IAAP;AACxB,UAAIA,IAAI,CAACN,YAAL,IAAqB,CAAzB,EACE,6BACKM,IADL;AAEEJ,QAAAA,UAAU,EAAE;AAFd;AAIFK,MAAAA,UAAU,CAAC,YAAM;AACfH,QAAAA,YAAY,CAAC,UAACE,IAAD;AAAA,uCAAgBA,IAAhB;AAAsBL,YAAAA,aAAa,EAAE;AAArC;AAAA,SAAD,CAAZ;AACD,OAFS,EAEP,IAFO,CAAV;AAGA,aAAO;AACLA,QAAAA,aAAa,EAAE,IADV;AAELD,QAAAA,YAAY,EAAEM,IAAI,CAACN,YAAL,GAAoB,CAF7B;AAGLE,QAAAA,UAAU,EAAE,CAACP,YAAY,CAACa,OAAd,IAAyBF,IAAI,CAACN,YAAL,GAA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aU,aAAa,GAAG,SAAhBA,aAAgB,QAA2B;AAAA,MAAxBC,OAAwB,SAAxBA,OAAwB;AAAA,MAAZnE,KAAY;;AACtD,sBACE;AAAK,IAAA,SAAS,EAAE6C,MAAM,CAACuB,SAAvB;AAAkC,IAAA,KAAK,EAAE;AAAEC,MAAAA,eAAe,EAAEF;AAAnB;AAAzC,kBACE;AAAK,IAAA,SAAS,EAAEtB,MAAM,CAACyB;AAAvB,KAAsCtE,KAAK,CAACK,QAA5C,CADF,CADF;AAKD,CANM;;;;"} -------------------------------------------------------------------------------- /dist/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["import React, { useState, useEffect, useRef } from 'react'\nimport styles from './styles.module.css'\n\nexport const FullPageContainer = ({ showIndicators = true, ...props }) => {\n const panelsCount = React.Children.count(props.children)\n\n const windowHeight = useRef(window.innerHeight)\n\n const [viewState, setViewState] = useState({\n currentPanel: 1,\n transitioning: false,\n currentTop: 0\n })\n const prevSection = () => {\n setViewState((prev) => {\n if (prev.transitioning) return prev\n if (prev.currentPanel <= 1)\n return {\n ...prev,\n currentTop: 0\n }\n setTimeout(() => {\n setViewState((prev) => ({ ...prev, transitioning: false }))\n }, 1000)\n return {\n transitioning: true,\n currentPanel: prev.currentPanel - 1,\n currentTop: -windowHeight.current * (prev.currentPanel - 2)\n }\n })\n }\n\n const nextSection = () => {\n setViewState((prev) => {\n if (prev.transitioning) return prev\n\n if (prev.currentPanel >= panelsCount)\n return {\n ...prev,\n currentTop: -windowHeight.current * (panelsCount - 1)\n }\n setTimeout(() => {\n setViewState((prev) => ({ ...prev, transitioning: false }))\n }, 1000)\n return {\n transitioning: true,\n currentPanel: prev.currentPanel + 1,\n currentTop: -windowHeight.current * prev.currentPanel\n }\n })\n }\n\n const restoreSection = () => {\n setViewState((prev) => {\n return {\n ...prev,\n currentTop: -windowHeight.current * (prev.currentPanel - 1)\n }\n })\n }\n\n const handleScroll = (e) => {\n if (e.deltaY > 40 && viewState.currentPanel < panelsCount) {\n nextSection()\n } else if (e.deltaY < -40 && viewState.currentPanel > 0) {\n prevSection()\n }\n }\n\n const onSetSection = (sectionNumber) => {\n setViewState((prev) => {\n setTimeout(() => {\n setViewState((prev) => ({ ...prev, transitioning: false }))\n }, 1000)\n return {\n transitioning: true,\n currentPanel: sectionNumber,\n currentTop: -windowHeight.current * (sectionNumber - 1)\n }\n })\n }\n\n const removeEventListeners = () => {\n window.removeEventListener('wheel', (e) => {\n handleScroll(e)\n })\n window.removeEventListener('touchstart', (e) => {\n handleSwipe(e, true)\n })\n window.removeEventListener('touchend', (e) => {\n handleSwipe(e, false)\n })\n window.removeEventListener('pointerdown', (e) => {\n handleSwipe(e.changedTouches[0].screenY, true)\n })\n window.removeEventListener('pointerup', (e) => {\n handleSwipe(e.changedTouches[0].screenY, false)\n })\n window.removeEventListener('pointermove', (e) => {\n handleDrag(e.screenY)\n })\n\n window.removeEventListener('resize', () => {\n windowHeight.current = window.innerHeight\n })\n }\n\n useEffect(() => {\n removeEventListeners()\n window.addEventListener('wheel', (e) => {\n handleScroll(e)\n })\n window.addEventListener('touchstart', (e) => {\n handleSwipe(e.changedTouches[0].screenY, true, e)\n })\n window.addEventListener('touchend', (e) => {\n handleSwipe(e.changedTouches[0].screenY, false, e)\n })\n window.addEventListener('pointerdown', (e) => {\n handleSwipe(e.screenY, true, e)\n })\n window.addEventListener('pointerup', (e) => {\n handleSwipe(e.screenY, false, e)\n })\n\n window.addEventListener('pointermove', (e) => {\n handleDrag(e.screenY)\n })\n window.addEventListener('touchmove', (e) => {\n handleDrag(e.changedTouches[0].screenY)\n })\n\n window.addEventListener('resize', () => {\n windowHeight.current = window.innerHeight\n })\n return () => {\n removeEventListeners()\n }\n }, [])\n\n const touchStartY = useRef(0)\n\n const [currentPointer, setCurrentPointer] = useState(0)\n\n const handleDrag = (screenY) => {\n if (touchStartY.current === 0) {\n return\n }\n\n let initialSet = false\n let difference = 0\n setCurrentPointer((prev) => {\n if (prev === 0) {\n initialSet = true\n return screenY\n }\n\n difference = prev - screenY\n\n if (\n (difference < 0 && difference > -2) ||\n (difference > 0 && difference < 2)\n ) {\n initialSet = true\n return prev\n }\n return screenY\n })\n if (initialSet) return\n\n setViewState((prev) => {\n if (prev.transitioning) {\n return prev\n }\n return { ...prev, currentTop: prev.currentTop - difference }\n })\n }\n\n const handleSwipe = (screenY, isStart, event) => {\n if (isStart) {\n touchStartY.current = screenY\n return\n }\n\n const touchEndY = screenY\n\n const touchDifference = touchStartY.current - touchEndY\n\n if (touchDifference < -100) {\n prevSection()\n } else if (touchDifference > 100) {\n nextSection()\n } else {\n restoreSection()\n }\n\n touchStartY.current = 0\n setCurrentPointer(0)\n }\n\n const panelsstyles = [styles.panelsContainer]\n if (viewState.transitioning) {\n panelsstyles.push(styles.panelTransitioning)\n }\n\n return (\n
\n {currentPointer !== 0 &&
}\n \n {props.children}\n {showIndicators && (\n \n )}\n
\n
\n )\n}\n\nconst NavIndicators = ({ count, activeIndex, setIndicator }) => {\n let indicatorHtml = null\n if (count) {\n indicatorHtml = Array(count)\n .fill(0)\n .map((item, i) => {\n const indicatorstyles = [styles.indicator]\n if (i === activeIndex - 1) {\n indicatorstyles.push(styles.active)\n }\n return (\n {\n setIndicator(i + 1)\n }}\n >\n ⬤\n \n )\n })\n }\n return
{indicatorHtml}
\n}\n\nexport const FullPagePanel = ({ bgColor, ...props }) => {\n return (\n
\n
{props.children}
\n
\n )\n}\n"],"names":["FullPageContainer","showIndicators","props","panelsCount","React","Children","count","children","windowHeight","useRef","window","innerHeight","useState","currentPanel","transitioning","currentTop","viewState","setViewState","prevSection","prev","setTimeout","current","nextSection","restoreSection","handleScroll","e","deltaY","onSetSection","sectionNumber","removeEventListeners","removeEventListener","handleSwipe","changedTouches","screenY","handleDrag","useEffect","addEventListener","touchStartY","currentPointer","setCurrentPointer","initialSet","difference","isStart","event","touchEndY","touchDifference","panelsstyles","styles","panelsContainer","push","panelTransitioning","screenPane","clickMask","join","top","NavIndicators","activeIndex","setIndicator","indicatorHtml","Array","fill","map","item","i","indicatorstyles","indicator","active","navIndicators","FullPagePanel","bgColor","fullPanel","backgroundColor","panelContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGaA,iBAAiB,GAAG,SAApBA,iBAAoB,OAAyC;AAAA,iCAAtCC,cAAsC;AAAA,MAAtCA,cAAsC,oCAArB,IAAqB;AAAA,MAAZC,KAAY;;AACxE,MAAMC,WAAW,GAAGC,cAAK,CAACC,QAAN,CAAeC,KAAf,CAAqBJ,KAAK,CAACK,QAA3B,CAApB;AAEA,MAAMC,YAAY,GAAGC,YAAM,CAACC,MAAM,CAACC,WAAR,CAA3B;;AAHwE,kBAKtCC,cAAQ,CAAC;AACzCC,IAAAA,YAAY,EAAE,CAD2B;AAEzCC,IAAAA,aAAa,EAAE,KAF0B;AAGzCC,IAAAA,UAAU,EAAE;AAH6B,GAAD,CAL8B;AAAA,MAKjEC,SALiE;AAAA,MAKtDC,YALsD;;AAUxE,MAAMC,WAAW,GAAG,SAAdA,WAAc,GAAM;AACxBD,IAAAA,YAAY,CAAC,UAACE,IAAD,EAAU;AACrB,UAAIA,IAAI,CAACL,aAAT,EAAwB,OAAOK,IAAP;AACxB,UAAIA,IAAI,CAACN,YAAL,IAAqB,CAAzB,EACE,6BACKM,IADL;AAEEJ,QAAAA,UAAU,EAAE;AAFd;AAIFK,MAAAA,UAAU,CAAC,YAAM;AACfH,QAAAA,YAAY,CAAC,UAACE,IAAD;AAAA,uCAAgBA,IAAhB;AAAsBL,YAAAA,aAAa,EAAE;AAArC;AAAA,SAAD,CAAZ;AACD,OAFS,EAEP,IAFO,CAAV;AAGA,aAAO;AACLA,QAAAA,aAAa,EAAE,IADV;AAELD,QAAAA,YAAY,EAAEM,IAAI,CAACN,YAAL,GAAoB,CAF7B;AAGLE,QAAAA,UAAU,EAAE,CAACP,YAAY,CAACa,OAAd,IAAyBF,IAAI,CAACN,YAAL,GA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CAxBD;;AA0BA,IAAaU,aAAa,GAAG,SAAhBA,aAAgB,QAA2B;AAAA,MAAxBC,OAAwB,SAAxBA,OAAwB;AAAA,MAAZnE,KAAY;;AACtD,sBACEE;AAAK,IAAA,SAAS,EAAE2C,MAAM,CAACuB,SAAvB;AAAkC,IAAA,KAAK,EAAE;AAAEC,MAAAA,eAAe,EAAEF;AAAnB;AAAzC,kBACEjE;AAAK,IAAA,SAAS,EAAE2C,MAAM,CAACyB;AAAvB,KAAsCtE,KAAK,CAACK,QAA5C,CADF,CADF;AAKD,CANM;;;;;"} --------------------------------------------------------------------------------