123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <wxs src="./slider.wxs" module="t" />
- <wxs src="../common/utils.wxs" module="_" />
- <view
- style="{{_._style([style, customStyle])}}"
- class="{{_.cls(classPrefix, [['top', label || scaleTextArray.length], ['disabled', disabled], ['range', range]])}} class {{prefix}}-class"
- >
- <block wx:if="{{!range}}">
- <text wx:if="{{showExtremeValue}}" class="{{classPrefix}}__value {{classPrefix}}__value--min">
- {{ label ? t.getValue(label, min) : min}}
- </text>
- <view
- id="sliderLine"
- class="{{_.cls(classPrefix + '__bar', [['disabled', disabled], theme, ['marks', isScale && theme == 'capsule']])}} {{prefix}}-class-bar"
- style="{{t.getColor(disabled, false, disabledColor, colors)}}"
- bind:tap="onSingleLineTap"
- >
- <block wx:if="{{isScale}}">
- <view
- class="{{_.cls(classPrefix + '__scale-item', [['active', _value >= item.val], ['disabled', disabled], theme, ['hidden', (index == 0 || index == scaleArray.length - 1) && theme == 'capsule' || value == item.val]])}}"
- wx:for="{{scaleArray}}"
- wx:key="index"
- style="left:{{item.left}}px; transform: translateX(-50%); {{t.getColor(disabled, _value >= item.val, disabledColor, colors)}}"
- >
- <view wx:if="{{scaleTextArray.length}}" class="{{_.cls(classPrefix + '__scale-desc', [theme])}}}}">
- {{scaleTextArray[index]}}
- </view>
- </view>
- </block>
- <view
- class="{{_.cls(classPrefix + '__line', [['disabled', disabled], theme, 'single'])}} {{prefix}}-class-bar-active"
- style="width: {{lineBarWidth}}; {{t.getColor(disabled, true, disabledColor, colors)}}"
- >
- <view
- id="singleDot"
- class="{{classPrefix}}__dot {{prefix}}-class-cursor"
- bind:touchmove="onSingleLineTap"
- bind:touchend="onTouchEnd"
- bind:touchcancel="onTouchEnd"
- >
- <view
- class="{{_.cls(classPrefix+'__dot-value', [['sr-only', !label]])}}"
- aria-role="region"
- aria-live="assertive"
- >
- {{t.getValue(label, _value) || _value}}
- </view>
- <view
- class="{{classPrefix}}__dot-slider"
- aria-role="slider"
- aria-disabled="{{disabled}}"
- aria-valuemax="{{max}}"
- aria-valuemin="{{min}}"
- aria-valuenow="{{_value}}"
- ></view>
- </view>
- </view>
- </view>
- <!-- <view wx:if="{{label}}" class="{{classPrefix}}__value {{classPrefix}}__value--right">
- <text class="{{classPrefix}}__value--text"> {{t.getValue(label, _value)}}</text>
- </view> -->
- <text wx:if="{{showExtremeValue}}" class="{{classPrefix}}__value {{classPrefix}}__value--max">
- {{ label ? t.getValue(label, max) : max}}
- </text>
- </block>
- <!-- range选择器自定义 -->
- <block wx:if="{{range}}">
- <view wx:if="{{showExtremeValue}}" class="{{classPrefix}}__range-extreme {{classPrefix}}__range-extreme--min">
- {{min}}
- </view>
- <view
- id="sliderLine"
- bind:tap="onLineTap"
- class="{{_.cls(classPrefix + '__bar', [['disabled', disabled], theme, ['marks', isScale && theme == 'capsule']])}} {{prefix}}-class-bar"
- style="{{t.getColor(disabled, false, disabledColor, colors)}}"
- >
- <block wx:if="{{isScale}}">
- <view
- class="{{_.cls(classPrefix + '__scale-item', [['active', dotTopValue[1] >= item.val && item.val >= dotTopValue[0]], ['disabled', disabled], theme, ['hidden', (index == 0 || index == scaleArray.length - 1) && theme == 'capsule' || value == item.val]])}}"
- wx:for="{{scaleArray}}"
- wx:for-index="index"
- wx:key="index"
- style="left: {{item.left}}px; transform: translateX(-50%); {{t.getColor(disabled, (dotTopValue[1] >= item.val && item.val >= dotTopValue[0]), disabledColor, colors)}}"
- >
- <view wx:if="{{scaleTextArray.length}}" class="{{_.cls(classPrefix + '__scale-desc', [theme])}}"
- >{{scaleTextArray[index]}}</view
- >
- </view>
- </block>
- <view
- class="{{_.cls(classPrefix + '__line', [['disabled', disabled], theme])}} {{prefix}}-class-bar-active"
- style="left: {{lineLeft}}px; right: {{lineRight}}px; {{t.getColor(disabled, true, disabledColor, colors)}}"
- >
- <view
- id="leftDot"
- bind:touchmove="onTouchMoveLeft"
- bind:touchend="onTouchEnd"
- bind:touchcancel="onTouchEnd"
- class="{{classPrefix}}__dot {{classPrefix}}__dot--left {{prefix}}-class-cursor"
- >
- <view
- class="{{_.cls(classPrefix+'__dot-value', [['sr-only', !label]])}}"
- aria-role="region"
- aria-live="assertive"
- >
- {{t.getValue(label, dotTopValue[0]) || dotTopValue[0]}}
- </view>
- <view
- class="{{classPrefix}}__dot-slider"
- aria-role="slider"
- aria-disabled="{{disabled}}"
- aria-valuemax="{{t.getValue(label, dotTopValue[1]) || dotTopValue[1]}}"
- aria-valuemin="{{min}}"
- aria-valuenow="{{t.getValue(label, dotTopValue[0]) || dotTopValue[0]}}"
- ></view>
- </view>
- <view
- id="rightDot"
- bind:touchmove="onTouchMoveRight"
- bind:touchend="onTouchEnd"
- bind:touchcancel="onTouchEnd"
- class="{{classPrefix}}__dot {{classPrefix}}__dot--right {{prefix}}-class-cursor"
- >
- <view
- class="{{_.cls(classPrefix+'__dot-value', [['sr-only', !label]])}}"
- aria-role="region"
- aria-live="assertive"
- >
- {{t.getValue(label, dotTopValue[1]) || dotTopValue[1]}}
- </view>
- <view
- class="{{classPrefix}}__dot-slider"
- aria-role="slider"
- aria-disabled="{{disabled}}"
- aria-valuemax="{{max}}"
- aria-valuemin="{{t.getValue(label, dotTopValue[0]) || dotTopValue[0]}}"
- aria-valuenow="{{t.getValue(label, dotTopValue[1]) || dotTopValue[1]}}"
- >
- </view>
- </view>
- </view>
- </view>
- <view wx:if="{{showExtremeValue}}" class="{{classPrefix}}__range-extreme {{classPrefix}}__range-extreme--max">
- {{max}}
- </view>
- </block>
- </view>
|