Commit 01a44d49 authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

fix: Can't scroll behind bag (#5299)

* mobile bag scroll behind and snap

* fix laggy animation on profile page when filters are opened

* don't scroll assets behind bag

* refactor duration

* correct placement of isBagExpanded

* simplify conditions
Co-authored-by: default avatarCharles Bachmeier <charlie@genie.xyz>
parent f0412f5d
...@@ -9,8 +9,9 @@ import { themeVars } from 'nft/css/sprinkles.css' ...@@ -9,8 +9,9 @@ import { themeVars } from 'nft/css/sprinkles.css'
import { useFiltersExpanded, useIsMobile, useWalletCollections } from 'nft/hooks' import { useFiltersExpanded, useIsMobile, useWalletCollections } from 'nft/hooks'
import { WalletCollection } from 'nft/types' import { WalletCollection } from 'nft/types'
import { Dispatch, FormEvent, SetStateAction, useCallback, useEffect, useReducer, useState } from 'react' import { Dispatch, FormEvent, SetStateAction, useCallback, useEffect, useReducer, useState } from 'react'
import { useSpring } from 'react-spring' import { easings, useSpring } from 'react-spring'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { TRANSITION_DURATIONS } from 'theme/styles'
import * as styles from './ProfilePage.css' import * as styles from './ProfilePage.css'
...@@ -22,7 +23,6 @@ const ItemsContainer = styled.div` ...@@ -22,7 +23,6 @@ const ItemsContainer = styled.div`
export const FilterSidebar = () => { export const FilterSidebar = () => {
const collectionFilters = useWalletCollections((state) => state.collectionFilters) const collectionFilters = useWalletCollections((state) => state.collectionFilters)
const setCollectionFilters = useWalletCollections((state) => state.setCollectionFilters) const setCollectionFilters = useWalletCollections((state) => state.setCollectionFilters)
const walletCollections = useWalletCollections((state) => state.walletCollections) const walletCollections = useWalletCollections((state) => state.walletCollections)
const [isFiltersExpanded, setFiltersExpanded] = useFiltersExpanded() const [isFiltersExpanded, setFiltersExpanded] = useFiltersExpanded()
...@@ -30,6 +30,10 @@ export const FilterSidebar = () => { ...@@ -30,6 +30,10 @@ export const FilterSidebar = () => {
const { sidebarX } = useSpring({ const { sidebarX } = useSpring({
sidebarX: isFiltersExpanded ? 0 : -360, sidebarX: isFiltersExpanded ? 0 : -360,
config: {
duration: TRANSITION_DURATIONS.medium,
easing: easings.easeOutSine,
},
}) })
return ( return (
// @ts-ignore // @ts-ignore
......
...@@ -21,7 +21,7 @@ import { WalletCollection } from 'nft/types' ...@@ -21,7 +21,7 @@ import { WalletCollection } from 'nft/types'
import { Dispatch, SetStateAction, useEffect, useState } from 'react' import { Dispatch, SetStateAction, useEffect, useState } from 'react'
import InfiniteScroll from 'react-infinite-scroll-component' import InfiniteScroll from 'react-infinite-scroll-component'
import { useQuery } from 'react-query' import { useQuery } from 'react-query'
import { useSpring } from 'react-spring' import { easings, useSpring } from 'react-spring'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import shallow from 'zustand/shallow' import shallow from 'zustand/shallow'
...@@ -66,6 +66,7 @@ export const ProfilePage = () => { ...@@ -66,6 +66,7 @@ export const ProfilePage = () => {
shallow shallow
) )
const sellAssets = useSellAsset((state) => state.sellAssets) const sellAssets = useSellAsset((state) => state.sellAssets)
const isBagExpanded = useBag((state) => state.bagExpanded)
const toggleBag = useBag((state) => state.toggleBag) const toggleBag = useBag((state) => state.toggleBag)
const [isFiltersExpanded, setFiltersExpanded] = useFiltersExpanded() const [isFiltersExpanded, setFiltersExpanded] = useFiltersExpanded()
const isMobile = useIsMobile() const isMobile = useIsMobile()
...@@ -91,6 +92,10 @@ export const ProfilePage = () => { ...@@ -91,6 +92,10 @@ export const ProfilePage = () => {
const { gridX } = useSpring({ const { gridX } = useSpring({
gridX: isFiltersExpanded ? FILTER_SIDEBAR_WIDTH : -PADDING, gridX: isFiltersExpanded ? FILTER_SIDEBAR_WIDTH : -PADDING,
config: {
duration: 250,
easing: easings.easeOutSine,
},
}) })
return ( return (
...@@ -107,6 +112,7 @@ export const ProfilePage = () => { ...@@ -107,6 +112,7 @@ export const ProfilePage = () => {
<Column width="full"> <Column width="full">
<AnimatedBox <AnimatedBox
flexShrink="0" flexShrink="0"
position={isMobile && isBagExpanded ? 'fixed' : 'static'}
style={{ style={{
transform: gridX.to( transform: gridX.to(
(x) => (x) =>
......
...@@ -24,6 +24,7 @@ import { useLocation, useNavigate, useParams } from 'react-router-dom' ...@@ -24,6 +24,7 @@ import { useLocation, useNavigate, useParams } from 'react-router-dom'
import { easings, useSpring } from 'react-spring' import { easings, useSpring } from 'react-spring'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { ThemedText } from 'theme' import { ThemedText } from 'theme'
import { TRANSITION_DURATIONS } from 'theme/styles'
const FILTER_WIDTH = 332 const FILTER_WIDTH = 332
const BAG_WIDTH = 324 const BAG_WIDTH = 324
...@@ -100,11 +101,11 @@ const Collection = () => { ...@@ -100,11 +101,11 @@ const Collection = () => {
? isBagExpanded ? isBagExpanded
? BAG_WIDTH + FILTER_WIDTH ? BAG_WIDTH + FILTER_WIDTH
: FILTER_WIDTH : FILTER_WIDTH
: isBagExpanded : isBagExpanded && !isMobile
? BAG_WIDTH ? BAG_WIDTH
: 0, : 0,
config: { config: {
duration: 250, duration: TRANSITION_DURATIONS.medium,
easing: easings.easeOutSine, easing: easings.easeOutSine,
}, },
}) })
...@@ -188,7 +189,7 @@ const Collection = () => { ...@@ -188,7 +189,7 @@ const Collection = () => {
{/* @ts-ignore: https://github.com/microsoft/TypeScript/issues/34933 */} {/* @ts-ignore: https://github.com/microsoft/TypeScript/issues/34933 */}
<AnimatedBox <AnimatedBox
position={isMobile && isFiltersExpanded ? 'fixed' : 'static'} position={isMobile && (isFiltersExpanded || isBagExpanded) ? 'fixed' : 'static'}
style={{ style={{
transform: gridX.to((x) => `translate(${x as number}px)`), transform: gridX.to((x) => `translate(${x as number}px)`),
width: gridWidthOffset.to((x) => `calc(100% - ${x as number}px)`), width: gridWidthOffset.to((x) => `calc(100% - ${x as number}px)`),
......
...@@ -10,11 +10,17 @@ export const flexRowNoWrap = css` ...@@ -10,11 +10,17 @@ export const flexRowNoWrap = css`
flex-flow: row nowrap; flex-flow: row nowrap;
` `
export enum TRANSITION_DURATIONS {
slow = 500,
medium = 250,
fast = 125,
}
const transitions = { const transitions = {
duration: { duration: {
slow: '500ms', slow: `${TRANSITION_DURATIONS.slow}ms`,
medium: '250ms', medium: `${TRANSITION_DURATIONS.medium}ms`,
fast: '125ms', fast: `${TRANSITION_DURATIONS.fast}ms`,
}, },
timing: { timing: {
ease: 'ease', ease: 'ease',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment