Refactor #3879 - For ScrollTop
parent
1af654c740
commit
9dd6301979
|
@ -22,6 +22,12 @@ const ScrollTopProps = [
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'smooth',
|
default: 'smooth',
|
||||||
description: 'Defines the scrolling behavi, "smooth" adds an animation and "auto" scrolls with a jump.'
|
description: 'Defines the scrolling behavi, "smooth" adds an animation and "auto" scrolls with a jump.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'pt',
|
||||||
|
type: 'any',
|
||||||
|
default: 'null',
|
||||||
|
description: 'Uses to pass attributes to DOM elements inside the component.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,49 @@
|
||||||
import { VNode } from 'vue';
|
import { VNode } from 'vue';
|
||||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||||
|
|
||||||
|
export declare type ScrollTopPassThroughOptionType = ScrollTopPassThroughAttributes | ((options: ScrollTopPassThroughMethodOptions) => ScrollTopPassThroughAttributes) | null | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough(pt) option method.
|
||||||
|
*/
|
||||||
|
export interface ScrollTopPassThroughMethodOptions {
|
||||||
|
props: ScrollTopProps;
|
||||||
|
state: ScrollTopState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough(pt) options.
|
||||||
|
* @see {@link ScrollTopProps.pt}
|
||||||
|
*/
|
||||||
|
export interface ScrollTopPassThroughOptions {
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the root's DOM element.
|
||||||
|
*/
|
||||||
|
root?: ScrollTopPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the icon's DOM element.
|
||||||
|
*/
|
||||||
|
icon?: ScrollTopPassThroughOptionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough attributes for each DOM elements
|
||||||
|
*/
|
||||||
|
export interface ScrollTopPassThroughAttributes {
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines current inline state in ScrollTop component.
|
||||||
|
*/
|
||||||
|
export interface ScrollTopState {
|
||||||
|
/**
|
||||||
|
* Current visible state as a boolean.
|
||||||
|
* @defaultValue false
|
||||||
|
*/
|
||||||
|
visible: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines valid properties in ScrollTop component.
|
* Defines valid properties in ScrollTop component.
|
||||||
*/
|
*/
|
||||||
|
@ -34,6 +77,11 @@ export interface ScrollTopProps {
|
||||||
* @defaultValue smooth
|
* @defaultValue smooth
|
||||||
*/
|
*/
|
||||||
behavior?: string | undefined;
|
behavior?: string | undefined;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to DOM elements inside the component.
|
||||||
|
* @type {ScrollTopPassThroughOptions}
|
||||||
|
*/
|
||||||
|
pt?: ScrollTopPassThroughOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
<template>
|
<template>
|
||||||
<transition name="p-scrolltop" appear @enter="onEnter" @after-leave="onAfterLeave">
|
<transition name="p-scrolltop" appear @enter="onEnter" @after-leave="onAfterLeave">
|
||||||
<button v-if="visible" :ref="containerRef" :class="containerClass" @click="onClick" type="button" :aria-label="scrollTopAriaLabel">
|
<button v-if="visible" :ref="containerRef" :class="containerClass" @click="onClick" type="button" :aria-label="scrollTopAriaLabel" v-bind="ptm('root')">
|
||||||
<slot name="icon">
|
<slot name="icon">
|
||||||
<component :is="icon ? 'span' : 'ChevronUpIcon'" :class="['p-scrolltop-icon', icon]"></component>
|
<component :is="icon ? 'span' : 'ChevronUpIcon'" :class="['p-scrolltop-icon', icon]" v-bind="ptm('icon')" />
|
||||||
</slot>
|
</slot>
|
||||||
</button>
|
</button>
|
||||||
</transition>
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import BaseComponent from 'primevue/basecomponent';
|
||||||
import ChevronUpIcon from 'primevue/icons/chevronup';
|
import ChevronUpIcon from 'primevue/icons/chevronup';
|
||||||
import { DomHandler, ZIndexUtils } from 'primevue/utils';
|
import { DomHandler, ZIndexUtils } from 'primevue/utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ScrollTop',
|
name: 'ScrollTop',
|
||||||
|
extends: BaseComponent,
|
||||||
scrollListener: null,
|
scrollListener: null,
|
||||||
container: null,
|
container: null,
|
||||||
props: {
|
props: {
|
||||||
|
|
Loading…
Reference in New Issue