Skip to content

Commit 4a8f657

Browse files
committed
[Android] Temporarily disable animations for performance reasons
#126 pmndrs/react-spring#570
1 parent 0fb76c8 commit 4a8f657

File tree

10 files changed

+32
-8
lines changed

10 files changed

+32
-8
lines changed

packages/components/src/components/buttons/GitHubLoginButton.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,12 @@ export function GitHubLoginButton(props: GitHubLoginButtonProps) {
114114

115115
function getStyles() {
116116
const { isHovered, isPressing, theme } = cacheRef.current
117+
118+
const immediate = Platform.realOS === 'android'
119+
117120
return {
118-
config: { duration: 100 },
121+
config: { duration: immediate ? 0 : 100 },
122+
immediate,
119123
backgroundColor:
120124
isHovered || isPressing
121125
? theme.backgroundColorLess2

packages/components/src/components/columns/ColumnHeaderItem.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useSpring } from 'react-spring/native'
66
import { GitHubIcon, ThemeColors } from '@devhub/core'
77
import { useHover } from '../../hooks/use-hover'
88
import { useReduxState } from '../../hooks/use-redux-state'
9+
import { Platform } from '../../libs/platform'
910
import * as selectors from '../../redux/selectors'
1011
import {
1112
columnHeaderItemContentSize,
@@ -109,10 +110,13 @@ export const ColumnHeaderItem = React.memo((props: ColumnHeaderItemProps) => {
109110
const { isHovered: _isHovered, theme } = cacheRef.current
110111

111112
const isHovered = (_isHovered || forceHoverState) && !disabled
112-
const immediate = !!(enableForegroundHover && !enableBackgroundHover)
113+
const immediate =
114+
Platform.realOS === 'android' ||
115+
!!(enableForegroundHover && !enableBackgroundHover)
113116

114117
return {
115118
config: { duration: immediate ? 0 : 100 },
119+
immediate,
116120
backgroundColor:
117121
isHovered && enableBackgroundHover
118122
? theme[hoverBackgroundThemeColor || 'backgroundColorLess1']

packages/components/src/components/columns/ColumnOptionsRenderer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@ export const ColumnOptionsRenderer = React.memo(
2828
const springAnimatedTheme = useCSSVariablesOrSpringAnimatedTheme()
2929
const { sizename } = useAppLayout()
3030

31+
const immediate = Platform.realOS === 'android'
32+
3133
const overlayTransition = useTransition<boolean, any>(
3234
visible ? [true] : [],
3335
() => 'column-options-overlay',
3436
{
3537
reset: true,
3638
unique: true,
37-
config: { duration: 400, precision: 0.01 },
39+
config: { duration: immediate ? 0 : 400, precision: 0.01 },
40+
immediate,
3841
from: { opacity: 0 },
3942
enter: { opacity: 0.75 },
4043
leave: { opacity: 0 },

packages/components/src/components/columns/ColumnOptionsRow.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ export function ColumnOptionsRow(props: ColumnOptionsRowProps) {
8686

8787
function getStyles() {
8888
const { isHovered, isPressing, theme } = cacheRef.current
89+
const immediate = Platform.realOS === 'android'
8990

9091
return {
91-
config: { duration: 100 },
92+
config: { duration: immediate ? 0 : 100 },
93+
immediate,
9294
backgroundColor:
9395
isHovered || isPressing || isOpen
9496
? theme[getColumnHeaderThemeColors(theme.backgroundColor).hover]

packages/components/src/components/columns/Columns.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Omit } from '@devhub/core'
1111
import { ColumnContainer } from '../../containers/ColumnContainer'
1212
import { useEmitter } from '../../hooks/use-emitter'
1313
import { bugsnag } from '../../libs/bugsnag'
14+
import { Platform } from '../../libs/platform'
1415
import { separatorTickSize } from '../common/Separator'
1516
import { useColumnWidth } from '../context/ColumnWidthContext'
1617
import { useAppLayout } from '../context/LayoutContext'

packages/components/src/components/common/AccordionView.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ export const AccordionView = React.memo((props: AccordionViewProps) => {
2222

2323
const [size, setSize] = useState<number | 'auto'>(0)
2424

25+
const immediate = Platform.realOS === 'android'
26+
2527
const animatedStyles = useSpring<any>({
28+
immediate,
2629
from: { height: 0 },
2730
to: { height: isOpen ? size : 0 },
2831
})

packages/components/src/components/common/Button.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ export const Button = React.memo((props: ButtonProps) => {
8585
function getStyles() {
8686
const { isHovered, isPressing, theme } = cacheRef.current
8787

88+
const immediate = Platform.realOS === 'android'
89+
8890
return {
89-
config: { duration: 100 },
91+
config: { duration: immediate ? 0 : 100 },
92+
immediate,
9093
activityIndicatorColor: theme.foregroundColor,
9194
touchableBorderColor: backgroundColor
9295
? backgroundColor

packages/components/src/components/modals/AddColumnModal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,11 @@ function AddColumnModalItem({
213213

214214
function getStyles() {
215215
const { isHovered, isPressing, theme } = cacheRef.current
216+
const immediate = Platform.realOS === 'android'
216217

217218
return {
218-
config: { duration: 100 },
219+
config: { duration: immediate ? 0 : 100 },
220+
immediate,
219221
backgroundColor:
220222
(isHovered || isPressing) && !disabled
221223
? theme.backgroundColorLess1

packages/components/src/components/modals/ModalRenderer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,12 @@ export function ModalRenderer(props: ModalRendererProps) {
104104
}, [!!currentOpenedModal])
105105

106106
const immediate =
107-
sizename === '1-small' &&
107+
Platform.realOS === 'android' ||
108+
(sizename === '1-small' &&
108109
((isSettings && !previouslyOpenedModal) ||
109110
(!currentOpenedModal && wasSettings))
110111
? true
111-
: false
112+
: false)
112113

113114
const size = columnWidth + (renderSeparator ? separatorTickSize : 0)
114115

packages/components/src/containers/ColumnsContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ export interface ColumnsContainerProps {}
88

99
export function ColumnsContainer() {
1010
const columnIds = useReduxState(selectors.columnIdsSelector)
11+
1112
return <Columns key="columns-container" columnIds={columnIds} />
1213
}

0 commit comments

Comments
 (0)