1.1.3 • Published 3 years ago

carosello-campus-opacita 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.

ajvacceptsacornacorn-jsxajv-errorsansi-colorsansi-htmlansi-escapesansi-regexanymatchansi-stylesaprobaargparseajv-keywordsarr-diffarr-flattenarr-unionarray-flattenarray-unionarray-uniqasn1.jsarray-uniqueassign-symbolsassertasyncastral-regexasync-limiterasync-eachatobbabel-code-framebabel-helper-bindify-decoratorsbabel-generatorbabel-helper-builder-binary-assignment-operator-visitorbabel-helper-call-delegatebabel-helper-builder-react-jsxbabel-helper-explode-assignable-expressionbabel-helper-define-mapbabel-helper-explode-classbabel-helper-function-namebabel-helper-get-function-aritybabel-helper-optimise-call-expressionbabel-helper-hoist-variablesbabel-helper-regexbabel-helper-remap-async-to-generatorbabel-helper-replace-supersbabel-messagesbabel-helpersbabel-plugin-syntax-async-generatorsbabel-plugin-syntax-class-constructor-callbabel-plugin-check-es2015-constantsbabel-plugin-syntax-async-functionsbabel-plugin-syntax-decoratorsbabel-plugin-syntax-class-propertiesbabel-plugin-syntax-do-expressionsbabel-plugin-syntax-dynamic-importbabel-plugin-syntax-export-extensionsbabel-plugin-syntax-exponentiation-operatorbabel-plugin-syntax-flowbabel-plugin-syntax-jsxbabel-plugin-syntax-function-bindbabel-plugin-syntax-object-rest-spreadbabel-plugin-transform-async-generator-functionsbabel-plugin-syntax-trailing-function-commasbabel-plugin-transform-async-to-generatorbabel-plugin-transform-decoratorsbabel-plugin-transform-class-constructor-callbabel-plugin-transform-class-propertiesbabel-plugin-transform-do-expressionsbabel-plugin-transform-es2015-arrow-functionsbabel-plugin-transform-es2015-block-scoped-functionsbabel-plugin-transform-es2015-destructuringbabel-plugin-transform-es2015-block-scopingbabel-plugin-transform-es2015-classesbabel-plugin-transform-es2015-computed-propertiesbabel-plugin-transform-es2015-duplicate-keysbabel-plugin-transform-es2015-literalsbabel-plugin-transform-es2015-function-namebabel-plugin-transform-es2015-for-ofbabel-plugin-transform-es2015-modules-amdbabel-plugin-transform-es2015-modules-systemjsbabel-plugin-transform-es2015-modules-commonjsbabel-plugin-transform-es2015-object-superbabel-plugin-transform-es2015-modules-umdbabel-plugin-transform-es2015-parametersbabel-plugin-transform-es2015-shorthand-propertiesbabel-plugin-transform-es2015-spreadbabel-plugin-transform-es2015-sticky-regexbabel-plugin-transform-es2015-template-literalsbabel-plugin-transform-exponentiation-operatorbabel-plugin-transform-es2015-unicode-regexbabel-plugin-transform-es2015-typeof-symbolbabel-plugin-transform-export-extensionsbabel-plugin-transform-flow-strip-typesbabel-plugin-transform-function-bindbabel-plugin-transform-react-display-namebabel-plugin-transform-regeneratorbabel-plugin-transform-react-jsx-selfbabel-plugin-transform-react-jsx-sourcebabel-plugin-transform-strict-modebabel-preset-flowbabel-preset-stage-2babel-preset-stage-1babel-registerbabel-preset-stage-3babel-runtimebabel-templatebabel-traversebabel-typesbabylonbalanced-matchbase64-jsbasebatchbig.jsbn.jsbluebirdbinary-extensionsbonjourbody-parserbrace-expansionbracesbrowserify-aesbrowserify-cipherbrorandbrowserify-desbrowserify-rsabrowserify-signbrowserify-zlibbufferbuffer-frombrowserslistbuffer-indexofbuiltin-status-codescacachebuffer-xorbytescache-basecamelcasecallsitescaniuse-litechalkchardetchownrcipher-basechrome-trace-eventchokidarcli-cursorclass-utilscli-widthcliuicode-point-atcollection-visitcolor-convertcolor-namecommandercommondircomponent-emittercompressiblecompressionconcat-streamconcat-mapconnect-history-api-fallbackconsole-browserifyconstants-browserifycontent-dispositioncontent-typeconvert-source-mapcookiecookie-signaturecopy-concurrentlycopy-descriptorcore-util-iscore-jscreate-ecdhcreate-hashcreate-hmaccross-spawncrypto-browserifycyclistdate-nowdebugdecamelizedeep-equaldecode-uri-componentdeep-isdefault-gatewaydefine-propertiesdefine-propertydeldepddes.jsdestroydetect-filedetect-indentdetect-nodedns-equaldiffie-hellmandns-packetdns-txtdoctrinedomain-browserduplexifyee-firstelectron-to-chromiumellipticemoji-regexemojis-listend-of-streamencodeurlenhanced-resolveerrnoescape-htmlescape-string-regexpeslint-scopeeslint-utilseslint-visitor-keysespreeesprimaesqueryesrecurseestraverseesutilsetageventemitter3eventsevp_bytestokeyexecaexpand-bracketsexpand-rangeexpand-tildeexpressextend-shallowexternal-editorfast-deep-equalextglobfast-levenshteineventsourcefiggy-puddingfiguresfile-entry-cachefill-rangefilename-regexfinalhandlerfind-cache-dirfind-upfindup-syncflat-cacheflush-write-streamflattedfor-infollow-redirectsfor-ownforwardedfragment-cachefrom2freshfs-readdir-recursivefs-write-stream-atomicfs.realpathfseventsfunction-bindfunctional-red-black-treeget-caller-fileget-streamget-valuefaye-websocketglobal-modulesglobglobal-prefixglob-parentglobbyglobalsgraceful-fshandle-thinghashas-ansihas-valueshas-flaghas-valuehash-basehash.jshome-or-tmphomedir-polyfillhpack.jshtml-entitieshmac-drbghttp-deceiverhttp-errorshttp-parser-jshttp-proxyhttp-proxy-middlewarehttps-browserifyiconv-liteieee754iferrglob-baseimport-localimport-freshimurmurhashinfer-ownerinflightinheritsiniinquirerinternal-ipinterpretinvariantinvert-kvipip-regexipaddr.jsis-absolute-urlis-accessor-descriptoris-argumentsis-binary-pathis-bufferis-data-descriptoris-date-objectis-descriptoris-dotfileis-equal-shallowis-extglobis-extendableis-finiteis-fullwidth-code-pointis-numberis-globis-path-cwdis-path-in-cwdis-path-insideis-plain-objis-posix-bracketis-plain-objectis-primitiveis-promiseis-regexis-streamis-windowsis-wslisarrayisexeisobjectjs-tokensjs-yamljsescjson-parse-better-errorsjson-schema-traversejson-stable-stringify-without-jsonifyjson3json5killablekind-oflcidlevnloader-runnerloader-utilslocate-pathlodashloglevelloose-envifylru-cachemake-dirmamacromap-age-cleanermap-cachemap-visitmath-randommd5.jsmedia-typermemory-fsmemmethodsmerge-descriptorsmicromatchmiller-rabinmime-dbmimemime-typesmimic-fnminimalistic-assertminimalistic-crypto-utilsminimatchmississippiminimistmixin-deepmove-concurrentlymkdirpmsmulticast-dnsmute-streamnannanomatchnatural-comparemulticast-dns-service-typesnegotiatorneo-asyncnice-trynode-forgenode-libs-browsernormalize-pathnpm-run-pathobject-assignnumber-is-nanobject-copyobject-isobject-keysfast-json-stable-stringifyobject.pickobufon-finishedobject-visiton-headersonceonetimeopnoptionatororiginalos-browserifyos-homediros-localeos-tmpdiroutput-file-syncp-deferp-finallyp-is-promisep-locatep-limitp-mapp-retryp-trypakoparallel-transformparent-moduleparse-asn1parse-globparse-passwdparseurlpascalcasepath-browserifypath-dirnamepath-existspath-is-insidepath-is-absolutepath-keypath-parsepath-to-regexppbkdf2pifypinkie-promisepinkiepkg-dirportfinderposix-character-classesprelude-lspreserveprivateprocessprocess-nextick-argsprogresspromise-inflightprrproxy-addrpumppublic-encryptpumpifyqsquerystringpunycodequerystring-es3querystringifyrandomaticrandombytesrandomfillrange-parserraw-bodyreadable-streamreact-isreaddirpregenerateregenerator-runtimeregenerator-transformregex-cacheregex-notregexp.prototype.flagsregexppregexpu-coreremove-trailing-separatorobject.omitignorerequire-main-filenamerequire-directoryregjsgenrequires-portrepeat-stringresolveresolve-cwdresolve-dirresolve-fromretryresolve-urlretrimrafripemd160run-queuerun-asyncrxjsrestore-cursorsafe-buffersafer-buffersafe-regexschedulerselfsignedselect-hosesendsemverserialize-javascriptserve-indexserve-staticset-blockingrepeatingsetprototypeofset-valuesha.jsshebang-regexshebang-commandsignal-exitsnapdragonslashslice-ansisnapdragon-nodesnapdragon-utilsockjssockjs-clientsource-list-mapsource-map-supportsource-mapsource-map-resolvesource-map-urlspdyspdy-transportsplit-stringssrisprintf-jsstatic-extendstream-browserifystatusesstream-eachstream-httpstring-widthstream-shiftstring_decoderstrip-ansistrip-eofstrip-json-commentstablesupports-colortersertapableterser-webpack-pluginthrough2text-tablethroughtimers-browserifythunkyto-arraybuffertmpto-fast-propertiesto-object-pathto-regex-rangeto-regextoidentifiertrim-righttype-checktslibtty-browserifytype-festtype-isunion-valuetypedarrayunique-slugunique-filenameunset-valueunpipeupathuri-jsurixurlurl-parseutiluseutil-deprecateutils-mergevm-browserifyuuidv8-compile-cachevarywbufwatchpackwebpack-logwebpack-dev-middlewarewebpack-sourceswebsocket-driverwebsocket-extensionswhichwhich-modulewrap-ansiwordwrapworker-farmwrappywritewsxtendyargsy18nyallistyargs-parserregjsparserrepeat-elementsetimmediate
1.1.3

3 years ago