Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tabs): recover tab-item track #52

Merged
merged 2 commits into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/tabs/tab-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class TabPanel extends SuperComponent {
properties = props;

data = {
prefix,
classPrefix: name,
active: false,
hide: true,
Expand Down
2 changes: 1 addition & 1 deletion src/tabs/tab-panel.wxml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<wxs src="../common/utils.wxs" module="utils" />
<view
wx:if="{{!(destroyOnHide && hide)}}"
class="{{classPrefix}} {{active ? 't-is-active': ''}}"
class="{{classPrefix}} {{active ? prefix + '-is-active': ''}}"
style="{{hide ? 'display:none;' :''}}"
>
<view wx:if="{{panel}}">{{panel}}</view>
Expand Down
5 changes: 3 additions & 2 deletions src/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const trackLineWidth = 30;
export default class Tabs extends SuperComponent {
behaviors = [dom, touch];

externalClasses = ['t-class', 't-class-item', 't-class-active'];
externalClasses = [`${prefix}-class`, `${prefix}-class-item`, `${prefix}-class-active`];

relations = {
'./tab-panel': {
Expand Down Expand Up @@ -53,6 +53,7 @@ export default class Tabs extends SuperComponent {
};

data = {
prefix,
classPrefix: name,
tabs: [],
currentIndex: -1,
Expand Down Expand Up @@ -134,7 +135,7 @@ export default class Tabs extends SuperComponent {
if (!children) return;
const { currentIndex, isScrollX, direction } = this.data;
if (currentIndex <= -1) return;
this.gettingBoundingClientRect('.t-tabs-item', true).then((res: any) => {
this.gettingBoundingClientRect(`.${prefix}-tabs__item`, true).then((res: any) => {
const rect = res[currentIndex];
if (!rect) return;
let count = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/tabs/tabs.wxml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<wxs src="./tabs.wxs" module="filters" />
<view class="t-class {{classPrefix}} {{classPrefix}}--{{placement}}">
<view class="{{prefix}}-class {{classPrefix}} {{classPrefix}}--{{placement}}">
<scroll-view
class="{{classPrefix}}__scroll"
enable-flex
Expand All @@ -11,7 +11,7 @@
wx:for="{{tabs}}"
wx:key="index"
data-index="{{index}}"
class="t-class-item {{classPrefix}}__item {{item.disabled ? 't-is-disabled' : '' }} {{currentIndex === index ? 't-is-active t-class-active' : ''}}"
class="{{prefix}}-class-item {{classPrefix}}__item {{item.disabled ? (prefix + '-is-disabled') : '' }} {{currentIndex === index ? prefix + '-is-active ' + prefix + '-class-active' : ''}}"
bind:tap="onTabTap"
>
{{item.label}}
Expand Down