-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a new parameter for onStep & update api-docs (#701)
- Loading branch information
Showing
6 changed files
with
83 additions
and
17 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
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,46 @@ | ||
/* eslint no-console:0 */ | ||
import InputNumber from '@rc-component/input-number'; | ||
import React, { useState } from 'react'; | ||
import '../../assets/index.less'; | ||
|
||
export default () => { | ||
const [emitter, setEmitter] = useState('interface buttons (up)'); | ||
const [value, setValue] = React.useState<string | number>(0); | ||
|
||
const onChange = (val: number) => { | ||
console.warn('onChange:', val, typeof val); | ||
setValue(val); | ||
}; | ||
|
||
const onStep = (_: number, info: { offset: number; type: 'up' | 'down', emitter: 'handler' | 'keyboard' | 'wheel' }) => { | ||
if (info.emitter === 'handler') { | ||
setEmitter(`interface buttons (${info.type})`); | ||
} | ||
|
||
if (info.emitter === 'keyboard') { | ||
setEmitter(`keyboard (${info.type})`); | ||
} | ||
|
||
if (info.emitter === 'wheel') { | ||
setEmitter(`mouse wheel (${info.type})`); | ||
} | ||
}; | ||
|
||
return ( | ||
<div style={{ margin: 10 }}> | ||
<h3>onStep callback</h3> | ||
<InputNumber | ||
aria-label="onStep callback example" | ||
min={0} | ||
max={10} | ||
style={{ width: 100 }} | ||
value={value} | ||
changeOnWheel | ||
onChange={onChange} | ||
onStep={onStep} | ||
/> | ||
|
||
<div style={{ marginTop: 10 }}>Triggered by: {emitter}</div> | ||
</div> | ||
); | ||
}; |
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
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