pl-fe: improve floating-ui behavior
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
4d47b42e5d
commit
e6bed8c471
2 changed files with 16 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
|||
import { useFloating, useTransitionStyles } from '@floating-ui/react';
|
||||
import { shift, useFloating, useTransitionStyles } from '@floating-ui/react';
|
||||
import clsx from 'clsx';
|
||||
import React, { useEffect } from 'react';
|
||||
import { useIntl, FormattedMessage } from 'react-intl';
|
||||
|
@ -73,17 +73,23 @@ const ProfileHoverCard: React.FC<IProfileHoverCard> = ({ visible = true }) => {
|
|||
};
|
||||
}, []);
|
||||
|
||||
const { x, y, strategy, refs, context } = useFloating({
|
||||
const { x, y, strategy, refs, context, placement } = useFloating({
|
||||
open: !!account,
|
||||
elements: {
|
||||
reference: targetRef,
|
||||
},
|
||||
middleware: [
|
||||
shift({
|
||||
padding: 8,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const { styles } = useTransitionStyles(context, {
|
||||
initial: {
|
||||
opacity: 0,
|
||||
transform: 'scale(0.8)',
|
||||
transformOrigin: placement === 'bottom' ? 'top' : 'bottom',
|
||||
},
|
||||
duration: {
|
||||
open: 100,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { useFloating, useTransitionStyles } from '@floating-ui/react';
|
||||
import { shift, useFloating, useTransitionStyles } from '@floating-ui/react';
|
||||
import clsx from 'clsx';
|
||||
import React, { useEffect, useCallback } from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
|
@ -43,19 +43,23 @@ const StatusHoverCard: React.FC<IStatusHoverCard> = ({ visible = true }) => {
|
|||
};
|
||||
}, []);
|
||||
|
||||
const { x, y, strategy, refs, context } = useFloating({
|
||||
const { x, y, strategy, refs, context, placement } = useFloating({
|
||||
open: !!statusId,
|
||||
elements: {
|
||||
reference: targetRef,
|
||||
},
|
||||
placement: 'top',
|
||||
middleware: [
|
||||
shift({
|
||||
padding: 8,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const { styles } = useTransitionStyles(context, {
|
||||
initial: {
|
||||
opacity: 0,
|
||||
transform: 'scale(0.8)',
|
||||
transformOrigin: 'bottom',
|
||||
transformOrigin: placement === 'bottom' ? 'top' : 'bottom',
|
||||
},
|
||||
duration: {
|
||||
open: 100,
|
||||
|
|
Loading…
Reference in a new issue