Skip to content

Commit

Permalink
Merge pull request #4058 from A0150315/patch-5
Browse files Browse the repository at this point in the history
feat(h5): 使scroll-view组件在h5中支持scrollIntoView属性
  • Loading branch information
jinjinjin0731 authored Aug 7, 2019
2 parents b1db5fd + cd73e14 commit 080823f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/taro-components/src/components/scroll-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ class ScrollView extends Nerv.Component {
}
this._scrollLeft = nextProps.scrollLeft
}
// scrollIntoView
if (
nextProps.scrollIntoView &&
typeof nextProps.scrollIntoView === 'string' &&
document &&
document.querySelector &&
document.querySelector(`#${nextProps.scrollIntoView}`)
)
document.querySelector(`#${nextProps.scrollIntoView}`).scrollIntoView({
behavior: 'smooth',
block: 'center',
inline: 'start',
});
}

render() {
Expand Down

0 comments on commit 080823f

Please sign in to comment.