<template>
<uni-shadow-root class="vant-slider-index"><view :class="'custom-class '+(utils.bem('slider', { disabled }))" :style="inactiveColor ? 'background:' + inactiveColor : ''" @click="onClick">
  <view class="van-slider__bar" :style="(barStyle)+'; '+(activeColor ? 'background:' + activeColor : '')">
    <view class="van-slider__button-wrapper" @touchstart="onTouchStart" @touchmove.stop.prevent="onTouchMove" @touchend="onTouchEnd" @touchcancel="onTouchEnd">
      <slot v-if="useButtonSlot" name="button"></slot>
      <view v-else class="van-slider__button"></view>
    </view>
  </view>
</view></uni-shadow-root>
</template>
<wxs src="../wxs/utils.wxs" module="utils"></wxs>
<script>

global['__wxRoute'] = 'vant/slider/index'
"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require('./../common/component.js');
var touch_1 = require('./../mixins/touch.js');
component_1.VantComponent({
    mixins: [touch_1.touch],
    props: {
        disabled: Boolean,
        useButtonSlot: Boolean,
        activeColor: String,
        inactiveColor: String,
        max: {
            type: Number,
            value: 100
        },
        min: {
            type: Number,
            value: 0
        },
        step: {
            type: Number,
            value: 1
        },
        value: {
            type: Number,
            value: 0
        },
        barHeight: {
            type: String,
            value: '2px'
        }
    },
    watch: {
        value: function value(_value) {
            this.updateValue(_value, false);
        }
    },
    created: function created() {
        this.updateValue(this.data.value);
    },
    methods: {
        onTouchStart: function onTouchStart(event) {
            if (this.data.disabled) return;
            this.touchStart(event);
            this.startValue = this.format(this.data.value);
        },
        onTouchMove: function onTouchMove(event) {
            var _this = this;
            if (this.data.disabled) return;
            this.touchMove(event);
            this.getRect('.van-slider').then(function (rect) {
                var diff = _this.deltaX / rect.width * 100;
                _this.newValue = _this.startValue + diff;
                _this.updateValue(_this.newValue, false, true);
            });
        },
        onTouchEnd: function onTouchEnd() {
            if (this.data.disabled) return;
            this.updateValue(this.newValue, true);
        },
        onClick: function onClick(event) {
            var _this = this;
            if (this.data.disabled) return;
            this.getRect('.van-slider').then(function (rect) {
                var value = (event.detail.x - rect.left) / rect.width * 100;
                _this.updateValue(value, true);
            });
        },
        updateValue: function updateValue(value, end, drag) {
            value = this.format(value);
            this.set({
                value: value,
                barStyle: "width: " + value + "%; height: " + this.data.barHeight + ";"
            });
            if (drag) {
                this.$emit('drag', { value: value });
            }
            if (end) {
                this.$emit('change', value);
            }
        },
        format: function format(value) {
            var _a = this.data,
                max = _a.max,
                min = _a.min,
                step = _a.step;
            return Math.round(Math.max(min, Math.min(value, max)) / step) * step;
        }
    }
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LmpzIl0sIm5hbWVzIjpbIk9iamVjdCIsInZhbHVlIiwiY29tcG9uZW50XzEiLCJyZXF1aXJlIiwidG91Y2hfMSIsIm1peGlucyIsInByb3BzIiwiZGlzYWJsZWQiLCJ1c2VCdXR0b25TbG90IiwiYWN0aXZlQ29sb3IiLCJpbmFjdGl2ZUNvbG9yIiwibWF4IiwidHlwZSIsIm1pbiIsInN0ZXAiLCJiYXJIZWlnaHQiLCJ3YXRjaCIsImNyZWF0ZWQiLCJtZXRob2RzIiwib25Ub3VjaFN0YXJ0Iiwib25Ub3VjaE1vdmUiLCJfdGhpcyIsImRpZmYiLCJyZWN0Iiwib25Ub3VjaEVuZCIsIm9uQ2xpY2siLCJldmVudCIsInVwZGF0ZVZhbHVlIiwiYmFyU3R5bGUiLCJmb3JtYXQiLCJfYSIsIk1hdGgiXSwibWFwcGluZ3MiOiI7O0FBQ0FBLE9BQUFBLGNBQUFBLENBQUFBLE9BQUFBLEVBQUFBLFlBQUFBLEVBQTZDLEVBQUVDLE9BQS9DRCxJQUE2QyxFQUE3Q0E7QUFDQSxJQUFJRSxjQUFjQyxRQUFsQiwwQkFBa0JBLENBQWxCO0FBQ0EsSUFBSUMsVUFBVUQsUUFBZCxzQkFBY0EsQ0FBZDtBQUNBRCxZQUFBQSxhQUFBQSxDQUEwQjtBQUN0QkcsWUFBUSxDQUFDRCxRQURhLEtBQ2QsQ0FEYztBQUV0Qk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21tb24vY29tcG9uZW50XCIpO1xudmFyIHRvdWNoXzEgPSByZXF1aXJlKFwiLi4vbWl4aW5zL3RvdWNoXCIpO1xuY29tcG9uZW50XzEuVmFudENvbXBvbmVudCh7XG4gICAgbWl4aW5zOiBbdG91Y2hfMS50b3VjaF0sXG4gICAgcHJvcHM6IHtcbiAgICAgICAgZGlzYWJsZWQ6IEJvb2xlYW4sXG4gICAgICAgIHVzZUJ1dHRvblNsb3Q6IEJvb2xlYW4sXG4gICAgICAgIGFjdGl2ZUNvbG9yOiBTdHJpbmcsXG4gICAgICAgIGluYWN0aXZlQ29sb3I6IFN0cmluZyxcbiAgICAgICAgbWF4OiB7XG4gICAgICAgICAgICB0eXBlOiBOdW1iZXIsXG4gICAgICAgICAgICB2YWx1ZTogMTAwXG4gICAgICAgIH0sXG4gICAgICAgIG1pbjoge1xuICAgICAgICAgICAgdHlwZTogTnVtYmVyLFxuICAgICAgICAgICAgdmFsdWU6IDBcbiAgICAgICAgfSxcbiAgICAgICAgc3RlcDoge1xuICAgICAgICAgICAgdHlwZTogTnVtYmVyLFxuICAgICAgICAgICAgdmFsdWU6IDFcbiAgICAgICAgfSxcbiAgICAgICAgdmFsdWU6IHtcbiAgICAgICAgICAgIHR5cGU6IE51bWJlcixcbiAgICAgICAgICAgIHZhbHVlOiAwXG4gICAgICAgIH0sXG4gICAgICAgIGJhckhlaWdodDoge1xuICAgICAgICAgICAgdHlwZTogU3RyaW5nLFxuICAgICAgICAgICAgdmFsdWU6ICcycHgnXG4gICAgICAgIH1cbiAgICB9LFxuICAgIHdhdGNoOiB7XG4gICAgICAgIHZhbHVlOiBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgIHRoaXMudXBkYXRlVmFsdWUodmFsdWUsIGZhbHNlKTtcbiAgICAgICAgfVxuICAgIH0sXG4gICAgY3JlYXRlZDogZnVuY3Rpb24gKCkge1xuICAgICAgICB0aGlzLnVwZGF0ZVZhbHVlKHRoaXMuZGF0YS52YWx1ZSk7XG4gICAgfSxcbiAgICBtZXRob2RzOiB7XG4gICAgICAgIG9uVG91Y2hTdGFydDogZnVuY3Rpb24gKGV2ZW50KSB7XG4gICAgICAgICAgICBpZiAodGhpcy5kYXRhLmRpc2FibGVkKVxuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIHRoaXMudG91Y2hTdGFydChldmVudCk7XG4gICAgICAgICAgICB0aGlzLnN0YXJ0VmFsdWUgPSB0aGlzLmZvcm1hdCh0aGlzLmRhdGEudmFsdWUpO1xuICAgICAgICB9LFxuICAgICAgICBvblRvdWNoTW92ZTogZnVuY3Rpb24gKGV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICAgICAgaWYgKHRoaXMuZGF0YS5kaXNhYmxlZClcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB0aGlzLnRvdWNoTW92ZShldmVudCk7XG4gICAgICAgICAgICB0aGlzLmdldFJlY3QoJy52YW4tc2xpZGVyJykudGhlbihmdW5jdGlvbiAocmVjdCkge1xuICAgICAgICAgICAgICAgIHZhciBkaWZmID0gX3RoaXMuZGVsdGFYIC8gcmVjdC53aWR0aCAqIDEwMDtcbiAgICAgICAgICAgICAgICBfdGhpcy5uZXdWYWx1ZSA9IF90aGlzLnN0YXJ0VmFsdWUgKyBkaWZmO1xuICAgICAgICAgICAgICAgIF90aGlzLnVwZGF0ZVZhbHVlKF90aGlzLm5ld1ZhbHVlLCBmYWxzZSwgdHJ1ZSk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSxcbiAgICAgICAgb25Ub3VjaEVuZDogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuZGF0YS5kaXNhYmxlZClcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB0aGlzLnVwZGF0ZVZhbHVlKHRoaXMubmV3VmFsdWUsIHRydWUpO1xuICAgICAgICB9LFxuICAgICAgICBvbkNsaWNrOiBmdW5jdGlvbiAoZXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgICAgICBpZiAodGhpcy5kYXRhLmRpc2FibGVkKVxuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIHRoaXMuZ2V0UmVjdCgnLnZhbi1zbGlkZXInKS50aGVuKGZ1bmN0aW9uIChyZWN0KSB7XG4gICAgICAgICAgICAgICAgdmFyIHZhbHVlID0gKGV2ZW50LmRldGFpbC54IC0gcmVjdC5sZWZ0KSAvIHJlY3Qud2lkdGggKiAxMDA7XG4gICAgICAgICAgICAgICAgX3RoaXMudXBkYXRlVmFsdWUodmFsdWUsIHRydWUpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0sXG4gICAgICAgIHVwZGF0ZVZhbHVlOiBmdW5jdGlvbiAodmFsdWUsIGVuZCwgZHJhZykge1xuICAgICAgICAgICAgdmFsdWUgPSB0aGlzLmZvcm1hdCh2YWx1ZSk7XG4gICAgICAgICAgICB0aGlzLnNldCh7XG4gICAgICAgICAgICAgICAgdmFsdWU6IHZhbHVlLFxuICAgICAgICAgICAgICAgIGJhclN0eWxlOiBcIndpZHRoOiBcIiArIHZhbHVlICsgXCIlOyBoZWlnaHQ6IFwiICsgdGhpcy5kYXRhLmJhckhlaWdodCArIFwiO1wiXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGlmIChkcmFnKSB7XG4gICAgICAgICAgICAgICAgdGhpcy4kZW1pdCgnZHJhZycsIHsgdmFsdWU6IHZhbHVlIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGVuZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuJGVtaXQoJ2NoYW5nZScsIHZhbHVlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgZm9ybWF0OiBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgIHZhciBfYSA9IHRoaXMuZGF0YSwgbWF4ID0gX2EubWF4LCBtaW4gPSBfYS5taW4sIHN0ZXAgPSBfYS5zdGVwO1xuICAgICAgICAgICAgcmV0dXJuIE1hdGgucm91bmQoTWF0aC5tYXgobWluLCBNYXRoLm1pbih2YWx1ZSwgbWF4KSkgLyBzdGVwKSAqIHN0ZXA7XG4gICAgICAgIH1cbiAgICB9XG59KTtcbiJdLCJmaWxlIjoiaW5kZXguanMifQ==
export default global['__wxComponents']['vant/slider/index']
</script>
<style platform="mp-weixin">
@import '../common/index.css';.van-slider{position:relative;border-radius:999px;background-color:#e5e5e5}.van-slider__bar{position:relative;border-radius:inherit;background-color:#1989fa}.van-slider__button{width:20px;height:20px;border-radius:50%;background-color:#fff;box-shadow:0 1px 2px rgba(0,0,0,.5)}.van-slider__button-wrapper{position:absolute;top:50%;right:0;-webkit-transform:translate3d(50%,-50%,0);transform:translate3d(50%,-50%,0)}.van-slider__button-wrapper:after{content:"";position:absolute;width:200%;height:200%;top:-50%;left:-50%}.van-slider--disabled{opacity:.3}
</style>