You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.1 KiB

feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case & update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 <wangning4567@163.com> Co-authored-by: MadCcc <1075746765@qq.com>
2 years ago
import VerticalAlignTopOutlined from '@ant-design/icons/VerticalAlignTopOutlined';
import classNames from 'classnames';
import CSSMotion from 'rc-motion';
import addEventListener from 'rc-util/lib/Dom/addEventListener';
import React, { memo, useContext, useEffect, useRef, useState } from 'react';
import FloatButton, { floatButtonPrefixCls } from './FloatButton';
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case & update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 <wangning4567@163.com> Co-authored-by: MadCcc <1075746765@qq.com>
2 years ago
import type { ConfigConsumerProps } from '../config-provider';
import { ConfigContext } from '../config-provider';
import getScroll from '../_util/getScroll';
import scrollTo from '../_util/scrollTo';
import throttleByAnimationFrame from '../_util/throttleByAnimationFrame';
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case & update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 <wangning4567@163.com> Co-authored-by: MadCcc <1075746765@qq.com>
2 years ago
import FloatButtonGroupContext from './context';
import type { BackTopProps, FloatButtonProps, FloatButtonShape } from './interface';
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case & update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 <wangning4567@163.com> Co-authored-by: MadCcc <1075746765@qq.com>
2 years ago
import useStyle from './style';
const BackTop: React.FC<BackTopProps> = (props) => {
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case &amp; update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 &lt;wangning4567@163.com&gt; Co-authored-by: MadCcc &lt;1075746765@qq.com&gt;
2 years ago
const {
prefixCls: customizePrefixCls,
className = '',
type = 'default',
shape = 'circle',
visibilityHeight = 400,
icon = <VerticalAlignTopOutlined />,
target,
onClick,
duration = 450,
...restProps
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case &amp; update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 &lt;wangning4567@163.com&gt; Co-authored-by: MadCcc &lt;1075746765@qq.com&gt;
2 years ago
} = props;
const [visible, setVisible] = useState<boolean>(visibilityHeight === 0);
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case &amp; update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 &lt;wangning4567@163.com&gt; Co-authored-by: MadCcc &lt;1075746765@qq.com&gt;
2 years ago
const ref = useRef<HTMLAnchorElement | HTMLButtonElement>(null);
const scrollEvent = useRef<ReturnType<typeof addEventListener> | null>(null);
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case &amp; update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 &lt;wangning4567@163.com&gt; Co-authored-by: MadCcc &lt;1075746765@qq.com&gt;
2 years ago
const getDefaultTarget = (): HTMLElement | Document | Window =>
ref.current && ref.current.ownerDocument ? ref.current.ownerDocument : window;
const handleScroll = throttleByAnimationFrame(
(e: React.UIEvent<HTMLElement, UIEvent> | { target: any }) => {
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case &amp; update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 &lt;wangning4567@163.com&gt; Co-authored-by: MadCcc &lt;1075746765@qq.com&gt;
2 years ago
const scrollTop = getScroll(e.target, true);
setVisible(scrollTop >= visibilityHeight);
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case &amp; update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 &lt;wangning4567@163.com&gt; Co-authored-by: MadCcc &lt;1075746765@qq.com&gt;
2 years ago
},
);
const bindScrollEvent = () => {
const getTarget = target || getDefaultTarget;
const container = getTarget();
scrollEvent.current = addEventListener(container, 'scroll', handleScroll);
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case &amp; update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 &lt;wangning4567@163.com&gt; Co-authored-by: MadCcc &lt;1075746765@qq.com&gt;
2 years ago
handleScroll({ target: container });
};
useEffect(() => {
bindScrollEvent();
return () => {
handleScroll.cancel();
scrollEvent.current?.remove();
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case &amp; update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 &lt;wangning4567@163.com&gt; Co-authored-by: MadCcc &lt;1075746765@qq.com&gt;
2 years ago
};
}, [target]);
const scrollToTop: React.MouseEventHandler<HTMLDivElement> = (e) => {
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case &amp; update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 &lt;wangning4567@163.com&gt; Co-authored-by: MadCcc &lt;1075746765@qq.com&gt;
2 years ago
scrollTo(0, { getContainer: target || getDefaultTarget, duration });
onClick?.(e);
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case &amp; update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 &lt;wangning4567@163.com&gt; Co-authored-by: MadCcc &lt;1075746765@qq.com&gt;
2 years ago
};
const { getPrefixCls } = useContext<ConfigConsumerProps>(ConfigContext);
const prefixCls = getPrefixCls(floatButtonPrefixCls, customizePrefixCls);
const rootPrefixCls = getPrefixCls();
const [wrapSSR] = useStyle(prefixCls);
const groupShape = useContext<FloatButtonShape | undefined>(FloatButtonGroupContext);
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case &amp; update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 &lt;wangning4567@163.com&gt; Co-authored-by: MadCcc &lt;1075746765@qq.com&gt;
2 years ago
const mergeShape = groupShape || shape;
const contentProps: FloatButtonProps = { prefixCls, icon, type, shape: mergeShape, ...restProps };
feat: Float Button (#37520) * feat: add FloatButton * feat: add FloatButton * feat: FloatButton * feat: FloatButton * fix: fix * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * feat: FloatButton * fix: add groupShape * feat: mergeShape * fix: fix * fix: fix style * fix: style fix * fix: fix * fix: style fix * fix: fix * fix: fix * fix: fix * fix: fix style * fix: fix style * fix: fix style * fix: style fix * feat: back-top * fix: style bug fix * fix: fix erroe * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * fix: add tiggerElement * feat: add useMemo * docs: add docs * fix: bugFix * fix: bugFix * fix: bugfix * fix: style fix * fix: bugfix * test: add test case * fix: style fix * fix: style fix * fix: fix style * fix: fix style * fix: fix trigger action * fix: fix style * feat: add demo * fix: add demo * feat: add docs * fix: style ifx * feat: update maxSize of bundlesize * feat: add animation for group * fix: fix * fix: fix style * fix: fix test case * fix: fix test case * fix: fix type * fix: fix type * fix: update bundlesize * fix: fix * fix: fix style * fix: fix style * fix: updata snap * fix: fix CI * fix: fix style * fix: rename float button motion * fix: fix style * fix: bugFix * fix: fix style * fix: bugFix * fix: update docs * refactor: float button trigger * test: fix test case &amp; update snapshot * fix: delete rest * docs: update demo * test: update snapshot * fix: fix eslint error * test: update snapshot * style: update icon fontSize to 18 * fix: fix style * fix: style fix * fix: test case fix * test: add test case * fix: style fix * test: update snap * fix: style fix * fix: style fix * fix: style fix * docs: demo update * fix: style fix * docs: update demo * test: update snapshot Co-authored-by: 黑雨 &lt;wangning4567@163.com&gt; Co-authored-by: MadCcc &lt;1075746765@qq.com&gt;
2 years ago
return wrapSSR(
<CSSMotion visible={visible} motionName={`${rootPrefixCls}-fade`}>
{({ className: motionClassName }) => (
<FloatButton
ref={ref}
{...contentProps}
onClick={scrollToTop}
className={classNames(className, motionClassName)}
/>
)}
</CSSMotion>,
);
};
export default memo(BackTop);