diff --git a/src/components/scrolltop/ScrollTop.d.ts b/src/components/scrolltop/ScrollTop.d.ts index e69de29bb..e79b2e127 100644 --- a/src/components/scrolltop/ScrollTop.d.ts +++ b/src/components/scrolltop/ScrollTop.d.ts @@ -0,0 +1,10 @@ +import Vue from 'vue'; + +declare class ScrollTo extends Vue { + target?: string; + threshold?: number; + icon?: boolean; + behavior?: boolean; +} + +export default ScrollTo; \ No newline at end of file diff --git a/src/components/scrolltop/ScrollTop.vue b/src/components/scrolltop/ScrollTop.vue index e48bef14b..9f627832f 100644 --- a/src/components/scrolltop/ScrollTop.vue +++ b/src/components/scrolltop/ScrollTop.vue @@ -21,13 +21,17 @@ export default { type: String, default: 'window' }, - visiblePosition: { + threshold: { type: Number, default: 400 }, icon: { type: String, default: 'pi pi-chevron-up' + }, + behavior: { + type: String, + default: 'smooth' } }, mounted() { @@ -47,11 +51,11 @@ export default { let scrollElement = this.target === 'window' ? window : this.$el.parentElement; scrollElement.scroll({ top: 0, - behavior: 'smooth' + behavior: this.behavior }); }, checkVisibility(scrollY) { - if (scrollY > this.visiblePosition) + if (scrollY > this.threshold) this.visible = true; else this.visible = false; diff --git a/src/views/scrolltop/ScrollTopDemo.vue b/src/views/scrolltop/ScrollTopDemo.vue index d37cb6942..cda5aba48 100644 --- a/src/views/scrolltop/ScrollTopDemo.vue +++ b/src/views/scrolltop/ScrollTopDemo.vue @@ -28,7 +28,7 @@ Eget egestas purus viverra accumsan in nisl nisi. Suscipit adipiscing bibendum est ultricies integer. Mattis aliquam faucibus purus in massa tempor nec.
-When the vertical scroll position reaches a certain threshold, ScrollTop gets displays. This value is - defined with the visiblePosition property that defaults to 400.
+When the vertical scroll position reaches a certain value, ScrollTop gets displayed. This value is + defined with the threshold property that defaults to 400.
-<ScrollTop :visiblePosition="400" />
+<ScrollTop :threshold="200" />
@@ -56,7 +56,7 @@ import ScrollTop from 'primevue/scrolltop';