Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
tbg-react-slider
Advanced tools
Pure JS React image slider component with no CSS dependencies
The simplest way to use TBG-React-Slider is to grab it from NPM and include it in your build process.
npm install tbg-react-slider --save
TBG-React-Slider is packaged as an es6 module, so to import it use
import Slider from 'tbg-react-slider'
or to use it as a CommonJS module:
const TBGReactSlider = require('tbg-react-slider').default
To use TBG-React-Slider at its most basic form
import React from 'react';
import ReactDOM from 'react-dom';
import Slider from 'tbg-react-slider';
ReactDOM.render(
<Slider>
<div> Slide 1 </div>
<div> Slide 2 </div>
<div> Slide 3 </div>
<div> Slide 4 </div>
</Slider>
,
document.getElementById('carousel')
);
className: 'slider'
arrows: true
dots: true
delay: 5000
autoplay: true
initialSlide: 0
direction: 'right'
transitionTime: 0.5
transition: Fade
onChange: () => { }
onShow: () => { }
dot: <span>•</span>
arrow: {
left: <span>‹</span>,
right: <span>›</span>,
}
TBG-React-Slider doesn't depend on any external styles for functionality. However, it can be styled for UI and follows BEM principles.
The default Block class is .slider
and can be changed via passing a className
string as a component prop.
Available styles based on the default Block .slider
class:
.slider {}
.slider__wrapper {}
.slider__view {}
.slider__dots {}
.slider__dot {}
.slider__dot.is-active {}
.slider__arrow__wrapper {}
.slider__arrow__wrapper--right {}
.slider__arrow__wrapper--left {}
.slider__arrow {}
.slider__arrow--right {}
.slider__arrow--left {}
TBG-React-Slider has some exposed component functions which can be used to navigate slides - start()
, stop()
, next()
, prev()
& goto(index)
To access these, add a ref
to the component <Slider ref="slider" ...
and they can then be referenced via this.refs.slider.next()
Example using react-hammerjs
import Slider, { Transitions } from 'tbg-react-slider';
import Hammer from 'react-hammerjs';
class HammerJSExample extends React.Component {
handleSwipe(e) {
const dir = e.direction;
if (dir === 2) { this.refs.slider.nextSlide(); }
if (dir === 4) { this.refs.slider.previousSlide(); }
}
...
render() {
return (
<Hammer onSwipe={ this.handleSwipe.bind(this) }>
<Slider ref="slider" transition={ Transitions.Slide } >
...
</Slider>
</Hammer>
);
}
}
TBG-React-Slider comes with a couple of pre-packed transitions which can be imported and passed as props to the slider component.
By default the Fade
transition is used.
import Slider, { Transitions } from 'tbg-react-slider';
<Slider transition={ Transitions.Slide } >
...
</Slider>
Packed transitions include: Fade
, Slide
, SlideDown
To create a custom transition you can create
method in Transitions
import Slider, { Transitions } from 'tbg-react-slider';
const Spin = Transitions.create({
start(dir, view) {
return {
transform: `
translate(${view.width * dir}px, ${view.height * dir}px)
rotateZ(360deg)
`,
};
},
end() {
return {
transform: 'translateX(0) rotateZ(0)',
};
},
transition(time) {
return {
transition: `transform ${time}s`,
};
},
});
<Slider transition={ Spin } >
...
</Slider>
FAQs
React slider component
The npm package tbg-react-slider receives a total of 2 weekly downloads. As such, tbg-react-slider popularity was classified as not popular.
We found that tbg-react-slider demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.