classcard-ui 0.2.427 → 0.2.430

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "classcard-ui",
3
- "version": "0.2.427",
3
+ "version": "0.2.430",
4
4
  "main": "dist/classcard-ui.common.js",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -78,11 +78,29 @@ export default {
78
78
  };
79
79
  },
80
80
  methods: {
81
+ scrollIfNeeded(element, container) {
82
+ if (element.offsetTop < container.scrollTop) {
83
+ container.scrollTop = element.offsetTop;
84
+ } else {
85
+ const offsetBottom = element.offsetTop + element.offsetHeight;
86
+ const scrollBottom = container.scrollTop + container.offsetHeight;
87
+ if (offsetBottom > scrollBottom) {
88
+ container.scrollTop = offsetBottom - container.offsetHeight;
89
+ }
90
+ }
91
+ },
81
92
  switchTab(name) {
82
93
  this.activeTab = name;
83
- document.querySelector(`#${name}`).scrollIntoView({
84
- behavior: "smooth",
85
- });
94
+ // document.getElementById(`${name}`).scrollIntoView({
95
+ // behavior: "smooth",
96
+ // block: "nearest",
97
+ // inline: "start",
98
+ // });
99
+
100
+ this.scrollIfNeeded(
101
+ document.getElementById(`${name}`),
102
+ document.getElementById("container")
103
+ );
86
104
  },
87
105
  switchTabForMobile(index) {
88
106
  var selectedOption = this.tabs[index];