comand-component-library 3.3.39 → 3.3.41

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comand-component-library",
3
- "version": "3.3.39",
3
+ "version": "3.3.41",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
package/src/App.vue CHANGED
@@ -819,7 +819,7 @@
819
819
  <!-- end advanced form elements ----------------------------------------------------------------------------------------------------------------------------------------------------->
820
820
 
821
821
  <!-- begin back to top button ----------------------------------------------------------------------------------------------------------------------------------------------------->
822
- <CmdBackToTopButton/>
822
+ <CmdBackToTopButton />
823
823
  <!-- end back to top button ----------------------------------------------------------------------------------------------------------------------------------------------------->
824
824
 
825
825
  <!-- begin bank account data ----------------------------------------------------------------------------------------------------------------------------------------------------->
@@ -17,12 +17,12 @@ export default {
17
17
  data() {
18
18
  return {
19
19
  windowInnerHeight: window.innerHeight,
20
- windowScrollY: window.scrollY ?? (document.querySelector(this.parentSelector)?.scrollTop || 0),
21
- scrollHeight: document.querySelector(this.parentSelector)?.scrollHeight || 0
20
+ windowScrollY: this.getScrollY(),
21
+ scrollHeight: document.querySelector(this.scrollContainer)?.scrollHeight || 0
22
22
  }
23
23
  },
24
24
  props: {
25
- parentSelector: {
25
+ scrollContainer: {
26
26
  type: String,
27
27
  default: "body"
28
28
  },
@@ -42,13 +42,21 @@ export default {
42
42
  }
43
43
  }
44
44
  },
45
- created() {
45
+ mounted() {
46
46
  window.addEventListener('resize', this.onViewportChange)
47
- document.querySelector(this.parentSelector)?.addEventListener('scroll', this.onViewportChange)
47
+ if (this.scrollContainer === "body") {
48
+ window.addEventListener('scroll', this.onViewportChange);
49
+ } else {
50
+ document.querySelector(this.scrollContainer)?.addEventListener('scroll', this.onViewportChange);
51
+ }
48
52
  },
49
53
  unmounted() {
50
54
  window.removeEventListener('resize', this.onViewportChange)
51
- document.querySelector(this.parentSelector)?.removeEventListener('scroll', this.onViewportChange)
55
+ if (this.scrollContainer === "body") {
56
+ window.addEventListener('scroll', this.onViewportChange);
57
+ } else {
58
+ document.querySelector(this.scrollContainer)?.removeEventListener('scroll', this.onViewportChange)
59
+ }
52
60
  },
53
61
  /* watch for changes */
54
62
  computed: {
@@ -57,13 +65,23 @@ export default {
57
65
  }
58
66
  },
59
67
  methods: {
68
+ getScrollY() {
69
+ if (this.scrollContainer === "body") {
70
+ return window.scrollY
71
+ }
72
+ return document.querySelector(this.scrollContainer)?.scrollTop || 0
73
+ },
60
74
  onViewportChange() {
61
75
  this.windowInnerHeight = window.innerHeight;
62
- this.windowScrollY = window.scrollY ?? (document.querySelector(this.parentSelector)?.scrollTop || 0)
63
- this.scrollHeight = document.querySelector(this.parentSelector)?.scrollHeight || 0
76
+ this.windowScrollY = this.getScrollY()
77
+ this.scrollHeight = document.querySelector(this.scrollContainer)?.scrollHeight || 0
64
78
  },
65
79
  onBackToTop() {
66
- document.querySelector(this.parentSelector)?.scrollTo({top: 0, left: 0, behavior: 'smooth'})
80
+ if (this.scrollContainer === "body") {
81
+ window.scrollTo({top: 0, left: 0, behavior: 'smooth'})
82
+ } else {
83
+ document.querySelector(this.scrollContainer)?.scrollTo({top: 0, left: 0, behavior: 'smooth'})
84
+ }
67
85
  }
68
86
  }
69
87
  }