parent
f4c1c4569d
commit
c6e22ce8ab
|
@ -0,0 +1,9 @@
|
||||||
|
import PropTypes from '../_util/vue-types';
|
||||||
|
export default () => ({
|
||||||
|
visibilityHeight: PropTypes.number,
|
||||||
|
// onClick?: React.MouseEventHandler<any>;
|
||||||
|
target: PropTypes.func,
|
||||||
|
prefixCls: PropTypes.string,
|
||||||
|
onClick: PropTypes.func,
|
||||||
|
// visible: PropTypes.bool, // Only for test. Don't use it.
|
||||||
|
});
|
|
@ -1,34 +1,30 @@
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
|
import backTopTypes from './backTopTypes';
|
||||||
import addEventListener from '../vc-util/Dom/addEventListener';
|
import addEventListener from '../vc-util/Dom/addEventListener';
|
||||||
import getScroll from '../_util/getScroll';
|
import getScroll from '../_util/getScroll';
|
||||||
import BaseMixin from '../_util/BaseMixin';
|
import BaseMixin from '../_util/BaseMixin';
|
||||||
import getTransitionProps from '../_util/getTransitionProps';
|
import getTransitionProps from '../_util/getTransitionProps';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
import Base from '../base';
|
|
||||||
import { getListeners } from '../_util/props-util';
|
|
||||||
import scrollTo from '../_util/scrollTo';
|
import scrollTo from '../_util/scrollTo';
|
||||||
|
import { inject } from 'vue';
|
||||||
|
|
||||||
function getDefaultTarget() {
|
function getDefaultTarget() {
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BackTopProps = {
|
const props = backTopTypes();
|
||||||
visibilityHeight: PropTypes.number,
|
|
||||||
// onClick?: React.MouseEventHandler<any>;
|
|
||||||
target: PropTypes.func,
|
|
||||||
prefixCls: PropTypes.string,
|
|
||||||
// visible: PropTypes.bool, // Only for test. Don't use it.
|
|
||||||
};
|
|
||||||
|
|
||||||
const BackTop = {
|
const BackTop = {
|
||||||
name: 'ABackTop',
|
name: 'ABackTop',
|
||||||
mixins: [BaseMixin],
|
mixins: [BaseMixin],
|
||||||
props: {
|
props: {
|
||||||
...BackTopProps,
|
...props,
|
||||||
visibilityHeight: PropTypes.number.def(400),
|
visibilityHeight: PropTypes.number.def(400),
|
||||||
},
|
},
|
||||||
inject: {
|
setup() {
|
||||||
configProvider: { default: () => ConfigConsumerProps },
|
return {
|
||||||
|
configProvider: inject('configProvider', ConfigConsumerProps),
|
||||||
|
};
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
this.scrollEvent = null;
|
this.scrollEvent = null;
|
||||||
|
@ -88,15 +84,12 @@ const BackTop = {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
const divProps = {
|
const divProps = {
|
||||||
on: {
|
onClick: this.scrollToTop,
|
||||||
...getListeners(this),
|
|
||||||
click: this.scrollToTop,
|
|
||||||
},
|
|
||||||
class: prefixCls,
|
class: prefixCls,
|
||||||
};
|
};
|
||||||
|
|
||||||
const backTopBtn = this.visible ? (
|
const backTopBtn = this.visible ? (
|
||||||
<div {...divProps}>{$slots.default || defaultElement}</div>
|
<div {...divProps}>{($slots.default && $slots.default()) || defaultElement}</div>
|
||||||
) : null;
|
) : null;
|
||||||
const transitionProps = getTransitionProps('fade');
|
const transitionProps = getTransitionProps('fade');
|
||||||
return <transition {...transitionProps}>{backTopBtn}</transition>;
|
return <transition {...transitionProps}>{backTopBtn}</transition>;
|
||||||
|
@ -104,9 +97,8 @@ const BackTop = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
BackTop.install = function(Vue) {
|
BackTop.install = function(app) {
|
||||||
Vue.use(Base);
|
app.component(BackTop.name, BackTop);
|
||||||
Vue.component(BackTop.name, BackTop);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default BackTop;
|
export default BackTop;
|
||||||
|
|
|
@ -21,6 +21,7 @@ import Col from 'ant-design-vue/col';
|
||||||
import Row from 'ant-design-vue/row';
|
import Row from 'ant-design-vue/row';
|
||||||
import Tooltip from 'ant-design-vue/tooltip';
|
import Tooltip from 'ant-design-vue/tooltip';
|
||||||
import Descriptions from 'ant-design-vue/descriptions';
|
import Descriptions from 'ant-design-vue/descriptions';
|
||||||
|
import BackTop from 'ant-design-vue/back-top';
|
||||||
import Tag from 'ant-design-vue/tag';
|
import Tag from 'ant-design-vue/tag';
|
||||||
import 'ant-design-vue/style.js';
|
import 'ant-design-vue/style.js';
|
||||||
|
|
||||||
|
@ -45,5 +46,6 @@ createApp(App)
|
||||||
.use(Row)
|
.use(Row)
|
||||||
.use(Tooltip)
|
.use(Tooltip)
|
||||||
.use(Descriptions)
|
.use(Descriptions)
|
||||||
|
.use(BackTop)
|
||||||
.use(Tag)
|
.use(Tag)
|
||||||
.mount('#app');
|
.mount('#app');
|
||||||
|
|
Loading…
Reference in New Issue