├── .babelrc ├── .gitignore ├── .npmignore ├── .prettierrc ├── .travis.yml ├── LICENSE ├── README.md ├── demo ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ └── index.html ├── src │ ├── App.css │ ├── App.js │ ├── App.test.js │ ├── Demo.css │ ├── Demo.js │ ├── Stargazers.js │ ├── index.css │ ├── index.js │ └── logo.svg └── yarn.lock ├── docs ├── favicon.ico ├── index.html └── static │ ├── css │ ├── main.b671ab10.css │ └── main.b671ab10.css.map │ └── js │ ├── main.526fd85a.js │ └── main.526fd85a.js.map ├── karma.conf.js ├── package.json ├── scripts └── copy-swiper-styles.js ├── src ├── Slide.js ├── Swiper.js ├── SwiperLib.js ├── index.js ├── styles.css └── swiperEvents.js ├── test └── src │ ├── Slide.test.js │ ├── Swiper.test.js │ ├── SwiperEvents.test.js │ └── spy.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "es2015", 4 | "react", 5 | "stage-0" 6 | ], 7 | "plugins": [ 8 | "transform-object-assign" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | *.pid.lock 11 | 12 | # Directory for instrumented libs generated by jscoverage/JSCover 13 | lib-cov 14 | 15 | # Coverage directory used by tools like istanbul 16 | coverage 17 | 18 | # nyc test coverage 19 | .nyc_output 20 | 21 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 22 | .grunt 23 | 24 | # node-waf configuration 25 | .lock-wscript 26 | 27 | # Compiled binary addons (http://nodejs.org/api/addons.html) 28 | build/Release 29 | 30 | # Dependency directories 31 | node_modules 32 | jspm_packages 33 | 34 | # Optional npm cache directory 35 | .npm 36 | 37 | # Optional REPL history 38 | .node_repl_history 39 | 40 | lib 41 | 42 | ### JetBrains ### 43 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 44 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 45 | 46 | .idea/ 47 | 48 | ## File-based project format: 49 | *.iws 50 | 51 | ## Plugin-specific files: 52 | 53 | # IntelliJ 54 | /out/ 55 | 56 | # mpeltonen/sbt-idea plugin 57 | .idea_modules/ 58 | 59 | # JIRA plugin 60 | atlassian-ide-plugin.xml 61 | 62 | # Cursive Clojure plugin 63 | .idea/replstate.xml 64 | 65 | # Crashlytics plugin (for Android Studio and IntelliJ) 66 | com_crashlytics_export_strings.xml 67 | crashlytics.properties 68 | crashlytics-build.properties 69 | fabric.properties 70 | 71 | ### JetBrains Patch ### 72 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 73 | 74 | # *.iml 75 | # modules.xml 76 | # .idea/misc.xml 77 | # *.ipr 78 | 79 | # Sonarlint plugin 80 | .idea/sonarlint 81 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | demo 2 | docs 3 | src 4 | test 5 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": false, 6 | "singleQuote": true, 7 | "trailingComma": "none", 8 | "bracketSpacing": true, 9 | "jsxBracketSameLine": false, 10 | "arrowParens": "avoid" 11 | } 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 8.11.1 3 | script: "npm run test" 4 | sudo: required 5 | addons: 6 | chrome: stable 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2016 Nicholas Pisacane 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | 'Software'), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-dynamic-swiper 2 | 3 | [![Travis][travis-image]][travis-url] 4 | 5 | React wrapper for [iDangerous-Swiper][idangerous-swiper] that auto-magically 6 | reinitializes and updates when configuration changes. 7 | 8 | **[Demo](https://nickpisacane.github.io/react-dynamic-swiper)** 9 | 10 | # Installation 11 | 12 | ```sh 13 | $ npm i --save react-dynamic-swiper 14 | ``` 15 | 16 | # Usage 17 | 18 | ```js 19 | // Basic Usage 20 | function MySwiper() { 21 | return ( 22 | 29 | console.log('Slide Active!')} /> 30 | 31 | ) 32 | } 33 | 34 | // Advanced Usage 35 | // 36 | // Swiper will automatically update swiper instance when children change (i.e. Slides), 37 | // and/or re-initialize if swiper options change. Also, event handlers 38 | // (`onTouchMove`, `onSlideChangeEnd`, etc.) are delegated. Changing them will 39 | // require no reinitialization, while still functioning as expected. 40 | import React, { Component } from 'react' 41 | import { Swiper, Slide } from 'react-dynamic-swiper' 42 | import 'react-dynamic-swiper/lib/styles.css' 43 | 44 | class MySwiper extends Component { 45 | constructor(props, context) { 46 | super(props, context) 47 | this.state = { 48 | slides: [] 49 | } 50 | } 51 | 52 | componentWillMount() { 53 | getAsyncSlideData().then(slides => this.setState({ slides })) 54 | } 55 | 56 | render() { 57 | const { slides } = this.state 58 | 59 | return ( 60 | } 65 | prevButton={swiper => ( 66 | swiper.slideNext()} /> 67 | )} 68 | onTouchMove={(swiper, event) => doSomething()} 69 | > 70 | {slides.map(slide => ( 71 | 72 | ))} 73 | 74 | ) 75 | } 76 | } 77 | ``` 78 | 79 | # API 80 | 81 | ## Swiper 82 | 83 | #### Props 84 | 85 | - swiperOptions (Object) Options passed to swiper instance. 86 | - containerClassName (String) Classname for underlying container element. 87 | - wrapperClassName (String) Classname for underlying wrapper element. 88 | - navigation (Boolean) Display navigation elements (`true`) 89 | - nextButton (Element|Function) Navigation next element (`
`) 90 | - prevButton (Element|Function) Navigation previous element (`
`) 91 | - pagination (Boolean|Element|Function) Pagination is active by default, use `false` to hide. (`
`) 92 | - paginationClickable (Boolean) Enable clickable pagination. 93 | - scrollBar (Boolean|Element|Function) Scrollbar is hidden by default, use `false` to show. 94 | - onInitSwiper (Function) Function invoked every time swiper instance is initialized, invoked will `swiper` as first argument. 95 | - All event handlers are supported as well (i.e. onTouchMove, etc.) 96 | 97 | _note_: The following props can be functions: nextButton, prevButton, pagination, and scrollBar. If functions, they 98 | will be invoked with the underlying `Swiper` instance as the one and only argument. They must return a renderable element. 99 | 100 | #### Methods 101 | 102 | - swiper() Returns underlying swiper instance. 103 | 104 | ## Slide 105 | 106 | #### Props 107 | 108 | - onActive (Function) Invoked with swiper instance when `Slide` is active. Not invoked on initialization. 109 | 110 | [idangerous-swiper]: http://idangero.us/swiper 111 | [travis-image]: https://travis-ci.org/nickpisacane/react-dynamic-swiper.svg?branch=master 112 | [travis-url]: https://travis-ci.org/nickpisacane/react-dynamic-swiper 113 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | 6 | # testing 7 | coverage 8 | 9 | # production 10 | build 11 | 12 | # misc 13 | .DS_Store 14 | .env 15 | npm-debug.log 16 | -------------------------------------------------------------------------------- /demo/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). 2 | 3 | Below you will find some information on how to perform common tasks. 4 | You can find the most recent version of this guide [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md). 5 | 6 | ## Table of Contents 7 | 8 | - [Updating to New Releases](#updating-to-new-releases) 9 | - [Sending Feedback](#sending-feedback) 10 | - [Folder Structure](#folder-structure) 11 | - [Available Scripts](#available-scripts) 12 | - [npm start](#npm-start) 13 | - [npm test](#npm-test) 14 | - [npm run build](#npm-run-build) 15 | - [npm run eject](#npm-run-eject) 16 | - [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor) 17 | - [Installing a Dependency](#installing-a-dependency) 18 | - [Importing a Component](#importing-a-component) 19 | - [Adding a Stylesheet](#adding-a-stylesheet) 20 | - [Post-Processing CSS](#post-processing-css) 21 | - [Adding Images and Fonts](#adding-images-and-fonts) 22 | - [Using the `public` Folder](#using-the-public-folder) 23 | - [Adding Bootstrap](#adding-bootstrap) 24 | - [Adding Flow](#adding-flow) 25 | - [Adding Custom Environment Variables](#adding-custom-environment-variables) 26 | - [Can I Use Decorators?](#can-i-use-decorators) 27 | - [Integrating with a Node Backend](#integrating-with-a-node-backend) 28 | - [Proxying API Requests in Development](#proxying-api-requests-in-development) 29 | - [Using HTTPS in Development](#using-https-in-development) 30 | - [Generating Dynamic `` Tags on the Server](#generating-dynamic-meta-tags-on-the-server) 31 | - [Running Tests](#running-tests) 32 | - [Filename Conventions](#filename-conventions) 33 | - [Command Line Interface](#command-line-interface) 34 | - [Version Control Integration](#version-control-integration) 35 | - [Writing Tests](#writing-tests) 36 | - [Testing Components](#testing-components) 37 | - [Using Third Party Assertion Libraries](#using-third-party-assertion-libraries) 38 | - [Initializing Test Environment](#initializing-test-environment) 39 | - [Focusing and Excluding Tests](#focusing-and-excluding-tests) 40 | - [Coverage Reporting](#coverage-reporting) 41 | - [Continuous Integration](#continuous-integration) 42 | - [Disabling jsdom](#disabling-jsdom) 43 | - [Experimental Snapshot Testing](#experimental-snapshot-testing) 44 | - [Deployment](#deployment) 45 | - [Building for Relative Paths](#building-for-relative-paths) 46 | - [GitHub Pages](#github-pages) 47 | - [Heroku](#heroku) 48 | - [Modulus](#modulus) 49 | - [Now](#now) 50 | - [Surge](#surge) 51 | - [Something Missing?](#something-missing) 52 | 53 | ## Updating to New Releases 54 | 55 | Create React App is divided into two packages: 56 | 57 | * `create-react-app` is a global command-line utility that you use to create new projects. 58 | * `react-scripts` is a development dependency in the generated projects (including this one). 59 | 60 | You almost never need to update `create-react-app` itself: it’s delegates all the setup to `react-scripts`. 61 | 62 | When you run `create-react-app`, it always creates the project with the latest version of `react-scripts` so you’ll get all the new features and improvements in newly created apps automatically. 63 | 64 | To update an existing project to a new version of `react-scripts`, [open the changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md), find the version you’re currently on (check `package.json` in this folder if you’re not sure), and apply the migration instructions for the newer versions. 65 | 66 | In most cases bumping the `react-scripts` version in `package.json` and running `npm install` in this folder should be enough, but it’s good to consult the [changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md) for potential breaking changes. 67 | 68 | We commit to keeping the breaking changes minimal so you can upgrade `react-scripts` painlessly. 69 | 70 | ## Sending Feedback 71 | 72 | We are always open to [your feedback](https://github.com/facebookincubator/create-react-app/issues). 73 | 74 | ## Folder Structure 75 | 76 | After creation, your project should look like this: 77 | 78 | ``` 79 | my-app/ 80 | README.md 81 | node_modules/ 82 | package.json 83 | public/ 84 | index.html 85 | favicon.ico 86 | src/ 87 | App.css 88 | App.js 89 | App.test.js 90 | index.css 91 | index.js 92 | logo.svg 93 | ``` 94 | 95 | For the project to build, **these files must exist with exact filenames**: 96 | 97 | * `public/index.html` is the page template; 98 | * `src/index.js` is the JavaScript entry point. 99 | 100 | You can delete or rename the other files. 101 | 102 | You may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack. 103 | You need to **put any JS and CSS files inside `src`**, or Webpack won’t see them. 104 | 105 | Only files inside `public` can be used from `public/index.html`. 106 | Read instructions below for using assets from JavaScript and HTML. 107 | 108 | You can, however, create more top-level directories. 109 | They will not be included in the production build so you can use them for things like documentation. 110 | 111 | ## Available Scripts 112 | 113 | In the project directory, you can run: 114 | 115 | ### `npm start` 116 | 117 | Runs the app in the development mode.
118 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 119 | 120 | The page will reload if you make edits.
121 | You will also see any lint errors in the console. 122 | 123 | ### `npm test` 124 | 125 | Launches the test runner in the interactive watch mode. 126 | See the section about [running tests](#running-tests) for more information. 127 | 128 | ### `npm run build` 129 | 130 | Builds the app for production to the `build` folder.
131 | It correctly bundles React in production mode and optimizes the build for the best performance. 132 | 133 | The build is minified and the filenames include the hashes.
134 | Your app is ready to be deployed! 135 | 136 | ### `npm run eject` 137 | 138 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 139 | 140 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 141 | 142 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 143 | 144 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 145 | 146 | ## Displaying Lint Output in the Editor 147 | 148 | >Note: this feature is available with `react-scripts@0.2.0` and higher. 149 | 150 | Some editors, including Sublime Text, Atom, and Visual Studio Code, provide plugins for ESLint. 151 | 152 | They are not required for linting. You should see the linter output right in your terminal as well as the browser console. However, if you prefer the lint results to appear right in your editor, there are some extra steps you can do. 153 | 154 | You would need to install an ESLint plugin for your editor first. 155 | 156 | >**A note for Atom `linter-eslint` users** 157 | 158 | >If you are using the Atom `linter-eslint` plugin, make sure that **Use global ESLint installation** option is checked: 159 | 160 | > 161 | 162 | Then add this block to the `package.json` file of your project: 163 | 164 | ```js 165 | { 166 | // ... 167 | "eslintConfig": { 168 | "extends": "react-app" 169 | } 170 | } 171 | ``` 172 | 173 | Finally, you will need to install some packages *globally*: 174 | 175 | ```sh 176 | npm install -g eslint-config-react-app@0.2.1 eslint@3.5.0 babel-eslint@6.1.2 eslint-plugin-react@6.3.0 eslint-plugin-import@1.12.0 eslint-plugin-jsx-a11y@2.2.2 eslint-plugin-flowtype@2.18.1 177 | ``` 178 | 179 | We recognize that this is suboptimal, but it is currently required due to the way we hide the ESLint dependency. The ESLint team is already [working on a solution to this](https://github.com/eslint/eslint/issues/3458) so this may become unnecessary in a couple of months. 180 | 181 | ## Installing a Dependency 182 | 183 | The generated project includes React and ReactDOM as dependencies. It also includes a set of scripts used by Create React App as a development dependency. You may install other dependencies (for example, React Router) with `npm`: 184 | 185 | ``` 186 | npm install --save 187 | ``` 188 | 189 | ## Importing a Component 190 | 191 | This project setup supports ES6 modules thanks to Babel. 192 | While you can still use `require()` and `module.exports`, we encourage you to use [`import` and `export`](http://exploringjs.com/es6/ch_modules.html) instead. 193 | 194 | For example: 195 | 196 | ### `Button.js` 197 | 198 | ```js 199 | import React, { Component } from 'react'; 200 | 201 | class Button extends Component { 202 | render() { 203 | // ... 204 | } 205 | } 206 | 207 | export default Button; // Don’t forget to use export default! 208 | ``` 209 | 210 | ### `DangerButton.js` 211 | 212 | 213 | ```js 214 | import React, { Component } from 'react'; 215 | import Button from './Button'; // Import a component from another file 216 | 217 | class DangerButton extends Component { 218 | render() { 219 | return