1.1.4 • Published 1 year ago

react-input-number-editor-more v1.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-input-number-editor-more

React component that act like adobe suite editor number input field that can be slided.

Gitlab pipeline status (branch) coverage report npm

Demo

Preview Image

Live demo available here

示例代码

Features

  • Mouse lock on drag
  • Custom number decimal precision
  • Manual editing of the input
  • Editing cancellation
  • Increment/decrement the value with arrow up and arrow down key
  • Use ctrl and shift key to increment/decrement the value with higher/lesser step
  • Change the value from external event
  • Customize the step modifier for ctrl and shift key
  • Customize the slide modifier for dragging accuracy

Install

npm install --save react-input-number-editor-more

Or

yarn add react-input-number-editor-more

Example

import React, { useState } from 'react';

import InputNumberEditor from 'react-input-number-editor-more';

function Example() {
    const [value, setValue] = useState(0);

    function handleChange(value) {
        setValue(value);
    }

    return (
        <InputNumberEditor
            value={value}
            min={0}
            max={100}
            precision={1}
            onChange={handleChange}
        />
    );
}

Usage

PropDescriptionTypeDefaultRequired
valueThe value to set the input tonumber0Yes
minThe minimum value reachablenumber-No
maxThe maximum value reachablenumber-No
precisionNumber of decimalsnumber0No
stepNumber of the steppingnumber1No
stepModifierModifier for the stepping (Ctrl and Shift key)number10No
slideModifierModifier for the sliding/dragging modestring0.3No
onChangeCallback called on value change。参数为一个对象{newInternalValue,event,moveNumbers:{movementX,movementY}}。newInternalValue:拖拽得到的最新值。movementX:鼠标在x轴每一次移动的距离;movementY:鼠标在y轴每一次移动的距离。func() => ()No
mouseSpeed调整鼠标速度number1No
showInput是否显示input框,只有在当前组件有子组件的情况下生效(有时我们并不需要input元素)BooleantrueNo
doubleSpeed当鼠标在y方向翻页时自动调节数字改变速度number1No
onMouseUp鼠标事件,返回参数eventfunctionNo
onMouseDown鼠标事件,返回参数eventfunctionNo
onMouseMove鼠标事件,返回参数是一个对象{ moveNumbers: { movementX: movementX mouseSpeed, movementY: movementY mouseSpeed, }, event }functionNo

对原项目的修改如下:

添加了mouseSpeed、showInput、doubleSpeed属性,以提供更多的可选项。

添加onMouseUp、onMouseDown、onMouseMove事件,以及改变onChange事件返回的参数。

给此组件添子组件时,子组件将作为鼠标操作对象,同样可以操作数字demo

添加的demo:

License

MIT © Vinarnt

1.1.4

1 year ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago