-
Notifications
You must be signed in to change notification settings - Fork 19.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
showLoading align center #12414
Merged
showLoading align center #12414
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ecb4de9
showLoading align center #11790
yufeng04 b0c950b
adapt pr: showLoading align center
yufeng04 0f63426
update pr: change arc.shape.r to opts.spinnerRadius
yufeng04 84b1066
update pr: change 4*r to 2*r
yufeng04 d26cd1a
update pr: modify the __meta__.json
yufeng04 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
|
||
import * as zrUtil from 'zrender/src/core/util'; | ||
import * as graphic from '../util/graphic'; | ||
import * as textContain from 'zrender/src/contain/text'; | ||
|
||
var PI = Math.PI; | ||
|
||
|
@@ -34,69 +35,80 @@ export default function (api, opts) { | |
opts = opts || {}; | ||
zrUtil.defaults(opts, { | ||
text: 'loading', | ||
color: '#c23531', | ||
textColor: '#000', | ||
fontSize: '12px', | ||
maskColor: 'rgba(255, 255, 255, 0.8)', | ||
showSpinner: true, | ||
color: '#c23531', | ||
spinnerRadius: 10, | ||
lineWidth: 5, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
zlevel: 0 | ||
}); | ||
var group = new graphic.Group(); | ||
var mask = new graphic.Rect({ | ||
style: { | ||
fill: opts.maskColor | ||
}, | ||
zlevel: opts.zlevel, | ||
z: 10000 | ||
}); | ||
var arc = new graphic.Arc({ | ||
shape: { | ||
startAngle: -PI / 2, | ||
endAngle: -PI / 2 + 0.1, | ||
r: 10 | ||
}, | ||
style: { | ||
stroke: opts.color, | ||
lineCap: 'round', | ||
lineWidth: 5 | ||
}, | ||
zlevel: opts.zlevel, | ||
z: 10001 | ||
}); | ||
group.add(mask); | ||
var font = opts.fontSize + ' sans-serif'; | ||
var labelRect = new graphic.Rect({ | ||
style: { | ||
fill: 'none', | ||
text: opts.text, | ||
font: font, | ||
textPosition: 'right', | ||
textDistance: 10, | ||
textFill: opts.textColor | ||
}, | ||
zlevel: opts.zlevel, | ||
z: 10001 | ||
}); | ||
|
||
arc.animateShape(true) | ||
.when(1000, { | ||
endAngle: PI * 3 / 2 | ||
}) | ||
.start('circularInOut'); | ||
arc.animateShape(true) | ||
.when(1000, { | ||
startAngle: PI * 3 / 2 | ||
}) | ||
.delay(300) | ||
.start('circularInOut'); | ||
|
||
var group = new graphic.Group(); | ||
group.add(arc); | ||
group.add(labelRect); | ||
group.add(mask); | ||
if (opts.showSpinner) { | ||
var arc = new graphic.Arc({ | ||
shape: { | ||
startAngle: -PI / 2, | ||
endAngle: -PI / 2 + 0.1, | ||
r: opts.spinnerRadius | ||
}, | ||
style: { | ||
stroke: opts.color, | ||
lineCap: 'round', | ||
lineWidth: opts.lineWidth | ||
}, | ||
zlevel: opts.zlevel, | ||
z: 10001 | ||
}); | ||
arc.animateShape(true) | ||
.when(1000, { | ||
endAngle: PI * 3 / 2 | ||
}) | ||
.start('circularInOut'); | ||
arc.animateShape(true) | ||
.when(1000, { | ||
startAngle: PI * 3 / 2 | ||
}) | ||
.delay(300) | ||
.start('circularInOut'); | ||
group.add(arc); | ||
} | ||
// Inject resize | ||
group.resize = function () { | ||
var cx = api.getWidth() / 2; | ||
var textWidth = textContain.getWidth(opts.text, font); | ||
var r = opts.showSpinner ? opts.spinnerRadius : 0; | ||
// cx = (containerWidth - arcDiameter - textDistance - textWidth) / 2 | ||
// textDistance needs to be calculated when both animation and text exist | ||
var cx = (api.getWidth() - r * 2 - (opts.showSpinner && textWidth ? 10 : 0) - textWidth) / 2 | ||
// only show the text | ||
- (opts.showSpinner ? 0 : textWidth / 2); | ||
var cy = api.getHeight() / 2; | ||
arc.setShape({ | ||
opts.showSpinner && arc.setShape({ | ||
cx: cx, | ||
cy: cy | ||
}); | ||
var r = arc.shape.r; | ||
labelRect.setShape({ | ||
x: cx - r, | ||
y: cy - r, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the name is better to be
showSpinner
?