Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
nuka-carousel
Advanced tools
A Pure ReactJS Carousel Component
$ yarn add nuka-carousel
import React from 'react';
import Carousel from 'nuka-carousel';
export default class extends React.Component {
render() {
return (
<Carousel>
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide1" />
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide2" />
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide3" />
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide4" />
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide5" />
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide6" />
</Carousel>
);
}
}
The demo can be launched on local machine via webpack-dev-server
. Run the following:
yarn start
Now, you can access the application on your localhost at following url: Demo
React.PropTypes.func
Hook to be called after a slide is changed.
React.PropTypes.bool
Autoplay mode active. Defaults to false.
React.PropTypes.number
Interval for autoplay iteration. Defaults to 3000.
React.PropTypes.func
Hook to be called before a slide is changed.
React.PropTypes.oneOf(['left', 'center', 'right'])
When displaying more than one slide, sets which position to anchor the current slide to.
React.PropTypes.number
Space between slides, as an integer, but reflected as px
React.PropTypes.bool
Enable mouse swipe/dragging
React.PropTypes.string
Animation easing function. See valid easings here: D3 Easing Functions.
React.PropTypes.string
Used to set the margin of the slider frame. Accepts any string dimension value such as "0px 20px"
or "500px"
.
React.PropTypes.string
Used to set overflow style property on slider frame. Defaults to hidden
.
React.PropTypes.string
Animation easing function when swipe exceeds edge. See valid easings here: D3 Easing Functions.
React.PropTypes.number
Initial height of the slides in pixels.
React.PropTypes.number
Initial width of the slides in pixels.
React.PropTypes.func
A set of eight render props for rendering controls in different positions around the carousel.
renderTopLeftControls
, renderTopCenterControls
, renderTopRightControls
, renderCenterLeftControls
, renderCenterCenterControls
, renderCenterRightControls
, renderBottomLeftControls
, renderBottomCenterControls
, and renderBottomRightControls
.<Carousel
renderTopCenterControls={({ currentSlide }) => (
<div>Slide: {currentSlide}</div>
)}
renderCenterLeftControls={({ previousSlide }) => (
<button onClick={previousSlide}>Previous</button>
)}
renderCenterRightControls={({ nextSlide }) => (
<button onClick={nextSlide}>Next</button>
)}
>
{/* Carousel Content */}
</Carousel>
goToSlide
, nextSlide
and previousSlide
functions in addition to slideCount
and currentSlide
values.React.PropTypes.number
Manually set the index of the slide to be shown.
React.PropTypes.number
Slides to show at once.
slidesToScroll: React.PropTypes.oneOfType([
React.PropTypes.number,
React.PropTypes.oneOf(['auto'])
])
Slides to scroll at once. Set to "auto"
to always scroll the current number of visible slides.
React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number])
Manually set slideWidth. If you want hard pixel widths, use a string like slideWidth="20px"
, and if you prefer a percentage of the container, use a decimal integer like slideWidth={0.8}
React.PropTypes.number
Animation duration.
React.PropTypes.bool
Enable touch swipe/dragging
React.PropTypes.bool
Enable the slides to transition vertically.
React.PropTypes.string
Used to hardcode the slider width. Accepts any string dimension value such as "80%"
or "500px"
.
React.PropTypes.bool
Sets infinite wrapAround mode. Defaults to false
You can control the state of the carousel from your parent component as shown below:
import React from 'react';
import Carousel from 'nuka-carousel';
export default class extends React.Component {
state = {
slideIndex: 0
};
render() {
return (
<Carousel
slideIndex={this.state.slideIndex}
afterSlide={slideIndex => this.setState({ slideIndex })}
>
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide1" />
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide2" />
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide3" />
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide4" />
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide5" />
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide6" />
</Carousel>
);
}
}
See the Contribution Docs.
FAQs
Pure React Carousel
The npm package nuka-carousel receives a total of 18,840 weekly downloads. As such, nuka-carousel popularity was classified as popular.
We found that nuka-carousel demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 17 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.