Skip to content

Commit

Permalink
fix(src): 修复segment组件滚动时获取属性报错问题 (#719)
Browse files Browse the repository at this point in the history
  • Loading branch information
二一 authored Mar 22, 2020
1 parent 0256ca8 commit 0ea8407
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dist/behaviors/scrollCenter.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions dist/sticky-item/index.json
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
{
"component": true,
"usingComponents": {}
}
{"component":true,"usingComponents":{}}
2 changes: 1 addition & 1 deletion dist/sticky-item/index.wxml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<view class="l-sticky-item l-class">

<view class="l-sticky-item-header-wrapper l-header-wrapper-class" style="height:{{isFixedTop&&stickyItemWrapperHeight?stickyItemWrapperHeight+'px':'auto'}}"></view>
<view style="{{mode==='js'?(isFixedTop?'position:fixed;':''):''}} top:{{top}}rpx" class="l-sticky-item-header l-sticky-item-header{{mode==='js'?(isFixedTop?'-fixed l-header-sticky-class':''):(mode==='css'?'-sticky l-header-sticky-class':'')}} l-header-class">
<slot name="header"></slot>
Expand Down
5 changes: 1 addition & 4 deletions dist/sticky/index.json
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
{
"component": true,
"usingComponents": {}
}
{"component":true,"usingComponents":{}}
5 changes: 2 additions & 3 deletions examples/dist/behaviors/scrollCenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ export default Behavior({
});
},
queryScrollNode(res, currentIndex, type = 'width') {
if(currentIndex<0) return;
const currentRect = res[currentIndex];

this.getRect('.l-tabsscroll').then(_ => {
if(!_) return console.error('找不到元素');
const scrollWidth = _[type];

let transformDistance = res
.slice(0, currentIndex)
.reduce((prev, curr) => prev + curr[type], 0);

transformDistance += (currentRect[type] - scrollWidth) / 2;

if (type === 'width') {
Expand Down
5 changes: 2 additions & 3 deletions src/behaviors/scrollCenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ export default Behavior({
});
},
queryScrollNode(res, currentIndex, type = 'width') {
if(currentIndex<0) return;
const currentRect = res[currentIndex];

this.getRect('.l-tabsscroll').then(_ => {
if(!_) return console.error('找不到元素');
const scrollWidth = _[type];

let transformDistance = res
.slice(0, currentIndex)
.reduce((prev, curr) => prev + curr[type], 0);

transformDistance += (currentRect[type] - scrollWidth) / 2;

if (type === 'width') {
Expand Down

0 comments on commit 0ea8407

Please sign in to comment.