123456789101112131415161718192021222324252627282930 |
- <view class="wux-class {{ classes.wrap }}" style="{{ extWrapStyle }}">
- <view class="{{ classes.min }}" wx:if="{{ common.getValue(showValue, 'min') }}">{{ min }}</view>
- <view class="{{ classes.rail }}" style="{{ extRailStyle }}">
- <block wx:for="{{ marks }}" wx:key="" wx:if="{{ showMark && marks.length > 0 }}">
- <view class="{{ classes.mark }}" style="left: {{ item + '%' }}; {{ common.getStyle(extMarkStyle, index) }}" />
- </block>
- <block wx:for="{{ sliderValue }}" wx:key="">
- <view
- class="{{ classes.track }}"
- style="{{ common.getTrackStyle(offsets, index, sliderValue.length > 1) }}; {{ common.getStyle(extTrackStyle, index) }}"
- wx:if="{{ sliderValue.length === 1 || index !== sliderValue.length - 1 }}"
- />
- <view
- class="{{ classes.handle }} {{ last === index ? prefixCls + '__handle--last' : '' }}"
- data-index="{{ index }}"
- bindtouchstart="onTouchStart"
- bindtouchmove="onTouchMove"
- bindtouchend="onTouchEnd"
- style="left: {{ offsets[index] + '%' }}; {{ common.getStyle(extHandleStyle, index) }}"
- />
- </block>
- </view>
- <view class="{{ classes.max }}" wx:if="{{ common.getValue(showValue, 'max') }}">{{ max }}</view>
- </view>
- <wxs module="common">
- module.exports.getTrackStyle = function(offsets, index, multiple) { if (!multiple) { return 'width: ' + offsets[index] + '%' } return 'left: ' + offsets[index] + '%; width: ' + (offsets[index + 1] - offsets[index]) + '%' }
- module.exports.getStyle = function(style, index) { if (style.constructor !== 'String') { return style[index] } return style }
- module.exports.getValue = function(obj, name) { if (obj.constructor === 'Object') { return obj[name] } return obj }
- </wxs>
|