Skip to content

Commit 1860d67

Browse files
gribnoysupmcasimir
authored andcommitted
chore(compass-components): remove shadow flicker (#3705)
1 parent 9c8c374 commit 1860d67

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

package-lock.json

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"hadron-document": "^8.0.1",
7676
"hadron-type-checker": "^7.0.0",
7777
"polished": "^4.2.2",
78-
"react-intersection-observer": "^8.25.1",
78+
"react-intersection-observer": "^8.34.0",
7979
"react-sortable-hoc": "^2.0.0",
8080
"react-window": "^1.8.6"
8181
},

packages/compass-components/src/components/workspace-container.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useRef } from 'react';
2-
import { css, cx } from '@leafygreen-ui/emotion';
2+
import { css, cx, keyframes } from '@leafygreen-ui/emotion';
33
import { palette } from '@leafygreen-ui/palette';
44
import { withTheme } from '../hooks/use-theme';
55
import { spacing } from '@leafygreen-ui/tokens';
@@ -28,6 +28,15 @@ const scrollBoxStyles = css({
2828

2929
const shadowHeight = spacing[4];
3030

31+
const fadeIn = keyframes({
32+
from: {
33+
opacity: 0,
34+
},
35+
to: {
36+
opacity: 1,
37+
},
38+
});
39+
3140
const shadowContainerStyles = css({
3241
overflow: 'hidden',
3342
position: 'absolute',
@@ -38,6 +47,11 @@ const shadowContainerStyles = css({
3847
flex: 'none',
3948
zIndex: 1,
4049
pointerEvents: 'none',
50+
// Animation prevents possible flicker when in-view trigger that is
51+
// responsible for showing the shadow very quickly switches between being
52+
// hidden to being visible again (that is the case where we don't unmount
53+
// collection tabs and just use display: none to hide them)
54+
animation: `${fadeIn} .1s linear`,
4155
});
4256

4357
const boxShadow = (color: string) => `0px 2px ${shadowHeight}px -1px ${color}`;
@@ -100,6 +114,10 @@ function UnthemedWorkspaceContainer({
100114

101115
const [scrollDetectionTrigger, triggerStillInView] = useInView({
102116
root: scrollContainer.current,
117+
// Prevents flicker on initial mount: when this component mounts we know for
118+
// sure that trigger in view as the trigger is at the very top of the
119+
// container
120+
initialInView: true,
103121
});
104122

105123
return (

0 commit comments

Comments
 (0)