1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _babelHelperVueJsxMergeProps = require('babel-helper-vue-jsx-merge-props');
var _babelHelperVueJsxMergeProps2 = _interopRequireDefault(_babelHelperVueJsxMergeProps);
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _vueTypes = require('../../_util/vue-types');
var _vueTypes2 = _interopRequireDefault(_vueTypes);
var _propsUtil = require('../../_util/props-util');
var _enhancer = require('./enhancer');
var _enhancer2 = _interopRequireDefault(_enhancer);
var _types = require('./types');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var circlePropTypes = (0, _extends3['default'])({}, _types.propTypes, {
gapPosition: _vueTypes2['default'].oneOf(['top', 'bottom', 'left', 'right']),
gapDegree: _vueTypes2['default'].number
});
var circleDefaultProps = (0, _extends3['default'])({}, _types.defaultProps, {
gapPosition: 'top'
});
var Circle = {
props: (0, _propsUtil.initDefaultProps)(circlePropTypes, circleDefaultProps),
methods: {
getPathStyles: function getPathStyles() {
var _$props = this.$props,
percent = _$props.percent,
strokeWidth = _$props.strokeWidth,
strokeColor = _$props.strokeColor,
_$props$gapDegree = _$props.gapDegree,
gapDegree = _$props$gapDegree === undefined ? 0 : _$props$gapDegree,
gapPosition = _$props.gapPosition;
var radius = 50 - strokeWidth / 2;
var beginPositionX = 0;
var beginPositionY = -radius;
var endPositionX = 0;
var endPositionY = -2 * radius;
switch (gapPosition) {
case 'left':
beginPositionX = -radius;
beginPositionY = 0;
endPositionX = 2 * radius;
endPositionY = 0;
break;
case 'right':
beginPositionX = radius;
beginPositionY = 0;
endPositionX = -2 * radius;
endPositionY = 0;
break;
case 'bottom':
beginPositionY = radius;
endPositionY = 2 * radius;
break;
default:
}
var pathString = 'M 50,50 m ' + beginPositionX + ',' + beginPositionY + '\n a ' + radius + ',' + radius + ' 0 1 1 ' + endPositionX + ',' + -endPositionY + '\n a ' + radius + ',' + radius + ' 0 1 1 ' + -endPositionX + ',' + endPositionY;
var len = Math.PI * 2 * radius;
var trailPathStyle = {
strokeDasharray: len - gapDegree + 'px ' + len + 'px',
strokeDashoffset: '-' + gapDegree / 2 + 'px',
transition: 'stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s'
};
var strokePathStyle = {
stroke: strokeColor,
strokeDasharray: percent / 100 * (len - gapDegree) + 'px ' + len + 'px',
strokeDashoffset: '-' + gapDegree / 2 + 'px',
transition: 'stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s' // eslint-disable-line
};
return { pathString: pathString, trailPathStyle: trailPathStyle, strokePathStyle: strokePathStyle };
}
},
render: function render() {
var h = arguments[0];
var _$props2 = this.$props,
prefixCls = _$props2.prefixCls,
strokeWidth = _$props2.strokeWidth,
trailWidth = _$props2.trailWidth,
trailColor = _$props2.trailColor,
strokeLinecap = _$props2.strokeLinecap,
percent = _$props2.percent,
restProps = (0, _objectWithoutProperties3['default'])(_$props2, ['prefixCls', 'strokeWidth', 'trailWidth', 'trailColor', 'strokeLinecap', 'percent']);
var _getPathStyles = this.getPathStyles(),
pathString = _getPathStyles.pathString,
trailPathStyle = _getPathStyles.trailPathStyle,
strokePathStyle = _getPathStyles.strokePathStyle;
delete restProps.percent;
delete restProps.gapDegree;
delete restProps.gapPosition;
delete restProps.strokeColor;
var pathFirst = {
attrs: {
d: pathString,
stroke: trailColor,
'stroke-linecap': strokeLinecap,
'stroke-width': trailWidth || strokeWidth,
'fill-opacity': '0'
},
'class': prefixCls + '-circle-trail',
style: trailPathStyle
};
var pathSecond = {
attrs: {
d: pathString,
'stroke-linecap': strokeLinecap,
'stroke-width': percent === 0 ? 0 : strokeWidth,
'fill-opacity': '0'
},
'class': prefixCls + '-circle-path',
style: strokePathStyle,
ref: 'svgPathRef'
};
return h(
'svg',
(0, _babelHelperVueJsxMergeProps2['default'])([{ 'class': prefixCls + '-circle', attrs: { viewBox: '0 0 100 100' }
}, restProps]),
[h('path', pathFirst), h('path', pathSecond)]
);
}
};
exports['default'] = (0, _enhancer2['default'])(Circle);