0.5.0 • Published 7 years ago

react-canvas-knob v0.5.0

Weekly downloads
43
License
MIT
Repository
github
Last release
7 years ago

react-canvas-knob

jQuery Knob rebuilt with React (no jQuery). This is an HTML5 Canvas-based component that serves as a circular range input. Accepts mouse, touch, scrollwheel, and keyboard input.

Installation

npm install react-canvas-knob --save

Example usage

Please note that react-canvas-knob must be used as a controlled input.

import React from 'react';
import Knob from 'react-canvas-knob';

class MyComponent extends React.Component {
  state = {value: 50};

  handleChange = (newValue) => {
    this.setState({value: newValue});
  };

  render() {
    return (
      <Knob
        value={this.state.value}
        onChange={this.handleChange}
      />
    );
  }
}

Properties

namedescriptiondefault
valuenumeric value of knobn/a
onChangefunction to be called on user input with the current numerical valuen/a
onChangeEndfunction to be called on mouseUp or touchEnd with the current numerical valuen/a
minmin value0
maxmax value100
stepstep size1
logenable logarithmic scale (must use non-zero min and max, step > 1)false
width or heightdimension of square (px)200
thicknessgauge thickness0.35
lineCapgauge stroke ending style (butt or round)'butt'
bgColorbackground color'#EEE'
fgColorforeground color'#EA2'
inputColortext colorfgColor
fontfont family'Arial'
fontWeightfont weight'bold'
clockwisedirection of progressiontrue
cursoruse cursor display mode - give width value or true which uses the default cursor width (30)false
stopperstop at min & max on keydown/mousewheeltrue
readOnlydisable all user inputfalse
disableTextInputdisable manual text input onlyfalse
displayInputshow numeric input boxtrue
displayCustomfunction that will render your custom component in the centre. (Make sure to set displayInput as false, as that takes priority)n/a
angleArcarc size in degrees360
angleOffsetstarting angle in degrees0
disableMouseWheeldisable changes on mouse wheel usefalse
titleadds title attribute to the wheelvalue
classNamecustom className to be applied to the container elementnull
canvasClassNamecustom className to be applied to the canvas elementnull

Contributing

  • Make changes to Knob.js, then run npm run babel to transpile.

Todo

  • Fix for height > width condition
  • Port displayPrevious feature
  • Downwards compatibility
  • Implement some of the existing pull requests
  • Improve manual text input
0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago