comand-component-library 3.3.38 → 3.3.40

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.38",
3
+ "version": "3.3.40",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -42,13 +42,21 @@ export default {
42
42
  }
43
43
  }
44
44
  },
45
- created() {
45
+ mounted() {
46
46
  window.addEventListener('resize', this.onViewportChange)
47
- window.addEventListener('scroll', this.onViewportChange)
47
+ if (this.parentSelector === "body") {
48
+ window.addEventListener('scroll', this.onViewportChange);
49
+ } else {
50
+ document.querySelector(this.parentSelector)?.addEventListener('scroll', this.onViewportChange);
51
+ }
48
52
  },
49
53
  unmounted() {
50
54
  window.removeEventListener('resize', this.onViewportChange)
51
- window.removeEventListener('scroll', this.onViewportChange)
55
+ if (this.parentSelector === "body") {
56
+ window.addEventListener('scroll', this.onViewportChange);
57
+ } else {
58
+ document.querySelector(this.parentSelector)?.removeEventListener('scroll', this.onViewportChange)
59
+ }
52
60
  },
53
61
  /* watch for changes */
54
62
  computed: {
@@ -63,7 +71,11 @@ export default {
63
71
  this.scrollHeight = document.querySelector(this.parentSelector)?.scrollHeight || 0
64
72
  },
65
73
  onBackToTop() {
66
- window.scrollTo({top: 0, left: 0, behavior: 'smooth'})
74
+ if (this.parentSelector === "body") {
75
+ window.scrollTo({top: 0, left: 0, behavior: 'smooth'})
76
+ } else {
77
+ document.querySelector(this.parentSelector)?.scrollTo({top: 0, left: 0, behavior: 'smooth'})
78
+ }
67
79
  }
68
80
  }
69
81
  }