mirror of
https://github.com/wassname/slider.git
synced 2026-09-11 12:42:49 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19f1183634 | ||
|
|
200d0810ce | ||
|
|
e7007fbe8e | ||
|
|
8f490c80be | ||
|
|
a68a839515 | ||
|
|
e615ffb7b0 | ||
|
|
c643ae235e | ||
|
|
93c92f5f37 | ||
|
|
35ba80d884 | ||
|
|
c28f14272d | ||
|
|
b70a4e8c94 | ||
|
|
41f5ddb9bd | ||
|
|
38edc4db93 | ||
|
|
93ddaef0c3 | ||
|
|
dbc64888bc | ||
|
|
2112385ccc |
-29
@@ -1,29 +0,0 @@
|
|||||||
build/
|
|
||||||
*.cfg
|
|
||||||
nohup.out
|
|
||||||
*.iml
|
|
||||||
.idea/
|
|
||||||
.ipr
|
|
||||||
.iws
|
|
||||||
*~
|
|
||||||
~*
|
|
||||||
*.diff
|
|
||||||
*.log
|
|
||||||
*.patch
|
|
||||||
*.bak
|
|
||||||
.DS_Store
|
|
||||||
Thumbs.db
|
|
||||||
.project
|
|
||||||
.*proj
|
|
||||||
.svn/
|
|
||||||
*.swp
|
|
||||||
out/
|
|
||||||
.build
|
|
||||||
node_modules
|
|
||||||
.cache
|
|
||||||
examples
|
|
||||||
tests
|
|
||||||
src
|
|
||||||
/index.js
|
|
||||||
.*
|
|
||||||
assets/**/*.less
|
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
|
|
||||||
|
sudo: false
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email:
|
email:
|
||||||
- yiminghe@gmail.com
|
- yiminghe@gmail.com
|
||||||
@@ -34,3 +36,8 @@ env:
|
|||||||
global:
|
global:
|
||||||
- secure: S1VwbaPzLnSH/IUT/wlJulxAX5VHRIDmSt53h/ycHcZsszUpWcLCJRQAe0fTVB2dAx5MdBbSZ+o+tr3tRwVB5TRAYm0oTCsYAkOZaWOB28RuUQtdGt3wf9xxTG1UiPiaLLUW3waX9zAaf3yqKBcJGf1op0RD8dksxbCFw/7xVbU=
|
- secure: S1VwbaPzLnSH/IUT/wlJulxAX5VHRIDmSt53h/ycHcZsszUpWcLCJRQAe0fTVB2dAx5MdBbSZ+o+tr3tRwVB5TRAYm0oTCsYAkOZaWOB28RuUQtdGt3wf9xxTG1UiPiaLLUW3waX9zAaf3yqKBcJGf1op0RD8dksxbCFw/7xVbU=
|
||||||
- secure: EBEDg8k///IlEsnx0AE8X3mbFl0QE5+xGKbG4AxXlGZda12uTIPUSMKJzdZQ2hVbZXduTzf1cQl9rcu9nGoSnkL/DWnIax9cvHi+1orx5+YPlxPHNWAwWByTnHosBn2MJhfy1s5paJfHC9cUzmmEL6x4fYthWxjsPUo+irEZH6E=
|
- secure: EBEDg8k///IlEsnx0AE8X3mbFl0QE5+xGKbG4AxXlGZda12uTIPUSMKJzdZQ2hVbZXduTzf1cQl9rcu9nGoSnkL/DWnIax9cvHi+1orx5+YPlxPHNWAwWByTnHosBn2MJhfy1s5paJfHC9cUzmmEL6x4fYthWxjsPUo+irEZH6E=
|
||||||
|
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
allow_failures:
|
||||||
|
- env: "TEST_TYPE=saucelabs"
|
||||||
@@ -99,6 +99,12 @@ React.render(<Rcslider />, container);
|
|||||||
<td>number</td>
|
<td>number</td>
|
||||||
<td>0</td>
|
<td>0</td>
|
||||||
<td>Determines the initial positions of the handles.</td>
|
<td>Determines the initial positions of the handles.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>value</td>
|
||||||
|
<td>number</td>
|
||||||
|
<td></td>
|
||||||
|
<td>Determines the current positions of the handles.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>marks</td>
|
<td>marks</td>
|
||||||
@@ -118,12 +124,24 @@ React.render(<Rcslider />, container);
|
|||||||
<td>0</td>
|
<td>0</td>
|
||||||
<td>For step or marks slider, determine the initial positions of the handles.</td>
|
<td>For step or marks slider, determine the initial positions of the handles.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>index</td>
|
||||||
|
<td>number</td>
|
||||||
|
<td></td>
|
||||||
|
<td>For step or marks slider, determine current positions of the handles.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>disabled</td>
|
<td>disabled</td>
|
||||||
<td>boolean</td>
|
<td>boolean</td>
|
||||||
<td>false</td>
|
<td>false</td>
|
||||||
<td>If true the handles can't be moved.</td>
|
<td>If true the handles can't be moved.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>tipTransitionName</td>
|
||||||
|
<td>string</td>
|
||||||
|
<td>''</td>
|
||||||
|
<td>Set the animation for tooltip if it shows.</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@@ -136,17 +154,17 @@ npm start
|
|||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
http://localhost:8000/examples/
|
http://localhost:8005/examples/
|
||||||
|
|
||||||
online example: http://react-component.github.io/slider/examples/
|
online example: http://react-component.github.io/slider/
|
||||||
|
|
||||||
## Test Case
|
## Test Case
|
||||||
|
|
||||||
http://localhost:8000/tests/runner.html?coverage
|
http://localhost:8005/tests/runner.html?coverage
|
||||||
|
|
||||||
## Coverage
|
## Coverage
|
||||||
|
|
||||||
http://localhost:8000/node_modules/rc-server/node_modules/node-jscover/lib/front-end/jscoverage.html?w=http://localhost:8088/tests/runner.html?coverage
|
http://localhost:8005/node_modules/rc-server/node_modules/node-jscover/lib/front-end/jscoverage.html?w=http://localhost:8088/tests/runner.html?coverage
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
@tooltip-arrow-width: 4px;
|
@tooltip-arrow-width: 4px;
|
||||||
@tooltip-distance: @tooltip-arrow-width+4;
|
@tooltip-distance: @tooltip-arrow-width+4;
|
||||||
@tooltip-arrow-color: @tooltip-bg;
|
@tooltip-arrow-color: @tooltip-bg;
|
||||||
|
@ease-out-quint : cubic-bezier(0.23, 1, 0.32, 1);
|
||||||
|
@ease-in-quint : cubic-bezier(0.755, 0.05, 0.855, 0.06);
|
||||||
|
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@@ -175,3 +177,63 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.motion-common() {
|
||||||
|
animation-duration: .3s;
|
||||||
|
animation-fill-mode: both;
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.make-motion(@className, @keyframeName) {
|
||||||
|
.@{className}-enter, .@{className}-appear {
|
||||||
|
.motion-common();
|
||||||
|
animation-play-state: paused;
|
||||||
|
}
|
||||||
|
.@{className}-leave {
|
||||||
|
.motion-common();
|
||||||
|
animation-play-state: paused;
|
||||||
|
}
|
||||||
|
.@{className}-enter.@{className}-enter-active, .@{className}-appear.@{className}-appear-active {
|
||||||
|
animation-name: ~"@{keyframeName}In";
|
||||||
|
animation-play-state: running;
|
||||||
|
}
|
||||||
|
.@{className}-leave.@{className}-leave-active {
|
||||||
|
animation-name: ~"@{keyframeName}Out";
|
||||||
|
animation-play-state: running;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.zoom-motion(@className, @keyframeName) {
|
||||||
|
.make-motion(@className, @keyframeName);
|
||||||
|
.@{className}-enter, .@{className}-appear {
|
||||||
|
transform: scale(0, 0); // need this by yiminghe
|
||||||
|
animation-timing-function: @ease-out-quint;
|
||||||
|
}
|
||||||
|
.@{className}-leave {
|
||||||
|
animation-timing-function: @ease-in-quint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.zoom-motion(zoom-down, zoomDown);
|
||||||
|
|
||||||
|
@keyframes zoomDownIn {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
transform: scale(0, 0);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
transform: scale(1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes zoomDownOut {
|
||||||
|
0% {
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
transform: scale(1, 1);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 0;
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
transform: scale(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
require('rc-slider/assets/index.css');
|
require('rc-slider/assets/index.less');
|
||||||
|
|
||||||
var Slider = require('rc-slider');
|
var Slider = require('rc-slider');
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
@@ -9,6 +9,6 @@ function onChange(v){
|
|||||||
console.log(v);
|
console.log(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// React.render(<Slider marks={["一","二","三","四","五"]} index={3}/>, document.getElementById('__react-content'));
|
// React.render(<div style={{width:400,margin:100}}><Slider marks={["一","二","三","四","五"]} defaultIndex={2} /></div>, document.getElementById('__react-content'));
|
||||||
// React.render(<Slider className='rc-slider' step={20}/>, document.getElementById('__react-content'));
|
// React.render(<div style={{width:400,margin:100}}><Slider className='rc-slider' step={20}/></div>, document.getElementById('__react-content'));
|
||||||
React.render(<div style={{width:400,margin:100}}><Slider onChange={onChange}/></div>, document.getElementById('__react-content'));
|
React.render(<div style={{width:400,margin:100}}><Slider onChange={onChange} tipTransitionName='zoom-down'/></div>, document.getElementById('__react-content'));
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rc-slider",
|
"name": "rc-slider",
|
||||||
"version": "1.4.0",
|
"version": "1.4.5",
|
||||||
"description": "slider ui component for react",
|
"description": "slider ui component for react",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
"licenses": "MIT",
|
"licenses": "MIT",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"config": {
|
"config": {
|
||||||
"port": 8000
|
"port": 8005
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rc-tools run build",
|
"build": "rc-tools run build",
|
||||||
|
|||||||
+25
-15
@@ -33,7 +33,7 @@ function getValueFromIndex(props) {
|
|||||||
}
|
}
|
||||||
if (marksLen > 0) {
|
if (marksLen > 0) {
|
||||||
value = ((props.max - props.min) / (marksLen - 1)) * (index);
|
value = ((props.max - props.min) / (marksLen - 1)) * (index);
|
||||||
value = value.toFixed(5);
|
value = value.toFixed(5) / 1;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -56,6 +56,7 @@ const Slider = React.createClass({
|
|||||||
onBeforeChange: React.PropTypes.func,
|
onBeforeChange: React.PropTypes.func,
|
||||||
onChange: React.PropTypes.func,
|
onChange: React.PropTypes.func,
|
||||||
onAfterChange: React.PropTypes.func,
|
onAfterChange: React.PropTypes.func,
|
||||||
|
tipTransitionName: React.PropTypes.string,
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
@@ -70,6 +71,7 @@ const Slider = React.createClass({
|
|||||||
prefixCls: 'rc-slider',
|
prefixCls: 'rc-slider',
|
||||||
disabled: false,
|
disabled: false,
|
||||||
defaultIndex: 0,
|
defaultIndex: 0,
|
||||||
|
tipTransitionName: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -103,8 +105,14 @@ const Slider = React.createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onMouseUp() {
|
onMouseUp(e) {
|
||||||
this._end('mouse');
|
const m = e.target;
|
||||||
|
const handleDom = React.findDOMNode(this.refs.handle);
|
||||||
|
let showToolTip = false;
|
||||||
|
if (m === handleDom) {
|
||||||
|
showToolTip = true;
|
||||||
|
}
|
||||||
|
this._end('mouse', showToolTip);
|
||||||
},
|
},
|
||||||
|
|
||||||
onTouchUp() {
|
onTouchUp() {
|
||||||
@@ -112,7 +120,7 @@ const Slider = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onMouseMove(e) {
|
onMouseMove(e) {
|
||||||
const position = e.pageX;
|
const position = e.pageX || (e.clientX + document.documentElement.scrollLeft); // to compat ie8
|
||||||
this.onMove(e, position);
|
this.onMove(e, position);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -156,16 +164,16 @@ const Slider = React.createClass({
|
|||||||
const position = this._getTouchPosition(e);
|
const position = this._getTouchPosition(e);
|
||||||
const value = this._calValueByPos(position);
|
const value = this._calValueByPos(position);
|
||||||
this._triggerEvents('onChange', value);
|
this._triggerEvents('onChange', value);
|
||||||
this._start(position);
|
this._start(position, value);
|
||||||
this._addDocumentEvents('touch');
|
this._addDocumentEvents('touch');
|
||||||
pauseEvent(e);
|
pauseEvent(e);
|
||||||
},
|
},
|
||||||
|
|
||||||
onSliderMouseDown(e) {
|
onSliderMouseDown(e) {
|
||||||
const position = e.pageX;
|
const position = e.pageX || (e.clientX + document.documentElement.scrollLeft); // to compat ie8
|
||||||
const value = this._calValueByPos(position);
|
const value = this._calValueByPos(position);
|
||||||
this._triggerEvents('onChange', value);
|
this._triggerEvents('onChange', value);
|
||||||
this._start(position);
|
this._start(position, value);
|
||||||
this._addDocumentEvents('mouse');
|
this._addDocumentEvents('mouse');
|
||||||
pauseEvent(e);
|
pauseEvent(e);
|
||||||
},
|
},
|
||||||
@@ -299,6 +307,7 @@ const Slider = React.createClass({
|
|||||||
tooltipVisible = true;
|
tooltipVisible = true;
|
||||||
} else {
|
} else {
|
||||||
events = {
|
events = {
|
||||||
|
onClick: this.showTooltip.bind(this, true),
|
||||||
onMouseEnter: this.showTooltip.bind(this, true),
|
onMouseEnter: this.showTooltip.bind(this, true),
|
||||||
onMouseLeave: this.showTooltip.bind(this, false),
|
onMouseLeave: this.showTooltip.bind(this, false),
|
||||||
};
|
};
|
||||||
@@ -307,8 +316,8 @@ const Slider = React.createClass({
|
|||||||
|
|
||||||
const handle = (<div className={className}
|
const handle = (<div className={className}
|
||||||
{...events}
|
{...events}
|
||||||
ref="handle"
|
ref="handle"
|
||||||
style={onStyle}></div>);
|
style={onStyle}></div>);
|
||||||
|
|
||||||
if (this.props.marks.length > 0) {
|
if (this.props.marks.length > 0) {
|
||||||
return handle;
|
return handle;
|
||||||
@@ -319,6 +328,7 @@ const Slider = React.createClass({
|
|||||||
visible={tooltipVisible}
|
visible={tooltipVisible}
|
||||||
overlay={<span>{this.state.value}</span>}
|
overlay={<span>{this.state.value}</span>}
|
||||||
delay={0}
|
delay={0}
|
||||||
|
transitionName={this.props.tipTransitionName}
|
||||||
prefixCls={prefixClsFn(prefixCls, 'tooltip')}>
|
prefixCls={prefixClsFn(prefixCls, 'tooltip')}>
|
||||||
{handle}
|
{handle}
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@@ -357,8 +367,8 @@ const Slider = React.createClass({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={rcUtil.classSet(sliderClassName)} ref="slider"
|
<div className={rcUtil.classSet(sliderClassName)} ref="slider"
|
||||||
onTouchStart={disabled ? noop : this.onTouchStart}
|
onTouchStart={disabled ? noop : this.onTouchStart}
|
||||||
onMouseDown={disabled ? noop : this.onSliderMouseDown}>
|
onMouseDown={disabled ? noop : this.onSliderMouseDown}>
|
||||||
{track}
|
{track}
|
||||||
{ons}
|
{ons}
|
||||||
{steps}
|
{steps}
|
||||||
@@ -458,21 +468,21 @@ const Slider = React.createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_start(position) {
|
_start(position, value) {
|
||||||
this._triggerEvents('onBeforeChange');
|
this._triggerEvents('onBeforeChange');
|
||||||
this.startValue = this.state.value;
|
this.startValue = value;
|
||||||
this.startPosition = position;
|
this.startPosition = position;
|
||||||
this.setState({
|
this.setState({
|
||||||
dragging: true,
|
dragging: true,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_end(type) {
|
_end(type, showToolTip) {
|
||||||
this._removeEventons(type);
|
this._removeEventons(type);
|
||||||
this._triggerEvents('onAfterChange');
|
this._triggerEvents('onAfterChange');
|
||||||
this.setState({
|
this.setState({
|
||||||
dragging: false,
|
dragging: false,
|
||||||
showTooltip: false,
|
showTooltip: !!showToolTip,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user