提交
This commit is contained in:
1
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/index.acss
generated
vendored
Normal file
1
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/index.acss
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
.ant-slider{user-select:none;width:100%}.ant-slider-track{position:relative;width:100%;height:28px;background-color:#fff}.ant-slider-track-number{height:48.5px}.ant-slider-track-touch-area{position:absolute;left:14px;top:0;right:12.5px;height:100%}.ant-slider-track-fill{position:absolute;left:0;top:12.5px;right:0;height:3px}.ant-slider-track-fill-background{position:absolute;background-color:#f5f5f5;width:100%;height:100%;border-radius:1.5px}.ant-slider-track-fill-front{position:absolute;height:100%;border-radius:1.5px;background-color:#1677ff}.ant-slider-handler{position:absolute;touch-action:none;left:0;transform:translate(-50%,-50%);top:1.5px}.ant-slider-handler-block{width:28px;height:28px;background:#fff;box-shadow:0 2px 5px 0 rgba(0,0,0,.12);border-radius:28px;text-align:center;line-height:28px;color:#1677ff}.ant-slider-handler-icon-default{position:absolute;top:0;left:0;right:0;bottom:0}.ant-slider-handler-icon-default-line1{position:absolute;width:2px;height:8px;background-color:#1677ff;border-radius:1px;top:10px;left:8px}.ant-slider-handler-icon-default-line2{position:absolute;width:2px;height:12px;background-color:#1677ff;border-radius:1px;top:8px;right:13px}.ant-slider-handler-icon-default-line3{position:absolute;width:2px;height:8px;background-color:#1677ff;border-radius:1px;top:10px;right:8px}.ant-slider-handler-icon-from-props{position:absolute;top:0;left:0;right:0;bottom:0;text-align:center;line-height:100%}.ant-slider-handler-icon-from-props-icon{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}.ant-slider-tick{position:absolute;width:8px;height:8px;border-radius:8px;top:1.5px;transform:translate(-50%,-50%)}.ant-slider-tick-front{background-color:#1677ff}.ant-slider-tick-back{background-color:#f5f5f5}.ant-slider-tick-number{position:absolute;color:#333;font-size:12px;transform:translateX(-50%);top:22px;left:4px;text-align:center;line-height:16.5px;height:16.5px}
|
94
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/index.axml
generated
vendored
Normal file
94
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/index.axml
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
<import-sjs
|
||||
from="./index.sjs"
|
||||
name="sliderSjs"
|
||||
></import-sjs>
|
||||
<template name="slider-handler">
|
||||
<view
|
||||
class="ant-slider-handler"
|
||||
style="left: {{position}}%"
|
||||
>
|
||||
<popover
|
||||
placement="top"
|
||||
visible="{{showTooltip}}"
|
||||
showMask="{{false}}"
|
||||
>
|
||||
<slot name="slider">
|
||||
<view class="ant-slider-handler-block">
|
||||
<view class="ant-slider-handler-icon-default">
|
||||
<view class="ant-slider-handler-icon-default-line1"></view>
|
||||
<view class="ant-slider-handler-icon-default-line2"></view>
|
||||
<view class="ant-slider-handler-icon-default-line3"></view>
|
||||
</view>
|
||||
</view>
|
||||
</slot>
|
||||
<view
|
||||
slot="content"
|
||||
class="ant-slider-tooltip-content"
|
||||
>
|
||||
<slot
|
||||
name="tooltip"
|
||||
value="{{value}}"
|
||||
>
|
||||
{{value}}
|
||||
</slot>
|
||||
</view>
|
||||
</popover>
|
||||
</view>
|
||||
</template>
|
||||
<view
|
||||
class="ant-slider {{className ? className : ''}}"
|
||||
style="opacity: {{disabled ? '0.4' : '1'}};"
|
||||
>
|
||||
<view class="ant-slider-track {{showNumber ? 'ant-slider-track-number' : ''}}">
|
||||
<view
|
||||
class="ant-slider-track-touch-area"
|
||||
id="ant-slider-id-{{$id || ''}}"
|
||||
onTouchStart="handleTrackTouchStart"
|
||||
onTouchEnd="handleTrackTouchEnd"
|
||||
onTouchMove="handleTrackTouchMove"
|
||||
>
|
||||
<view class="ant-slider-track-fill">
|
||||
<view class="ant-slider-track-fill-background"></view>
|
||||
<view
|
||||
class="ant-slider-track-fill-front {{activeLineClassName || ''}}"
|
||||
style="width: {{sliderWidth}}%; left: {{sliderLeft}}%; {{activeLineStyle || ''}}"
|
||||
></view>
|
||||
<view class="ant-slider-showTicks">
|
||||
<block
|
||||
a:for="{{tickList}}"
|
||||
a:for-index="index"
|
||||
a:for-item="item"
|
||||
>
|
||||
<view
|
||||
class="ant-slider-tick ant-slider-tick-{{sliderSjs.isFrontTick(item, sliderLeft, sliderWidth) ? 'front' : 'back'}} {{sliderSjs.isFrontTick(item, sliderLeft, sliderWidth) && activeDotClassName ? activeDotClassName : ''}}"
|
||||
style="left: {{item.left}}%;{{sliderSjs.isFrontTick(item, sliderLeft, sliderWidth) && activeDotStyle ? activeDotStyle : ''}}"
|
||||
>
|
||||
<view
|
||||
a:if="{{showNumber}}"
|
||||
class="ant-slider-tick-number"
|
||||
>
|
||||
<slot
|
||||
name="tick"
|
||||
value="{{item.value}}"
|
||||
>
|
||||
{{item.value}}
|
||||
</slot>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<block a:if="{{range}}">
|
||||
<template
|
||||
is="slider-handler"
|
||||
data="{{ position: sliderLeft, icon: icon, value: mixin.value[0], showTooltip: changingStart && showTooltip }}"
|
||||
></template>
|
||||
</block>
|
||||
<template
|
||||
is="slider-handler"
|
||||
data="{{ position: sliderLeft + sliderWidth, icon: icon, value: range ? mixin.value[1] : mixin.value, showTooltip: changingEnd && showTooltip }}"
|
||||
></template>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view></view>
|
||||
</view>
|
1
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/index.d.ts
generated
vendored
Normal file
1
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/index.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
270
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/index.js
generated
vendored
Normal file
270
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/index.js
generated
vendored
Normal file
@ -0,0 +1,270 @@
|
||||
import { __awaiter, __generator } from "tslib";
|
||||
import { Component, triggerEvent, getValueFromProps } from '../_util/simply';
|
||||
import equal from 'fast-deep-equal';
|
||||
import { getInstanceBoundingClientRect } from '../_util/jsapi/get-instance-bounding-client-rect';
|
||||
import { sliderDefaultProps } from './props';
|
||||
import createValue from '../mixins/value';
|
||||
Component(sliderDefaultProps, {
|
||||
getInstance: function () {
|
||||
if (this.$id) {
|
||||
return my;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
formatValue: function (val) {
|
||||
var _a = getValueFromProps(this, [
|
||||
'min',
|
||||
'max',
|
||||
'step',
|
||||
'range',
|
||||
]), min = _a[0], max = _a[1], step = _a[2], range = _a[3];
|
||||
var value = this.fitSliderValue(val, min, max, step, range);
|
||||
value = this.getRoundedValue(value, step);
|
||||
return value;
|
||||
},
|
||||
getRoundedValue: function (value, step) {
|
||||
if (step === void 0) { step = 1; }
|
||||
if (value === undefined) {
|
||||
return 0;
|
||||
}
|
||||
if (typeof value === 'number') {
|
||||
return Math.round(value / step) * step;
|
||||
}
|
||||
return [
|
||||
Math.round(value[0] / step) * step,
|
||||
Math.round(value[1] / step) * step,
|
||||
];
|
||||
},
|
||||
setSliderStyleByValue: function (roundedValue) {
|
||||
var leftValue = 0;
|
||||
var rightValue = 0;
|
||||
var _a = getValueFromProps(this, [
|
||||
'min',
|
||||
'max',
|
||||
]), minFromProps = _a[0], maxFromProps = _a[1];
|
||||
var max = maxFromProps !== null && maxFromProps !== void 0 ? maxFromProps : sliderDefaultProps.max;
|
||||
var min = minFromProps !== null && minFromProps !== void 0 ? minFromProps : sliderDefaultProps.min;
|
||||
if (roundedValue !== undefined) {
|
||||
if (typeof roundedValue === 'number') {
|
||||
leftValue = min;
|
||||
rightValue = roundedValue;
|
||||
}
|
||||
else {
|
||||
leftValue = roundedValue[0];
|
||||
rightValue = roundedValue[1];
|
||||
}
|
||||
}
|
||||
// FIX_ME when min and max is equal
|
||||
var width = ((rightValue - leftValue) / (max - min)) * 100;
|
||||
var left = ((leftValue - min) / (max - min)) * 100;
|
||||
this.setData({
|
||||
sliderLeft: left,
|
||||
sliderWidth: width,
|
||||
});
|
||||
},
|
||||
setTickList: function () {
|
||||
var _a = getValueFromProps(this, [
|
||||
'step',
|
||||
'min',
|
||||
'max',
|
||||
'showTicks',
|
||||
]), step = _a[0], min = _a[1], max = _a[2], showTicks = _a[3];
|
||||
if (!showTicks) {
|
||||
return;
|
||||
}
|
||||
var tickList = [];
|
||||
var stepCount = (max - min) / step;
|
||||
for (var i = 0; i <= stepCount; i += 1) {
|
||||
tickList.push({
|
||||
left: i * (100 / stepCount),
|
||||
value: i * step + min,
|
||||
});
|
||||
}
|
||||
this.setData({
|
||||
tickList: tickList,
|
||||
});
|
||||
},
|
||||
onTouchChanged: function (e, type) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var changeMoving, rect, _a, min, max, range, touchPosition, value, currentValue, leftValue, rightValue, leftDistance, rightDistance, isFarFromLeft, farValue;
|
||||
var _this = this;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
if (getValueFromProps(this, 'disabled')) {
|
||||
return [2 /*return*/];
|
||||
}
|
||||
changeMoving = function (params) {
|
||||
var newParams = {};
|
||||
for (var key in params) {
|
||||
if (params[key] !== _this.data[key]) {
|
||||
newParams[key] = params[key];
|
||||
}
|
||||
}
|
||||
if (Object.keys(newParams).length > 0) {
|
||||
_this.setData(newParams);
|
||||
}
|
||||
};
|
||||
return [4 /*yield*/, this.getRect(e)];
|
||||
case 1:
|
||||
rect = _b.sent();
|
||||
if (!rect)
|
||||
return [2 /*return*/];
|
||||
_a = getValueFromProps(this, [
|
||||
'min',
|
||||
'max',
|
||||
'range',
|
||||
]), min = _a[0], max = _a[1], range = _a[2];
|
||||
touchPosition = (rect.touch.pageX - rect.element.left) / rect.element.width;
|
||||
value = min + touchPosition * (max - min);
|
||||
if (!range) {
|
||||
this.update(value, {}, !this.isControlled(), true);
|
||||
changeMoving({ changingEnd: true });
|
||||
}
|
||||
else {
|
||||
currentValue = this.getValue();
|
||||
leftValue = currentValue[0];
|
||||
rightValue = currentValue[1];
|
||||
leftDistance = Math.abs(leftValue - value);
|
||||
rightDistance = Math.abs(rightValue - value);
|
||||
isFarFromLeft = leftDistance > rightDistance;
|
||||
farValue = isFarFromLeft ? leftValue : rightValue;
|
||||
this.update([value, farValue], {}, !this.isControlled(), 'onChange');
|
||||
if (isFarFromLeft) {
|
||||
changeMoving({ changingEnd: true });
|
||||
}
|
||||
else {
|
||||
changeMoving({ changingStart: true });
|
||||
}
|
||||
}
|
||||
if (type === 'end') {
|
||||
changeMoving({ changingEnd: false, changingStart: false });
|
||||
triggerEvent(this, 'afterChange', this.getValue(), e);
|
||||
}
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
getRect: function (e) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var element, touch;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, getInstanceBoundingClientRect(this.getInstance(), "#ant-slider-id-".concat(this.$id || ''))];
|
||||
case 1:
|
||||
element = _a.sent();
|
||||
touch = e.changedTouches[0];
|
||||
if (element) {
|
||||
return [2 /*return*/, {
|
||||
touch: {
|
||||
pageX: touch.pageX,
|
||||
},
|
||||
element: {
|
||||
left: element.left,
|
||||
width: element.width,
|
||||
},
|
||||
}];
|
||||
}
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
cloneSliderValue: function (value) {
|
||||
if (typeof value === 'object') {
|
||||
return [value[0], value[1]];
|
||||
}
|
||||
return value;
|
||||
},
|
||||
isSliderValueEqual: function (value1, value2) {
|
||||
if (value1 === value2) {
|
||||
return true;
|
||||
}
|
||||
if (value1 === undefined || value2 === undefined) {
|
||||
return false;
|
||||
}
|
||||
if (typeof value1 === 'number' || typeof value2 == 'number') {
|
||||
return value1 === value2;
|
||||
}
|
||||
if (value1[0] === value2[0] && value1[1] === value2[1]) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
fitSliderValue: function (value, min, max, step, isRange) {
|
||||
if (value === undefined || value === null) {
|
||||
if (isRange) {
|
||||
return [min, min];
|
||||
}
|
||||
else {
|
||||
return min !== null && min !== void 0 ? min : 0;
|
||||
}
|
||||
}
|
||||
if (typeof value === 'number') {
|
||||
if (value > max) {
|
||||
return max;
|
||||
}
|
||||
if (value < min) {
|
||||
return min;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
var leftValue = Math.min(value[0], value[1]);
|
||||
var rightValue = Math.max(value[0], value[1]);
|
||||
return [
|
||||
Math.max(min, leftValue),
|
||||
Math.min(max, rightValue),
|
||||
];
|
||||
},
|
||||
handleTrackTouchStart: function (e) {
|
||||
this.onTouchChanged(e, 'start');
|
||||
},
|
||||
handleTrackTouchMove: function (e) {
|
||||
this.onTouchChanged(e, 'move');
|
||||
},
|
||||
handleTrackTouchEnd: function (e) {
|
||||
this.onTouchChanged(e, 'end');
|
||||
},
|
||||
}, {
|
||||
sliderLeft: 0,
|
||||
sliderWidth: 0,
|
||||
tickList: [],
|
||||
changingStart: false,
|
||||
changingEnd: false,
|
||||
}, [
|
||||
createValue({
|
||||
transformValue: function (val, extra, needUpdate, emit) {
|
||||
if (needUpdate === void 0) { needUpdate = true; }
|
||||
var value = this.formatValue(val);
|
||||
if (needUpdate) {
|
||||
this.setSliderStyleByValue(value);
|
||||
this.setTickList();
|
||||
}
|
||||
this.onChangeValue =
|
||||
typeof this.onChangeValue === 'undefined'
|
||||
? this.getValue()
|
||||
: this.onChangeValue;
|
||||
if (emit && !this.isSliderValueEqual(this.onChangeValue, value)) {
|
||||
this.onChangeValue = value;
|
||||
triggerEvent(this, 'change', value);
|
||||
}
|
||||
return {
|
||||
value: value,
|
||||
needUpdate: needUpdate,
|
||||
};
|
||||
},
|
||||
}),
|
||||
], {
|
||||
onChangeValue: undefined,
|
||||
didUpdate: function (prevProps) {
|
||||
var _a = getValueFromProps(this, ['min', 'max', 'step', 'range', 'showTicks', 'value']), min = _a[0], max = _a[1], step = _a[2], range = _a[3], showTicks = _a[4], value = _a[5];
|
||||
if (!equal(min, prevProps.min) ||
|
||||
!equal(max, prevProps.max) ||
|
||||
!equal(step, prevProps.step) ||
|
||||
!equal(range, prevProps.range) ||
|
||||
!equal(showTicks, prevProps.showTicks)) {
|
||||
this.update(value);
|
||||
}
|
||||
},
|
||||
});
|
6
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/index.json
generated
vendored
Normal file
6
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/index.json
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"popover": "../Popover/index"
|
||||
}
|
||||
}
|
6
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/index.sjs
generated
vendored
Normal file
6
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/index.sjs
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
var isFrontTick = function isFrontTick(item, sliderLeft, sliderWidth) {
|
||||
return item.left >= sliderLeft && item.left <= sliderLeft + sliderWidth;
|
||||
};
|
||||
export default {
|
||||
isFrontTick: isFrontTick
|
||||
};
|
78
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/props.d.ts
generated
vendored
Normal file
78
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/props.d.ts
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
import { IBaseProps } from '../_util/base';
|
||||
/**
|
||||
* @description 滑块
|
||||
*/
|
||||
export type SliderValue = number | [number, number];
|
||||
export interface ISliderProps extends IBaseProps {
|
||||
/**
|
||||
* @description 当前值
|
||||
*/
|
||||
value: SliderValue;
|
||||
defaultValue: SliderValue;
|
||||
/**
|
||||
* @description 是否禁用
|
||||
* @default false
|
||||
*/
|
||||
disabled?: boolean;
|
||||
/**
|
||||
* @description 最大值
|
||||
* @default 100
|
||||
*/
|
||||
max: number;
|
||||
/**
|
||||
* @description 最小值
|
||||
* @default 0
|
||||
*/
|
||||
min: number;
|
||||
/**
|
||||
* @description 是否是双滑块
|
||||
* @default false
|
||||
*/
|
||||
range: boolean;
|
||||
/**
|
||||
* @description 是否展示刻度上的数据
|
||||
* @default false
|
||||
*/
|
||||
showNumber: boolean;
|
||||
/**
|
||||
* @description 步距,取值必须大于 0,并且可被 (max - min) 整除。当 marks 不为空对象时,step 的配置失效
|
||||
* @default 1
|
||||
*/
|
||||
step: number;
|
||||
/**
|
||||
* @description 是否显示刻度
|
||||
* @default false
|
||||
*/
|
||||
showTicks: boolean;
|
||||
/**
|
||||
* @description 是否在拖动时显示悬浮提示
|
||||
* @default false
|
||||
*/
|
||||
showTooltip: boolean;
|
||||
/**
|
||||
* @deprecated 选中线条的样式
|
||||
*/
|
||||
activeLineStyle?: string;
|
||||
/**
|
||||
* @description 选中线条的样式
|
||||
*/
|
||||
activeDotStyle?: string;
|
||||
/**
|
||||
* @description 选中线条的样式
|
||||
* @default '''
|
||||
*/
|
||||
activeLineClassName?: string;
|
||||
/**
|
||||
* @description 选中小圆点的类名
|
||||
*/
|
||||
activeDotClassName?: string;
|
||||
/**
|
||||
* @description 输入变化的时候触发, 参数为滑动组件的当前值
|
||||
*/
|
||||
onChange: (value: SliderValue, event: any) => void;
|
||||
/**
|
||||
* @description 与 touchend 触发时机一致,把当前值作为参数传入
|
||||
*/
|
||||
onAfterChange: (value: SliderValue, event: any) => void;
|
||||
}
|
||||
export declare const sliderDefaultProps: Partial<ISliderProps>;
|
16
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/props.js
generated
vendored
Normal file
16
甲情_甲意/miniprogram/node_modules/antd-mini/es/Slider/props.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
export var sliderDefaultProps = {
|
||||
value: null,
|
||||
defaultValue: null,
|
||||
disabled: false,
|
||||
max: 100,
|
||||
min: 0,
|
||||
range: false,
|
||||
showNumber: false,
|
||||
step: 1,
|
||||
showTicks: false,
|
||||
showTooltip: false,
|
||||
activeLineStyle: '',
|
||||
activeDotStyle: '',
|
||||
activeLineClassName: '',
|
||||
activeDotClassName: '',
|
||||
};
|
Reference in New Issue
Block a user