-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix safari spinner bug (#3834)
* chore: fix safari spinner bug * chore: refactor safari check * fix: spinner animation bug --------- Co-authored-by: TheSisb <[email protected]>
- Loading branch information
Showing
4 changed files
with
56 additions
and
14 deletions.
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@twilio-paste/spinner": patch | ||
"@twilio-paste/core": patch | ||
--- | ||
|
||
[Spinner] Fix a bug that previously occured when a Safari user zoomed in on a page with a Spinner. The animated track moving around the Spinner circle would lose its center and appear off of the circle. This was due to the fact that Safari does not accept "center" as a value for the `transformOrigin` property. The fix was to remove the extra animations for Safari windows only. |
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
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
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 |
---|---|---|
@@ -1,23 +1,32 @@ | ||
import { styled } from "@twilio-paste/styling-library"; | ||
|
||
import { circleCircumference } from "./constants"; | ||
import { CircleKeyframes, SvgKeyframes } from "./keyframes"; | ||
import { CircleKeyframes, SafariSvgKeyframes, SvgKeyframes } from "./keyframes"; | ||
|
||
export const StyledCircleTrack = styled.circle({ | ||
transformOrigin: "center", | ||
opacity: 0.25, | ||
}); | ||
|
||
export const AnimatedStyledCircle = styled.circle<{ show: boolean }>(({ show }) => ({ | ||
transformOrigin: "center", | ||
animation: `1.5s ease-in-out infinite both ${CircleKeyframes}`, | ||
strokeDasharray: circleCircumference, | ||
opacity: show ? 1 : 0, | ||
})); | ||
/* | ||
* AnimatedStyledCircle and StyledSvg use different animations for Safari because | ||
* Safari does not respect the `transformOrigin: "center"` and causes bugs | ||
*/ | ||
|
||
export const AnimatedStyledCircle = styled.circle<{ show: boolean; isSafari: boolean }>(({ show, isSafari }) => { | ||
return { | ||
transformOrigin: "center", | ||
animation: isSafari ? "none" : `1.5s ease-in-out infinite both ${CircleKeyframes}`, | ||
strokeDasharray: circleCircumference, | ||
opacity: show ? 1 : 0, | ||
}; | ||
}); | ||
|
||
export const StyledSvg = styled.svg({ | ||
height: "100%", | ||
width: "100%", | ||
display: "block", | ||
animation: `4.25s linear infinite both ${SvgKeyframes}`, | ||
export const StyledSvg = styled.svg<{ isSafari: boolean }>(({ isSafari }) => { | ||
return { | ||
height: "100%", | ||
width: "100%", | ||
display: "block", | ||
animation: isSafari ? `1s infinite linear ${SafariSvgKeyframes}` : `4.25s linear infinite both ${SvgKeyframes}`, | ||
}; | ||
}); |