mini-antui
Advanced tools
Comparing version 0.4.2-alpha.1 to 0.4.2
@@ -5,3 +5,3 @@ import fmtEvent from '../_util/fmtEvent'; | ||
props: { | ||
props: 'number', | ||
type: 'number', | ||
className: '', | ||
@@ -8,0 +8,0 @@ focus: false, |
Component({ | ||
data: { | ||
tabTop: 0, | ||
current: 0, | ||
wrapScrollTop: 0 | ||
}, | ||
props: { | ||
activeTab: 0, | ||
className: '', | ||
@@ -25,4 +25,6 @@ tabs: [], | ||
}, | ||
didUpdate: function didUpdate() { | ||
this.calcHeight(); | ||
didUpdate: function didUpdate(prevProps) { | ||
if (this.props.tabs.length !== prevProps.tabs.length) { | ||
this.calcHeight(); | ||
} | ||
}, | ||
@@ -40,5 +42,8 @@ didUnmount: function didUnmount() { | ||
var tabs = this.props.tabs; | ||
var _props = this.props, | ||
tabs = _props.tabs, | ||
activeTab = _props.activeTab; | ||
this.anchorMap = {}; | ||
this.indexMap = {}; | ||
this.wrapHeight = 0; | ||
@@ -59,2 +64,8 @@ this.scrollWrapHeight = 0; | ||
_this.anchorMap[anchor] = cacheHeight; | ||
_this.indexMap[i] = cacheHeight; | ||
if (activeTab === i) { | ||
_this.setData({ | ||
wrapScrollTop: _this.indexMap[i] | ||
}); | ||
} | ||
cacheHeight += ret[0].height; | ||
@@ -76,8 +87,7 @@ _this.scrollWrapHeight = cacheHeight; | ||
if (!this.isScrolling || !this.props.swipeable) { | ||
if (this.data.current !== index) { | ||
if (this.props.activeTab !== index) { | ||
this.props.onTabClick(index); | ||
} | ||
this.setData({ | ||
wrapScrollTop: this.anchorMap[anchor], | ||
current: index | ||
wrapScrollTop: this.anchorMap[anchor] | ||
}); | ||
@@ -95,4 +105,8 @@ this.moveScrollBar(index); | ||
} | ||
if (this.data.current !== current) { | ||
this.props.onScrollBar(current); | ||
if (this.props.activeTab !== current) { | ||
if (this.props.onChange) { | ||
this.props.onChange(current); | ||
} else { | ||
this.props.onScrollBar(current); | ||
} | ||
} | ||
@@ -99,0 +113,0 @@ this.setData({ |
{ | ||
"name": "mini-antui", | ||
"version": "0.4.2-alpha.1", | ||
"version": "0.4.2", | ||
"description": "小程序版AntUI", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
127455
1746
1