Skip to content

Instantly share code, notes, and snippets.

@gbuszmicz
Created April 16, 2019 02:19
Show Gist options
  • Save gbuszmicz/c3474dc5eeca64c9c00ff652a9049edd to your computer and use it in GitHub Desktop.
Save gbuszmicz/c3474dc5eeca64c9c00ff652a9049edd to your computer and use it in GitHub Desktop.
Pixi slider component for React
import React, { Component } from 'react'
import { Container, Text } from 'react-pixi-fiber'
import Slider from 'components/Slider'
class MyComponent extends Component {
constructor(props) {
super(props)
this.state = {
text: '5.0'
}
}
onChange = data => {
this.setState({
text: data.value
})
}
render() {
return (
<Container>
<Slider
width={400}
height={25}
x={400}
y={200}
currentPosition={5}
onChange={this.onChange}
steps={10}
/>
<Text
text={this.state.text}
x={400}
y={240}
style={{ fill: '#888888' }}
/>
</Container>
)
}
}
export default MyComponent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment