mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-12 20:43:11 +08:00
parent
8c5c458304
commit
f13e40b887
@ -1,6 +1,6 @@
|
|||||||
import React, { createElement } from 'react';
|
import React, { createElement } from 'react';
|
||||||
|
import { findDOMNode } from 'react-dom';
|
||||||
import { isCssAnimationSupported } from 'css-animation';
|
import { isCssAnimationSupported } from 'css-animation';
|
||||||
const isBrowser = (typeof document !== 'undefined' && typeof window !== 'undefined');
|
|
||||||
|
|
||||||
function getNumberArray(num) {
|
function getNumberArray(num) {
|
||||||
return num ?
|
return num ?
|
||||||
@ -34,6 +34,12 @@ export default class ScrollNumber extends React.Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
if (!isCssAnimationSupported) {
|
||||||
|
findDOMNode(this).className += ' not-support-css-animation';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getPositionByNum(num, i) {
|
getPositionByNum(num, i) {
|
||||||
if (this.state.animateStarted) {
|
if (this.state.animateStarted) {
|
||||||
return 10 + num;
|
return 10 + num;
|
||||||
@ -77,10 +83,11 @@ export default class ScrollNumber extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderNumberList() {
|
renderNumberList(position) {
|
||||||
const childrenToReturn = [];
|
const childrenToReturn = [];
|
||||||
for (let i = 0; i < 30; i++) {
|
for (let i = 0; i < 30; i++) {
|
||||||
childrenToReturn.push(<p key={i}>{i % 10}</p>);
|
const currentClassName = (position === i) ? 'current' : null;
|
||||||
|
childrenToReturn.push(<p key={i} className={currentClassName}>{i % 10}</p>);
|
||||||
}
|
}
|
||||||
return childrenToReturn;
|
return childrenToReturn;
|
||||||
}
|
}
|
||||||
@ -99,7 +106,7 @@ export default class ScrollNumber extends React.Component {
|
|||||||
height,
|
height,
|
||||||
},
|
},
|
||||||
key: i,
|
key: i,
|
||||||
}, this.renderNumberList());
|
}, this.renderNumberList(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
renderNumberElement() {
|
renderNumberElement() {
|
||||||
@ -116,17 +123,10 @@ export default class ScrollNumber extends React.Component {
|
|||||||
...this.props,
|
...this.props,
|
||||||
className: `${this.props.prefixCls} ${this.props.className}`
|
className: `${this.props.prefixCls} ${this.props.className}`
|
||||||
};
|
};
|
||||||
if (isBrowser && isCssAnimationSupported) {
|
|
||||||
return createElement(
|
|
||||||
this.props.component,
|
|
||||||
props,
|
|
||||||
this.renderNumberElement()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return createElement(
|
return createElement(
|
||||||
this.props.component,
|
this.props.component,
|
||||||
props,
|
props,
|
||||||
props.count
|
this.renderNumberElement()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,5 @@
|
|||||||
````jsx
|
````jsx
|
||||||
import { Spin } from 'antd';
|
import { Spin } from 'antd';
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(<Spin />, mountNode);
|
||||||
<Spin />
|
|
||||||
, mountNode);
|
|
||||||
````
|
````
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { findDOMNode } from 'react-dom';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { isCssAnimationSupported } from 'css-animation';
|
import { isCssAnimationSupported } from 'css-animation';
|
||||||
const isBrowser = (typeof document !== 'undefined' && typeof window !== 'undefined');
|
|
||||||
|
|
||||||
export default class Spin extends React.Component {
|
export default class Spin extends React.Component {
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
@ -18,6 +18,13 @@ export default class Spin extends React.Component {
|
|||||||
return !!(this.props && this.props.children);
|
return !!(this.props && this.props.children);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
if (!isCssAnimationSupported) {
|
||||||
|
// Show text in IE8/9
|
||||||
|
findDOMNode(this).className += ` ${this.props.prefixCls}-show-text`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { className, size, prefixCls, tip } = this.props;
|
const { className, size, prefixCls, tip } = this.props;
|
||||||
|
|
||||||
@ -27,21 +34,17 @@ export default class Spin extends React.Component {
|
|||||||
[`${prefixCls}-lg`]: size === 'large',
|
[`${prefixCls}-lg`]: size === 'large',
|
||||||
[className]: !!className,
|
[className]: !!className,
|
||||||
[`${prefixCls}-spining`]: this.props.spining,
|
[`${prefixCls}-spining`]: this.props.spining,
|
||||||
|
[`${prefixCls}-show-text`]: !!this.props.tip,
|
||||||
});
|
});
|
||||||
|
|
||||||
let spinElement;
|
const spinElement = (
|
||||||
if (!isBrowser || !isCssAnimationSupported || 'tip' in this.props) {
|
<div className={spinClassName}>
|
||||||
// not support for animation, just use text instead
|
<span className={`${prefixCls}-dot ${prefixCls}-dot-first`} />
|
||||||
spinElement = <div className={spinClassName}>{tip || '加载中...'}</div>;
|
<span className={`${prefixCls}-dot ${prefixCls}-dot-second`} />
|
||||||
} else {
|
<span className={`${prefixCls}-dot ${prefixCls}-dot-third`} />
|
||||||
spinElement = (
|
<div className={`${prefixCls}-text`}>{tip || '加载中...'}</div>
|
||||||
<div className={spinClassName}>
|
</div>
|
||||||
<span className={`${prefixCls}-dot ${prefixCls}-dot-first`} />
|
);
|
||||||
<span className={`${prefixCls}-dot ${prefixCls}-dot-second`} />
|
|
||||||
<span className={`${prefixCls}-dot ${prefixCls}-dot-third`} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isNestedPattern()) {
|
if (this.isNestedPattern()) {
|
||||||
return (
|
return (
|
||||||
|
@ -79,6 +79,15 @@ a & {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
transition: transform .3s @ease-in-out;
|
transition: transform .3s @ease-in-out;
|
||||||
}
|
}
|
||||||
|
// for IE8/9 display
|
||||||
|
&.not-support-css-animation &-only {
|
||||||
|
> p {
|
||||||
|
display: none;
|
||||||
|
&.current {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes antZoomBadgeIn {
|
@keyframes antZoomBadgeIn {
|
||||||
|
@ -95,6 +95,15 @@
|
|||||||
margin-left: @spin-dot-size-lg;
|
margin-left: @spin-dot-size-lg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&-text,
|
||||||
|
&&-show-text &-dot {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&&-show-text &-text {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pulse
|
// pulse
|
||||||
|
Loading…
Reference in New Issue
Block a user