cloud-web-corejs 1.0.267 → 1.0.268

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,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.267",
4
+ "version": "1.0.268",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "lint": "eslint --ext .js,.vue src",
@@ -1,3 +1,5 @@
1
+ import { scrollIntoScrollParent } from '@base/utils/scrollUtil';
2
+
1
3
  let baseTabsMixin, baseTabPaneMixin;
2
4
 
3
5
  baseTabsMixin = {
@@ -76,17 +78,10 @@ baseTabsMixin = {
76
78
  this.$emit('input', name);
77
79
  this.$emit('on-click', name);
78
80
  let target = this.getTabs()[index].$el;
79
- let scrollContainer = Array.prototype.find.call(
80
- this.$el.children,
81
- item => item.classList && item.classList.contains('d-cont')
82
- );
83
- if (scrollContainer) {
84
- let containerRect = scrollContainer.getBoundingClientRect();
85
- let targetRect = target.getBoundingClientRect();
86
- scrollContainer.scrollTop += targetRect.top - containerRect.top;
87
- } else {
88
- target.scrollIntoView();
89
- }
81
+ //滚动体是 .d-cont 还是它外面那层(.d-header + div{flex:1;overflow-y:auto})由布局决定,
82
+ //原来写死 .d-cont,在 .d-cont 没有确定高度(height:inherit 拿到 auto)的页面上
83
+ //scrollTop 赋值是空操作,点导航没反应——统一交给 scrollIntoScrollParent 找真正的滚动体。
84
+ scrollIntoScrollParent(target);
90
85
  }
91
86
  },
92
87
  watch: {
@@ -1,5 +1,6 @@
1
1
  import Vue from 'vue';
2
2
  import settingConfig from '@/settings.js'
3
+ import { scrollIntoScrollParent } from '@base/utils/scrollUtil';
3
4
 
4
5
  let f;
5
6
  let configUtil = {
@@ -90,7 +91,9 @@ f = async function (option) {
90
91
  click: (event) => {
91
92
  instance.$children[0].handleFold(true);
92
93
  that.$nextTick(() => {
93
- instance.$el.scrollIntoView();
94
+ //流程区是挂在 .d-cont 里滚的,直接 scrollIntoView 会把外层文档/宿主容器
95
+ //一起滚起来(固定头被顶走、微前端下滚的是主应用),只在真正的滚动容器里滚。
96
+ scrollIntoScrollParent(instance.$el);
94
97
  })
95
98
  }
96
99
  }
@@ -0,0 +1,25 @@
1
+ //在元素最近的可滚动祖先内部滚动到该元素;确实没有可滚动祖先时才退回 scrollIntoView。
2
+ //不能一上来就 scrollIntoView:那会把外层文档/宿主容器一起滚起来(固定头被顶走、
3
+ //微前端下滚的是主应用)。反过来也不能写死某一层容器——同一套详情结构里,真正带
4
+ //overflow 的是哪一层由 CSS 决定(有的布局是 .d-cont,有的是它外面那层 flex:1 的 div),
5
+ //写死就会在另一种布局里变成空操作。
6
+ //使用方:baseTabs 的页签锚点(components/baseTabs/mixins.js)、wf 的「流程信息」导航(components/wf/wfUtil.js)。
7
+ function scrollIntoScrollParent(el) {
8
+ if (!el || !el.parentElement) return;
9
+ let container = el.parentElement;
10
+ let root = document.documentElement;
11
+ while (container && container !== document.body && container !== root) {
12
+ let overflowY = window.getComputedStyle(container).overflowY;
13
+ let scrollable = /auto|scroll|overlay/.test(overflowY);
14
+ if (scrollable && container.scrollHeight > container.clientHeight) {
15
+ let containerRect = container.getBoundingClientRect();
16
+ let targetRect = el.getBoundingClientRect();
17
+ container.scrollTop += targetRect.top - containerRect.top;
18
+ return;
19
+ }
20
+ container = container.parentElement;
21
+ }
22
+ el.scrollIntoView();
23
+ }
24
+
25
+ export { scrollIntoScrollParent };