├── typings ├── custom.d.ts └── index.d.ts ├── examples ├── index.html └── index.tsx ├── src ├── index.tsx ├── decorators.tsx └── carousel.tsx ├── index.js ├── tests ├── index.js ├── helpers │ ├── phantomjs-shims.tsx │ └── raf-polyfill.tsx └── specs │ └── carousel.spec.tsx ├── tsconfig.json ├── HISTORY.md ├── .gitignore ├── LICENSE ├── package.json ├── .eslintrc └── README.md /typings/custom.d.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/index.html: -------------------------------------------------------------------------------- 1 | placeholder -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | export { default } from './carousel'; -------------------------------------------------------------------------------- /typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Carousel = require('./lib/carousel'); 4 | 5 | module.exports = Carousel; 6 | -------------------------------------------------------------------------------- /tests/index.js: -------------------------------------------------------------------------------- 1 | import './helpers/phantomjs-shims'; 2 | import './helpers/raf-polyfill'; 3 | import './specs/carousel.spec'; -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strictNullChecks": true, 4 | "moduleResolution": "node", 5 | "jsx": "preserve", 6 | "allowSyntheticDefaultImports": true, 7 | "target": "es6" 8 | } 9 | } -------------------------------------------------------------------------------- /HISTORY.md: -------------------------------------------------------------------------------- 1 | # History 2 | ---- 3 | 4 | ## 3.0.0 / 2017-09-19 5 | 6 | - `easing`/`edgeEasing`'s type change from string to Function. And change [tween-functions](https://github.com/chenglou/tween-functions) from "built-in" to "external". -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### SublimeText ### 2 | *.sublime-workspace 3 | 4 | ### OSX ### 5 | .DS_Store 6 | .AppleDouble 7 | .LSOverride 8 | Icon 9 | 10 | # Thumbnails 11 | ._* 12 | 13 | # Files that might appear on external disk 14 | .Spotlight-V100 15 | .Trashes 16 | 17 | ### Windows ### 18 | # Windows image file caches 19 | Thumbs.db 20 | ehthumbs.db 21 | 22 | # Folder config file 23 | Desktop.ini 24 | 25 | # Recycle Bin used on file shares 26 | $RECYCLE.BIN/ 27 | 28 | # App specific 29 | 30 | node_modules/ 31 | bower_components/ 32 | .tmp 33 | dist 34 | /src/scripts/main.js 35 | 36 | *.log 37 | *.log.* 38 | yarn.lock 39 | _ts2js 40 | package-lock.json -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /tests/helpers/phantomjs-shims.tsx: -------------------------------------------------------------------------------- 1 | (function() { 2 | 3 | var Ap = Array.prototype; 4 | var slice = Ap.slice; 5 | var Fp = Function.prototype; 6 | 7 | if (!Fp.bind) { 8 | // PhantomJS doesn't support Function.prototype.bind natively, so 9 | // polyfill it whenever this module is required. 10 | Fp.bind = function(context) { 11 | var func = this; 12 | var args = slice.call(arguments, 1); 13 | 14 | function bound() { 15 | var invokedAsConstructor = func.prototype && (this instanceof func); 16 | return func.apply( 17 | // Ignore the context parameter when invoking the bound function 18 | // as a constructor. Note that this includes not only constructor 19 | // invocations using the new keyword but also calls to base class 20 | // constructors such as BaseClass.call(this, ...) or super(...). 21 | !invokedAsConstructor && context || this, 22 | args.concat(slice.call(arguments)) 23 | ); 24 | } 25 | 26 | // The bound function must share the .prototype of the unbound 27 | // function so that any object created by one constructor will count 28 | // as an instance of both constructors. 29 | bound.prototype = func.prototype; 30 | 31 | return bound; 32 | }; 33 | } 34 | })(); 35 | -------------------------------------------------------------------------------- /tests/helpers/raf-polyfill.tsx: -------------------------------------------------------------------------------- 1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ 2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating 3 | 4 | // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel 5 | 6 | // MIT license 7 | 8 | (function() { 9 | var lastTime = 0; 10 | var vendors = ['ms', 'moz', 'webkit', 'o']; 11 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { 12 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; 13 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] 14 | || window[vendors[x]+'CancelRequestAnimationFrame']; 15 | } 16 | 17 | if (!window.requestAnimationFrame) 18 | window.requestAnimationFrame = function(callback) { 19 | var currTime = new Date().getTime(); 20 | var timeToCall = Math.max(0, 16 - (currTime - lastTime)); 21 | var id = window.setTimeout(function() { callback(currTime + timeToCall); }, 22 | timeToCall); 23 | lastTime = currTime + timeToCall; 24 | return id; 25 | }; 26 | 27 | if (!window.cancelAnimationFrame) 28 | window.cancelAnimationFrame = function(id) { 29 | clearTimeout(id); 30 | }; 31 | }()); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rmc-nuka-carousel", 3 | "version": "3.0.1", 4 | "description": "Pure React Carousel", 5 | "main": "./lib/index", 6 | "module": "./es/index", 7 | "dependencies": { 8 | "exenv": "^1.2.0", 9 | "raf": "^3.3.2" 10 | }, 11 | "devDependencies": { 12 | "@types/mocha": "~2.2.32", 13 | "@types/react": "~16.0.2", 14 | "@types/react-dom": "15.5.1", 15 | "expect.js": "0.3.x", 16 | "pre-commit": "1.x", 17 | "rc-test": "~6.0.3", 18 | "rc-tools": "6.x", 19 | "react": "^15.0.0", 20 | "react-dom": "^15.0.0", 21 | "tween-functions": "^1.2.0" 22 | }, 23 | "files": [ 24 | "lib", 25 | "es", 26 | "dist" 27 | ], 28 | "config": { 29 | "port": 8000, 30 | "entry": { 31 | "rmc-nuka-carousel": [ 32 | "./index.js" 33 | ] 34 | } 35 | }, 36 | "scripts": { 37 | "dist": "rc-tools run dist", 38 | "watch-tsc": "rc-tools run watch-tsc", 39 | "compile": "rc-tools run compile --babel-runtime", 40 | "build": "rc-tools run build", 41 | "gh-pages": "rc-tools run gh-pages", 42 | "start": "rc-tools run server", 43 | "prepublish": "rc-tools run guard", 44 | "prepare": "rc-tools run guard", 45 | "prepublishOnly": "rc-tools run guard", 46 | "pub": "rc-tools run pub --babel-runtime", 47 | "lint": "rc-tools run lint", 48 | "karma": "rc-test run karma", 49 | "test": "rc-test run test", 50 | "chrome-test": "rc-test run chrome-test", 51 | "coverage": "rc-test run coverage" 52 | }, 53 | "repository": { 54 | "type": "git", 55 | "url": "https://github.com/react-component/nuka-carousel.git" 56 | }, 57 | "keywords": [ 58 | "react", 59 | "carousel", 60 | "nuka" 61 | ], 62 | "author": "Ken Wheeler", 63 | "license": "MIT", 64 | "bugs": { 65 | "url": "https://github.com/react-component/nuka-carousel/issues" 66 | }, 67 | "homepage": "https://github.com/react-component/nuka-carousel" 68 | } 69 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "node": true, 4 | "browser": true, 5 | "mocha": true 6 | }, 7 | "globals": { 8 | "navigator", 9 | "$serverSide", 10 | "$isiOS", 11 | "$isAndroid", 12 | "$isBrowser" 13 | }, 14 | "parser": "babel-eslint", 15 | "ecmaFeatures": { 16 | "arrowFunctions": true, 17 | "binaryLiterals": true, 18 | "blockBindings": true, 19 | "classes": true, 20 | "defaultParams": true, 21 | "destructuring": true, 22 | "forOf": true, 23 | "generators": true, 24 | "modules": true, 25 | "objectLiteralComputedProperties": true, 26 | "objectLiteralDuplicateProperties": true, 27 | "objectLiteralShorthandMethods": true, 28 | "objectLiteralShorthandProperties": true, 29 | "spread": true, 30 | "superInFunctions": true, 31 | "templateStrings": true, 32 | "unicodeCodePointEscapes": true, 33 | "jsx": true 34 | }, 35 | "rules": { 36 | 37 | // Lint Rules 38 | 39 | "no-bitwise": 2, 40 | "eqeqeq": 2, 41 | "guard-for-in": 2, 42 | "no-use-before-define": 2, 43 | "no-caller": 2, 44 | "no-new": 0, 45 | "no-undef": 0, // Fix Me 46 | "no-unused-vars": 0, // Fix Me 47 | "strict": 0, 48 | "max-params": [2, 5], 49 | "semi": 0, 50 | "no-cond-assign": 0, 51 | "no-loop-func": 0, 52 | "no-shadow": 0, 53 | "no-underscore-dangle": 0, 54 | 55 | // Style Rules 56 | 57 | "no-with": 1, 58 | "no-eval": 1, 59 | "space-after-keywords": 1, 60 | 61 | "curly": [1, "all"], 62 | "space-before-blocks": 1, 63 | "no-empty": 1, 64 | 65 | "space-before-function-paren": [1, "never"], 66 | "wrap-iife": 1, 67 | 68 | "space-in-parens": [1, "never"], 69 | 70 | "space-infix-ops": 1, 71 | "dot-notation": 1, 72 | 73 | "camelcase": 1, 74 | "no-multi-str": 1, 75 | 76 | "no-mixed-spaces-and-tabs": 1, 77 | "no-trailing-spaces": 1, 78 | "eol-last" : 1, 79 | 80 | "comma-spacing": [1, {"before": false, "after": true}], 81 | "indent": [1, 2], 82 | "quotes": [1, "single"] 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /examples/index.tsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import Carousel from '../src/carousel'; 4 | import React from 'react'; 5 | import ReactDom from 'react-dom'; 6 | import easingTypes, { easeOutElastic } from 'tween-functions'; 7 | 8 | class App extends React.Component { 9 | state = { 10 | slideIndex: 0, 11 | }; 12 | 13 | render() { 14 | return (
15 | this.setState({ slideIndex: newSlideIndex })}> 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 |
38 | 39 | this.setState({ slideIndex: newSlideIndex })}> 46 | 47 | 48 | 49 | 50 | 51 | 52 |