mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-08 16:37:15 +00:00
Refactor #3965 - For ScrollTop
This commit is contained in:
parent
ab3343a751
commit
bff2abf68a
6 changed files with 94 additions and 65 deletions
80
components/lib/scrolltop/BaseScrollTop.vue
Normal file
80
components/lib/scrolltop/BaseScrollTop.vue
Normal file
|
@ -0,0 +1,80 @@
|
|||
<script>
|
||||
import BaseComponent from 'primevue/basecomponent';
|
||||
import { useStyle } from 'primevue/usestyle';
|
||||
|
||||
const styles = `
|
||||
.p-scrolltop {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.p-scrolltop-sticky {
|
||||
position: sticky;
|
||||
}
|
||||
|
||||
.p-scrolltop-sticky.p-link {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.p-scrolltop-enter-from {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.p-scrolltop-enter-active {
|
||||
transition: opacity 0.15s;
|
||||
}
|
||||
|
||||
.p-scrolltop.p-scrolltop-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.p-scrolltop-leave-active {
|
||||
transition: opacity 0.15s;
|
||||
}
|
||||
`;
|
||||
|
||||
const classes = {
|
||||
root: ({ props }) => ['p-scrolltop p-link p-component', { 'p-scrolltop-sticky': props.target !== 'window' }],
|
||||
icon: ({ props }) => ['p-scrolltop-icon', props.icon]
|
||||
};
|
||||
|
||||
const { load: loadStyle } = useStyle(styles, { id: 'primevue_scrolltop_style', manual: true });
|
||||
|
||||
export default {
|
||||
name: 'BaseScrollTop',
|
||||
extends: BaseComponent,
|
||||
props: {
|
||||
target: {
|
||||
type: String,
|
||||
default: 'window'
|
||||
},
|
||||
threshold: {
|
||||
type: Number,
|
||||
default: 400
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
behavior: {
|
||||
type: String,
|
||||
default: 'smooth'
|
||||
}
|
||||
},
|
||||
css: {
|
||||
classes
|
||||
},
|
||||
watch: {
|
||||
isUnstyled: {
|
||||
immediate: true,
|
||||
handler(newValue) {
|
||||
!newValue && loadStyle();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue