Skip to content

Commit 9322da0

Browse files
authored
Merge pull request #121 from dvtng/fix-120
Fix circle in Safari and enableAnimation regression
2 parents 09c7ff9 + 66645f6 commit 9322da0

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

.husky/pre-commit

100644100755
File mode changed.

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
## UNRELEASED
1+
## 3.0.1
22

33
### Bug Fixes
44

5-
- Fix `SkeletonProps` not being exported from the main entry point
5+
- Fix circle skeleton animation being broken in Safari (#120)
6+
- Fix `SkeletonProps` not being exported from the main entry point (#118)
7+
- Fix `enableAnimation` prop having no effect. This was a regression.
68

79
## 3.0.0
810

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-loading-skeleton",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"keywords": [
55
"react",
66
"loading",

src/Skeleton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function styleOptionsToCssProperties({
2323

2424
if (direction === 'rtl') style['--animation-direction'] = 'reverse'
2525
if (typeof duration === 'number') style['--animation-duration'] = `${duration}s`
26-
if (!enableAnimation) style.backgroundImage = 'none'
26+
if (!enableAnimation) style['--pseudo-element-display'] = 'none'
2727

2828
if (typeof width === 'string' || typeof width === 'number') style.width = width
2929
if (typeof height === 'string' || typeof height === 'number') style.height = height

src/__tests__/Skeleton.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ it('adds a line break when inline is false', () => {
7878

7979
it('disables the animation if and only if enableAnimation is false', () => {
8080
const { rerender } = render(<Skeleton containerTestId="container" />)
81-
expect(getSkeleton()).toHaveStyle({ backgroundImage: /linear-gradient/ })
81+
expect(getSkeleton().style.getPropertyValue('--pseudo-element-display')).toBe('')
8282
expect(screen.getByTestId('container')).toHaveAttribute('aria-busy', 'true')
8383

8484
rerender(<Skeleton enableAnimation containerTestId="container" />)
85-
expect(getSkeleton()).toHaveStyle({ backgroundImage: /linear-gradient/ })
85+
expect(getSkeleton().style.getPropertyValue('--pseudo-element-display')).toBe('')
8686
expect(screen.getByTestId('container')).toHaveAttribute('aria-busy', 'true')
8787

8888
rerender(<Skeleton enableAnimation={false} containerTestId="container" />)
89-
expect(getSkeleton()).toHaveStyle({ backgroundImage: 'none' })
89+
expect(getSkeleton().style.getPropertyValue('--pseudo-element-display')).toBe('none')
9090
expect(screen.getByTestId('container')).toHaveAttribute('aria-busy', 'false')
9191
})
9292

src/skeleton.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
--highlight-color: #f5f5f5;
1010
--animation-duration: 1.5s;
1111
--animation-direction: normal;
12+
--pseudo-element-display: block; /* Enable animation */
1213

1314
background-color: var(--base-color);
1415

@@ -19,11 +20,12 @@
1920

2021
position: relative;
2122
overflow: hidden;
23+
z-index: 1; /* Necessary for overflow: hidden to work correctly in Safari */
2224
}
2325

2426
.react-loading-skeleton::after {
2527
content: ' ';
26-
display: block;
28+
display: var(--pseudo-element-display);
2729
position: absolute;
2830
left: 0;
2931
right: 0;

0 commit comments

Comments
 (0)