1.1.3 • Published 3 years ago

campus2 v1.1.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

React Card Carousel

A simple React carousel.

  • GitHub
  • Demo

Installation

npm install react-card-carousel --save

Peer Dependencies

Be sure to have all peer dependencies installed as well. React Card Carousel requires the peer dependencies below:

  • react
  • react-dom
  • prop-types

Current Version: 1.1.3

  • 1.1.3 fixed setState warning on componentWillUnmount
  • Removed styled-components as a peer dependency
  • Greatly reduced package size
  • Various bug fixes

Usage

Import ReactCardCarousel and use it as a wrapper around card elements. Example:

import React, { Component } from 'react';
import ReactCardCarousel from 'react-card-carousel';

class MyCarousel extends Component {

  static get CARD_STYLE() {
    return {
      height: '200px',
      width: '200px',
      paddingTop: '80px',
      textAlign: 'center',
      background: '#52C0F5',
      color: '#FFF',
      fontSize: '12px',
      textTransform: 'uppercase',
      borderRadius: '10px',
    };
  }

  render() {
    return (
      <ReactCardCarousel autoplay={ true } autoplay_speed={ 2500 }>
        <div style={ MyCarousel.CARD_STYLE }>
          First Card
        </div>
        <div style={ MyCarousel.CARD_STYLE }>
          Second Card
        </div>
        <div style={ MyCarousel.CARD_STYLE }>
          Third Card
        </div>
        <div style={ MyCarousel.CARD_STYLE }>
          Fourth Card
        </div>
        <div style={ MyCarousel.CARD_STYLE }>
          Fifth Card
        </div>
      </ReactCardCarousel>
    );
  }
}

export default MyCarousel;

Props

  • alignment (String, oneOfhorizontal, vertical, default: horizontal): Card alignment display.
  • spread (String, oneOfnarrow, medium, wide, default: medium): Spread between cards.
  • initial_index (Number, default: 0): Which card to display as center card initially.
  • disable_keydown (Boolean, default: false): Disables left and right arrow key scroll.
  • disable_box_shadow (Boolean, default: false): Disables box shadow around center card.
  • disable_fade_in (Boolean, default: false): Disables initial animation on component render.
  • autoplay (Boolean, default: false)
  • autoplay_speed (Number, default: 5000): Number in milliseconds.
  • afterChange (Function (cardIndex) => {}, default: null): After card change function.

Methods

To use any instance methods, you must first create a ref to the ReactCardCarousel instance. Learn more about React refs in the official documentation.

<ReactCardCarousel ref={ Carousel => this.Carousel = Carousel }>

The methods can be accessed on the this.Carousel instance:

  • this.Carousel.next(): Sets next card as center card.
  • this.Carousel.prev(): Sets previous card as center card.
  • this.Carousel.goTo(index): Sets the specified number index as center card.
  • this.Carousel.getCurrentIndex(): Gets current card index.

NOTE: If you choose to create the ref using React.createRef() instead of using a callback ref, the methods can be accessed on the this.Carousel.current instance.

Credits

Created by @strawbee at Tomorrow Ideas.

acceptsacorn-jsxajvajv-errorsansi-colorsacornansi-htmlajv-keywordsansi-escapesansi-stylesargparseansi-regexaprobaanymatcharr-diffarr-flattenarr-unionarray-flattenarray-unionarray-uniqarray-uniqueassertassign-symbolsasn1.jsasync-eachastral-regexatobbabel-code-frameasync-limiterasyncbabel-helper-bindify-decoratorsbabel-generatorbabel-helper-builder-binary-assignment-operator-visitorbabel-helper-call-delegatebabel-helper-builder-react-jsxbabel-helper-function-namebabel-helper-define-mapbabel-helper-explode-assignable-expressionbabel-helper-hoist-variablesbabel-helper-explode-classbabel-helper-get-function-aritybabel-helper-optimise-call-expressionbabel-helper-remap-async-to-generatorbabel-helper-replace-supersbabel-helper-regexbabel-helpersbabel-plugin-check-es2015-constantsbabel-plugin-syntax-async-functionsbabel-plugin-syntax-class-constructor-callbabel-plugin-syntax-class-propertiesbabel-plugin-syntax-decoratorsbabel-plugin-syntax-do-expressionsbabel-plugin-syntax-dynamic-importbabel-messagesbabel-plugin-syntax-exponentiation-operatorbabel-plugin-syntax-flowbabel-plugin-syntax-function-bindbabel-plugin-syntax-export-extensionsbabel-plugin-syntax-jsxbabel-plugin-syntax-trailing-function-commasbabel-plugin-transform-async-generator-functionsbabel-plugin-syntax-object-rest-spreadbabel-plugin-transform-decoratorsbabel-plugin-transform-async-to-generatorbabel-plugin-transform-do-expressionsbabel-plugin-transform-es2015-arrow-functionsbabel-plugin-transform-class-propertiesbabel-plugin-transform-es2015-block-scopingbabel-plugin-transform-es2015-block-scoped-functionsbabel-plugin-transform-es2015-computed-propertiesbabel-plugin-transform-es2015-destructuringbabel-plugin-transform-class-constructor-callbabel-plugin-transform-es2015-classesbabel-plugin-transform-es2015-for-ofbabel-plugin-transform-es2015-function-namebabel-plugin-transform-es2015-literalsbabel-plugin-transform-es2015-duplicate-keysbabel-plugin-transform-es2015-modules-commonjsbabel-plugin-transform-es2015-modules-amdbabel-plugin-transform-es2015-modules-systemjsbabel-plugin-transform-es2015-parametersbabel-plugin-transform-es2015-object-superbabel-plugin-transform-es2015-shorthand-propertiesbabel-plugin-transform-es2015-template-literalsbabel-plugin-transform-es2015-modules-umdbabel-plugin-transform-es2015-typeof-symbolbabel-plugin-transform-export-extensionsbabel-plugin-transform-exponentiation-operatorbabel-plugin-transform-es2015-sticky-regexbabel-plugin-transform-function-bindbabel-plugin-transform-flow-strip-typesbabel-plugin-transform-es2015-unicode-regexbabel-plugin-transform-react-jsx-sourcebabel-plugin-transform-react-jsx-selfbabel-preset-flowbabel-plugin-transform-strict-modebabel-preset-stage-1babel-preset-stage-3babel-registerbabel-runtimebabel-plugin-transform-react-display-namebabel-plugin-syntax-async-generatorsbabel-plugin-transform-es2015-spreadbabel-traversebabel-templatebabel-typesbabylonbase64-jsbatchbasebig.jsbalanced-matchbluebirdbinary-extensionsbn.jsbody-parserbracesbrorandbonjourbrowserify-aesbrowserify-desbrowserify-rsabrowserify-signbrowserify-cipherbrowserify-zlibbufferbrowserslistbuffer-frombuffer-indexofbuffer-xorbuiltin-status-codesbytescacachecache-basecallsitesbrace-expansioncamelcasechalkchardetcaniuse-litechokidarchownrcipher-basechrome-trace-eventcli-cursorcli-widthcode-point-atcollection-visitcolor-convertclass-utilscliuicolor-namecommandercommondircompressiblecompressionconcat-mapcomponent-emitterconcat-streamconnect-history-api-fallbackconsole-browserifyconstants-browserifycontent-dispositioncontent-typecookiecookie-signaturecopy-concurrentlycopy-descriptorcreate-ecdhconvert-source-mapcreate-hmacbabel-plugin-transform-regeneratorcreate-hashcross-spawnbabel-preset-stage-2core-util-iscore-jsdate-nowcyclistdebugdecamelizedeep-equaldecode-uri-componentdeep-isdefault-gatewaydefine-propertydepddes.jsdefine-propertiesdiffie-hellmandetect-nodedetect-indentdetect-filedns-equaldns-packetdns-txtdoctrineduplexifydestroyelectron-to-chromiumdomain-browseree-firstcrypto-browserifyellipticemojis-listencodeurlemoji-regexenhanced-resolveend-of-streamerrnoescape-string-regexpescape-htmleslint-scopeeslint-visitor-keyseslint-utilsdelesprimaesrecurseesutilsestraverseetageventemitter3eventsourceeventsevp_bytestokeyexpand-bracketsexpand-rangeexecaexpand-tildeextend-shallowexternal-editorextglobexpressfast-deep-equalfast-json-stable-stringifyfast-levenshteinfiggy-puddingfile-entry-cachefiguresfilename-regexfill-rangefind-cache-dirfinalhandlerfind-upfindup-syncflat-cacheflattedespreeflush-write-streamfollow-redirectsfor-ownfor-infreshfragment-cachefaye-websocketfs-readdir-recursivefs.realpathfs-write-stream-atomicfrom2forwardedfunctional-red-black-treeget-valueglobfunction-bindget-streamglobal-modulesglobal-prefixglob-parentglobalsgraceful-fshandle-thingglobbyglob-basehas-flaghashas-ansihas-valuehash-basehash.jshas-valueshomedir-polyfillhmac-drbghpack.jshttp-deceiverhome-or-tmphtml-entitieshttp-errorshttp-parser-jshttp-proxyhttp-proxy-middlewarehttps-browserifyiconv-liteieee754iferrimport-freshimport-localimurmurhashinflightinheritsinfer-owneriniignoreinquirerinternal-ipget-caller-fileinterpretinvariantinvert-kvipis-absolute-urlipaddr.jsis-argumentsis-binary-pathis-accessor-descriptorip-regexis-data-descriptoris-bufferis-descriptoris-date-objectis-dotfileis-equal-shallowis-finiteis-extendableis-fullwidth-code-pointis-globis-path-in-cwdis-path-cwdis-numberis-extglobis-posix-bracketis-path-insideis-plain-objis-primitiveis-promiseis-streamis-regexis-wslisarrayisobjectisexejs-tokensjs-yamlis-plain-objectjsescjson-schema-traversejson3json-stable-stringify-without-jsonifyjson-parse-better-errorskillablelcidjson5levnloader-runnerlocate-pathlodashesqueryloglevelloose-envifylru-cachemake-diris-windowsmamacromap-age-cleanermap-visitmap-cachemath-randommd5.jsmedia-typermemmemory-fsmerge-descriptorsmethodsmicromatchmiller-rabinmimemime-dbminimalistic-assertmime-typesmimic-fnminimalistic-crypto-utilsminimistminimatchmississippimkdirpmixin-deepmsmulticast-dns-service-typesmulticast-dnsnanmove-concurrentlymute-streamnanomatchnatural-comparenegotiatornice-tryneo-asyncnode-libs-browsernode-forgenumber-is-nannormalize-pathnpm-run-pathobject-isobject-assignobject-copyobject-visitobject.omitobject.pickobject-keysobufon-finishedonceonetimeopnkind-ofoptionatoron-headersoriginalos-tmpdiros-localep-deferp-finallyoutput-file-syncp-limitos-browserifyp-locatep-retryp-mapparallel-transformp-trypakop-is-promiseparse-asn1parent-moduleparse-passwdpascalcaseparseurlpath-dirnamepath-browserifyparse-globloader-utilspath-existspath-is-insidepath-is-absolutepath-to-regexppath-keypath-parsepbkdf2pifyos-homedirpinkiepkg-dirpinkie-promiseprelude-lsportfinderposix-character-classespreserveprocessprivateprocess-nextick-argsprogresspromise-inflightprrproxy-addrpumppumpifypunycodeqsquerystring-es3querystringquerystringifyrandomaticrandombytesraw-bodypublic-encryptrange-parserrandomfillreact-isregeneratereaddirpregex-cacheregenerator-runtimeregex-notreadable-streamregenerator-transformregexp.prototype.flagsregexppregjsgenregexpu-coreremove-trailing-separatorrepeat-stringrepeat-elementregjsparserrequire-main-filenamerequires-portrequire-directoryresolveresolve-cwdresolve-fromresolve-dirretryrestore-cursorretripemd160run-asyncrimrafrun-queuerxjssafe-regexsafe-buffersafer-bufferschedulerselect-hoserepeatingselfsignedsemverserialize-javascriptserve-indexserve-staticset-blockingset-valuesetimmediatesendsetprototypeofsha.jsshebang-commandshebang-regexsignal-exitslashslice-ansisnapdragonsnapdragon-nodesnapdragon-utilsockjs-clientsource-list-mapsource-mapsource-map-urlsource-map-resolvesource-map-supportsockjsspdyspdy-transportsplit-stringsprintf-jsssristatic-extendstream-browserifystream-shiftstream-httpstream-eachstring-widthstrip-ansistring_decoderstrip-json-commentsstatusessupports-colortableterserterser-webpack-plugintext-tablethroughthunkystrip-eoftimers-browserifythrough2to-arraybufferto-object-pathtmpto-regexto-regex-rangetrim-rightto-fast-propertiestslibtty-browserifytoidentifiertype-checktype-festtype-istypedarrayunique-filenameunion-valueresolve-urltapableunset-valueurixunique-sluguri-jsupathurl-parseurlutilutil-deprecateutils-mergeuuidv8-compile-cacheusevaryvm-browserifywatchpackunpipewebpack-dev-middlewarewebpack-logwebpack-sourceswebsocket-driverwebsocket-extensionswhichwhich-moduleworker-farmwrap-ansiwrappywritewswbufxtendy18nyallistyargswordwrapyargs-parserfsevents
1.1.3

3 years ago