Skip to content

Commit

Permalink
Reresh cache after update
Browse files Browse the repository at this point in the history
Close #121
  • Loading branch information
yesmeck committed Jun 27, 2018
1 parent a6b82cd commit 641fb96
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/SwipeableTabBarMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,8 @@ export default {
const { totalDelta, vertical } = this.cache;
setPxStyle(this.swipeNode, totalDelta, vertical);
},
componentDidMount() {
const { swipe, nav } = this;
const { tabBarPosition, pageSize, panels, activeKey } = this.props;
this.swipeNode = ReactDOM.findDOMNode(swipe); // dom which scroll (9999px)
this.realNode = ReactDOM.findDOMNode(nav); // dom which visiable in screen (viewport)
setCache() {
const { tabBarPosition, pageSize, panels } = this.props;
const _isVertical = isVertical(tabBarPosition);
const _viewSize = getStyle(this.realNode, _isVertical ? 'height' : 'width');
const _tabWidth = _viewSize / pageSize;
Expand All @@ -99,13 +96,23 @@ export default {
totalAvaliableDelta: _tabWidth * panels.length - _viewSize,
tabWidth: _tabWidth,
};
},
componentDidMount() {
const { swipe, nav } = this;
const { activeKey } = this.props;
this.swipeNode = ReactDOM.findDOMNode(swipe); // dom which scroll (9999px)
this.realNode = ReactDOM.findDOMNode(nav); // dom which visiable in screen (viewport)
this.setCache();
this.setSwipePositionByKey(activeKey);
},
componentWillReceiveProps(nextProps) {
if (nextProps.activeKey && nextProps.activeKey !== this.props.activeKey) {
this.setSwipePositionByKey(nextProps.activeKey);
}
},
componentDidUpdate() {
this.setCache();
},
onPan(e) {
const { vertical, totalAvaliableDelta, totalDelta } = this.cache;
const { speed } = this.props;
Expand Down

0 comments on commit 641fb96

Please sign in to comment.