Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-range-slider

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-range-slider - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

126

index.js

@@ -21,45 +21,2 @@ var React = require('react/addons');

/**
* Reduce `v` with `f` and `init` or call `f` directly with `init` and `v` if it is a single value.
*/
function reduce(v, f, init) {
return (v && v.reduce) ? v.reduce(f, init) : f(init, v, 0);
}
/**
* Returns the size of `v` if it is an array, or 1 if it is a single value or 0 if it does not exists.
*/
function size(v) {
return v != null ? v.length ? v.length : 1 : 0;
}
/**
* Returns the value at `i` if `v` is an array. Just returns the value otherwise.
*/
function at(v, i) {
return v && v.map ? v[i] : v;
}
/**
* Compares `a` and `b` which can be either single values or an array of values.
*/
function is(a, b) {
return size(a) === size(b) &&
reduce(a, function (res, v, i) {
return res && v === at(b, i)
}, true);
}
/**
* Spreads `count` values equally between `min` and `max`.
*/
function linspace(min, max, count) {
var range = (max - min) / (count - 1);
var res = [];
for (var i = 0; i < count; i++) {
res.push(range * i);
}
return res;
}
/**
* Fomat [1, 2] or ['#FFF', '#FAD']

@@ -153,7 +110,30 @@ * To [{value:1, color: null}] or [{value: '20%', color: '#FFF'}]

orientation: PropTypes.oneOf(['horizontal', 'vertical']),
/**
* Options is slider show the bars or not, default false.
*/
withBars: PropTypes.bool,
/**
* Options is slider show the cursors or not, default false.
*/
withCursor: PropTypes.bool,
pearling: PropTypes.bool,
/**
* Options disable slider, default false.
* If set diabled with true cursors in the slider will unable to drag.
*/
disabled: PropTypes.bool,
/**
*
* Range for slider, menas you can set header or tailer cursor or both, something like blow:
* -|-----------|-
* Example:
*
* ```
* <RangeSlider range />
* or
* <RangeSlider range={[true, false]} />
* or
* <RangeSlider range={[10, 90]} />
*
* ```
*/
range: PropTypes.oneOfType([

@@ -164,10 +144,52 @@ PropTypes.bool,

]),
/**
* Disable slider header cursor.
*
* Example:
* ```
* <RangeSlider range={[10]} disabledHeader/>
* ```
*/
disabledHeader: PropTypes.bool,
/**
* Disable slider tailer cursor.
*
* Example:
* ```
* <RangeSlider range={[null, 90]} disabledTailer/>
* ```
*/
disabledTailer: PropTypes.bool,
/**
* Hook event for when mouse down for each cursor.
*
* Example:
* ```
* <RangeSlider onMouseDown={somefunction} />
* ```
*/
onMouseDown: PropTypes.func,
/**
* Hook function before cursor dragging.
*/
onBeforeChange: PropTypes.func,
/**
* Hook function when cursor dragging.
*/
onChange: PropTypes.func,
/**
* Hook function after cursor dragging.
*/
onAfterChange: PropTypes.func,
// Bar click event
/**
* Click event for each bar.
*
* Example:
* ```
* <RangeSlider onBarClick={somefunction(evt[, index, color])} />
* ```
* @param {Object} Event click event instance.
* @param {Number} Index Index of the clicked bar.
* @param {String} Color Clicked bar's background color.
*/
onBarClick: PropTypes.func

@@ -213,4 +235,4 @@ },

index: -1, // TODO: find better solution
clicked: -1,
upperBound: 0,
sliderLength: 0,
axis: this.isHorizontal() ? 'X' : 'Y',

@@ -267,4 +289,3 @@ minProp: this.isHorizontal() ? 'left' : 'top',

this.setState({
upperBound: slider[size] - (handle[size] || 0),
sliderLength: sliderMax - sliderMin
upperBound: slider[size] - (handle[size] || 0)
});

@@ -354,2 +375,5 @@ },

handleBarClick: function (i, e) {
this.setState({
clicked: i
});
this.props.onBarClick(e, i, this.state.value[i]);

@@ -417,3 +441,3 @@ },

ref: 'bar' + i,
className: 'bar bar-' + i,
className: 'bar bar-' + i + (this.state.clicked === i ? ' active' : ''),
style: style,

@@ -420,0 +444,0 @@ onClick: this.handleBarClick.bind(this, i)

{
"name": "react-range-slider",
"version": "0.0.5",
"version": "0.0.6",
"description": "A flexible slider for reactjs.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc