Skip to content

Commit

Permalink
fix(Tabs): enable hidden on the beginning (#3132)
Browse files Browse the repository at this point in the history
* fix(Tabs): enable hidden on the beginning

* docs(tabs): update
  • Loading branch information
jarmywang authored Sep 10, 2024
1 parent abe1f53 commit 1c0429a
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/common/wechat.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const getObserver = (context, selector: string) => {
return new Promise((resolve, reject) => {
wx.createIntersectionObserver(context)
context
.createIntersectionObserver(context)
.relativeToViewport()
.observe(selector, (res) => {
resolve(res);
Expand Down
5 changes: 0 additions & 5 deletions src/tab-panel/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ const props: TdTabPanelProps = {
badgeProps: {
type: Object,
},
/** 【实现有误,暂不支持】选项卡内容隐藏时是否销毁 */
destroyOnHide: {
type: Boolean,
value: true,
},
/** 是否禁用当前选项卡 */
disabled: {
type: Boolean,
Expand Down
8 changes: 0 additions & 8 deletions src/tab-panel/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ export interface TdTabPanelProps {
type: ObjectConstructor;
value?: object;
};
/**
* 【实现有误,暂不支持】选项卡内容隐藏时是否销毁
* @default true
*/
destroyOnHide?: {
type: BooleanConstructor;
value?: boolean;
};
/**
* 是否禁用当前选项卡
* @default false
Expand Down
3 changes: 1 addition & 2 deletions src/tabs/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ name | type | default | description | required
style | Object | - | CSS(Cascading Style Sheets) | N
custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
badge-props | Object | - | \- | N
destroy-on-hide | Boolean | true | \- | N
disabled | Boolean | false | \- | N
icon | String / Object | - | \- | N
label | String | - | \- | N
Expand Down Expand Up @@ -73,4 +72,4 @@ Name | Default Value | Description
--td-tab-track-color | @brand-color | -
--td-tab-track-radius | 8rpx | -
--td-tab-track-thickness | 6rpx | -
--td-tab-track-width | 32rpx | -
--td-tab-track-width | 32rpx | -
3 changes: 1 addition & 2 deletions src/tabs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ t-class-track | 滚动条样式类
style | Object | - | 样式 | N
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
badge-props | Object | - | 透传至 Badge 组件 | N
destroy-on-hide | Boolean | true | 【实现有误,暂不支持】选项卡内容隐藏时是否销毁 | N
disabled | Boolean | false | 是否禁用当前选项卡 | N
icon | String / Object | - | `1.0.0-rc.1`。图标,传对象则透传至 Icon | N
label | String | - | 选项卡名称 | N
Expand Down Expand Up @@ -186,4 +185,4 @@ value | String / Number | - | 选项卡的值,唯一标识。TS 类型:`TabV
--td-tab-track-color | @brand-color | -
--td-tab-track-radius | 8rpx | -
--td-tab-track-thickness | 6rpx | -
--td-tab-track-width | 32rpx | -
--td-tab-track-width | 32rpx | -
4 changes: 4 additions & 0 deletions src/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import config from '../common/config';
import touch from '../mixins/touch';
import { getRect, uniqueFactory } from '../common/utils';
import { TdTabsProps } from './type';
import { getObserver } from '../common/wechat';

const { prefix } = config;
const name = `${prefix}-tabs`;
Expand Down Expand Up @@ -215,6 +216,9 @@ export default class Tabs extends SuperComponent {
this.setData({
offset: Math.min(Math.max(offset, 0), maxOffset),
});
} else if (!this._hasObserved) {
this._hasObserved = true;
getObserver(this, `.${name}`).then(() => this.setTrack());
}

if (this.data.theme === 'line') {
Expand Down

0 comments on commit 1c0429a

Please sign in to comment.