-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from nfqde/fix/make-thumb-positioning-relative
fix(ranges): Update thumb while animating container
- Loading branch information
Showing
7 changed files
with
138 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+1.98 KB
..._snapshots__/animation-test-ts-update-thumb-when-animating-container-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.99 KB
..._snapshots__/animation-test-ts-update-thumb-when-animating-container-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { | ||
Examples, | ||
getTestUrl, | ||
addFontStyles | ||
} from './utils'; | ||
|
||
jest.setTimeout(10000); | ||
|
||
beforeEach(async () => { | ||
await page.goto(getTestUrl(Examples.ANIMATING_CONTAINER)); | ||
await page.setViewport({ width: 600, height: 200 }); | ||
await addFontStyles(page); | ||
}); | ||
|
||
test('update thumb when animating container', async () => { | ||
expect(await page.screenshot()).toMatchImageSnapshot(); | ||
await new Promise(resolve => setTimeout(resolve, 2000)); | ||
expect(await page.screenshot()).toMatchImageSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import * as React from 'react'; | ||
import { Range, getTrackBackground } from '../src/index'; | ||
|
||
const STEP = 0.1; | ||
const MIN = 0; | ||
const MAX = 100; | ||
|
||
class AnimatingContainer extends React.Component { | ||
state = { | ||
values: [50], | ||
expanded: true, | ||
}; | ||
|
||
componentDidMount() { | ||
this.setState({expanded: false}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
flexWrap: 'wrap', | ||
width: this.state.expanded ? '100%' : '50%', | ||
transition: 'width 1s ease 0.5s', | ||
}} | ||
> | ||
<Range | ||
values={this.state.values} | ||
step={STEP} | ||
min={MIN} | ||
max={MAX} | ||
onChange={values => this.setState({ values })} | ||
renderTrack={({ props, children }) => ( | ||
<div | ||
onMouseDown={props.onMouseDown} | ||
onTouchStart={props.onTouchStart} | ||
style={{ | ||
...props.style, | ||
height: '36px', | ||
display: 'flex', | ||
width: '100%' | ||
}} | ||
> | ||
<div | ||
ref={props.ref} | ||
style={{ | ||
height: '5px', | ||
width: '100%', | ||
borderRadius: '4px', | ||
background: getTrackBackground({ | ||
values: this.state.values, | ||
colors: ['#548BF4', '#ccc'], | ||
min: MIN, | ||
max: MAX | ||
}), | ||
alignSelf: 'center' | ||
}} | ||
> | ||
{children} | ||
</div> | ||
</div> | ||
)} | ||
renderThumb={({ props, isDragged }) => ( | ||
<div | ||
{...props} | ||
style={{ | ||
...props.style, | ||
height: '42px', | ||
width: '42px', | ||
borderRadius: '4px', | ||
backgroundColor: '#FFF', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
boxShadow: '0px 2px 6px #AAA' | ||
}} | ||
> | ||
<div | ||
style={{ | ||
height: '16px', | ||
width: '5px', | ||
backgroundColor: isDragged ? '#548BF4' : '#CCC' | ||
}} | ||
/> | ||
</div> | ||
)} | ||
/> | ||
<output style={{ marginTop: '30px' }} id="output"> | ||
{this.state.values[0].toFixed(1)} | ||
</output> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default AnimatingContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters