diff --git a/assets/index.less b/assets/index.less
index e799ee1..017301a 100644
--- a/assets/index.less
+++ b/assets/index.less
@@ -8,6 +8,8 @@
@tooltip-arrow-width: 4px;
@tooltip-distance: @tooltip-arrow-width+4;
@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;
@@ -174,4 +176,64 @@
border-top-color: @tooltip-arrow-color;
}
}
+}
+
+.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);
+ }
}
\ No newline at end of file
diff --git a/examples/simple.js b/examples/simple.js
index 549d886..4b86143 100644
--- a/examples/simple.js
+++ b/examples/simple.js
@@ -11,4 +11,4 @@ function onChange(v){
// React.render(
, document.getElementById('__react-content'));
// React.render(
, document.getElementById('__react-content'));
-React.render(
, document.getElementById('__react-content'));
+React.render(
, document.getElementById('__react-content'));
diff --git a/package.json b/package.json
index 9535d52..49f34e1 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "rc-slider",
- "version": "1.4.3",
+ "version": "1.4.4",
"description": "slider ui component for react",
"keywords": [
"react",
@@ -24,7 +24,7 @@
"licenses": "MIT",
"main": "./lib/index.js",
"config": {
- "port": 8000
+ "port": 8005
},
"scripts": {
"build": "rc-tools run build",
diff --git a/src/Slider.jsx b/src/Slider.jsx
index 0ca21dd..677bfea 100644
--- a/src/Slider.jsx
+++ b/src/Slider.jsx
@@ -56,6 +56,7 @@ const Slider = React.createClass({
onBeforeChange: React.PropTypes.func,
onChange: React.PropTypes.func,
onAfterChange: React.PropTypes.func,
+ tipTransitionName: React.PropTypes.string,
},
getDefaultProps() {
@@ -70,6 +71,7 @@ const Slider = React.createClass({
prefixCls: 'rc-slider',
disabled: false,
defaultIndex: 0,
+ tipTransitionName: '',
};
},
@@ -103,8 +105,14 @@ const Slider = React.createClass({
}
},
- onMouseUp() {
- this._end('mouse');
+ onMouseUp(e) {
+ const m = e.target;
+ const handleDom = React.findDOMNode(this.refs.handle);
+ let showToolTip = false;
+ if (m === handleDom) {
+ showToolTip = true;
+ }
+ this._end('mouse', showToolTip);
},
onTouchUp() {
@@ -308,8 +316,8 @@ const Slider = React.createClass({
const handle = ();
+ ref="handle"
+ style={onStyle}>);
if (this.props.marks.length > 0) {
return handle;
@@ -320,6 +328,7 @@ const Slider = React.createClass({
visible={tooltipVisible}
overlay={{this.state.value}}
delay={0}
+ transitionName={this.props.tipTransitionName}
prefixCls={prefixClsFn(prefixCls, 'tooltip')}>
{handle}
@@ -358,8 +367,8 @@ const Slider = React.createClass({
return (
+ onTouchStart={disabled ? noop : this.onTouchStart}
+ onMouseDown={disabled ? noop : this.onSliderMouseDown}>
{track}
{ons}
{steps}
@@ -468,12 +477,12 @@ const Slider = React.createClass({
});
},
- _end(type) {
+ _end(type, showToolTip) {
this._removeEventons(type);
this._triggerEvents('onAfterChange');
this.setState({
dragging: false,
- showTooltip: false,
+ showTooltip: !!showToolTip,
});
},
});