2023-05-24 10:09:45 +00:00
|
|
|
<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' }],
|
2023-05-25 14:42:59 +00:00
|
|
|
icon: 'p-scrolltop-icon'
|
2023-05-24 10:09:45 +00:00
|
|
|
};
|
|
|
|
|
2023-07-03 22:20:35 +00:00
|
|
|
const { load: loadStyle } = useStyle(styles, { name: 'scrolltop', manual: true });
|
2023-05-24 10:09:45 +00:00
|
|
|
|
|
|
|
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: {
|
2023-05-30 12:28:04 +00:00
|
|
|
classes,
|
|
|
|
loadStyle
|
2023-05-24 10:09:45 +00:00
|
|
|
},
|
2023-05-30 12:28:04 +00:00
|
|
|
provide() {
|
|
|
|
return {
|
|
|
|
$parentInstance: this
|
|
|
|
};
|
2023-05-24 10:09:45 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|