Skip to content

Commit

Permalink
fix(range): 适配百度
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczj committed Jan 30, 2019
1 parent 78bb287 commit 8e4e8eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 13 additions & 0 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ function getEventDetail (event: any) {
}
break

case Taro.ENV_TYPE.SWAN:
detail = {
pageX: event.changedTouches[0].pageX,
pageY: event.changedTouches[0].pageY,
clientX: event.target.clientX,
clientY: event.target.clientY,
offsetX: event.target.offsetLeft,
offsetY: event.target.offsetTop,
x: event.detail.x,
y: event.detail.y
}
break

default:
detail = {
pageX: 0,
Expand Down
9 changes: 4 additions & 5 deletions src/components/range/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import Taro from '@tarojs/taro'
import PropTypes from 'prop-types'
import { View } from '@tarojs/components'
import classNames from 'classnames'
import { uuid, delayQuerySelector, getEventDetail, isTest } from '../../common/utils'
import { delayQuerySelector, getEventDetail } from '../../common/utils'
import AtComponent from '../../common/component'


export default class AtRange extends AtComponent {
constructor (props) {
super(...arguments)
Expand All @@ -15,7 +16,6 @@ export default class AtRange extends AtComponent {
this.left = 0
this.deltaValue = max - min
this.currentSlider = ''
this.rangeId = isTest() ? 'range-AOTU2018' : uuid()
this.state = {
aX: 0,
bX: 0
Expand Down Expand Up @@ -90,9 +90,8 @@ export default class AtRange extends AtComponent {
}

componentDidMount () {
// 获取 range 宽度
const { value } = this.props
delayQuerySelector(this, `#${this.rangeId}`, 0)
delayQuerySelector(this, '.at-range__container', 0)
.then(rect => {
this.width = Math.round(rect[0].width)
this.left = Math.round(rect[0].left)
Expand Down Expand Up @@ -140,7 +139,7 @@ export default class AtRange extends AtComponent {
}

return <View className={rootCls} style={customStyle} onClick={this.handleClick}>
<View id={this.rangeId} className='at-range__container'style={containerStyle}>
<View className='at-range__container' style={containerStyle}>
<View className='at-range__rail' style={railStyle}></View>
<View className='at-range__track' style={this.mergeStyle(atTrackStyle, trackStyle)}></View>
<View
Expand Down

0 comments on commit 8e4e8eb

Please sign in to comment.