Skip to content
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

[Spinner] add additional child element to isolate spinner from parent #2890

Merged
merged 2 commits into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/src/common/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export const START = `${NS}-start`;
export const END = `${NS}-end`;

export const SPINNER = `${NS}-spinner`;
export const SPINNER_ANIMATION = `${SPINNER}-animation`;
export const SPINNER_HEAD = `${SPINNER}-head`;
export const SPINNER_NO_SPIN = `${NS}-no-spin`;
export const SPINNER_TRACK = `${SPINNER}-track`;
Expand Down
13 changes: 11 additions & 2 deletions packages/core/src/components/spinner/_spinner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
}

.#{$ns}-spinner {
// center animation container inside parent element to isolate layout
display: flex;
align-items: center;
justify-content: center;

// allow paths to overflow container -- critical for edges of circles!
overflow: visible;
vertical-align: middle;
animation: pt-spinner-animation ($pt-transition-duration * 5) linear infinite;

svg {
display: block;
Expand All @@ -33,8 +37,13 @@
.#{$ns}-spinner-track {
stroke: $progress-track-color;
}
}

// put the animation on a child HTML element to isolate it from display of parent
.#{$ns}-spinner-animation {
animation: pt-spinner-animation ($pt-transition-duration * 5) linear infinite;

&.#{$ns}-no-spin {
.#{$ns}-no-spin > & {
animation: none;
}
}
Expand Down
22 changes: 12 additions & 10 deletions packages/core/src/components/spinner/spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,18 @@ export class Spinner extends AbstractPureComponent<ISpinnerProps, {}> {

return (
<TagName className={classes}>
<svg height={size} width={size} viewBox="0 0 100 100" strokeWidth={strokeWidth}>
<path className={Classes.SPINNER_TRACK} d={SPINNER_TRACK} />
<path
className={Classes.SPINNER_HEAD}
d={SPINNER_TRACK}
pathLength={PATH_LENGTH}
strokeDasharray={`${PATH_LENGTH} ${PATH_LENGTH}`}
strokeDashoffset={strokeOffset}
/>
</svg>
<span className={Classes.SPINNER_ANIMATION}>
giladgray marked this conversation as resolved.
Show resolved Hide resolved
<svg height={size} width={size} viewBox="0 0 100 100" strokeWidth={strokeWidth}>
<path className={Classes.SPINNER_TRACK} d={SPINNER_TRACK} />
<path
className={Classes.SPINNER_HEAD}