提交
This commit is contained in:
1
甲情_甲意/miniprogram/node_modules/antd-mini/es/IndexBar/index.acss
generated
vendored
Normal file
1
甲情_甲意/miniprogram/node_modules/antd-mini/es/IndexBar/index.acss
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
.ant-indexbar-side{z-index:9}.ant-indexbar-side-mask{position:fixed;width:100vw;height:100vh;left:0;top:0;z-index:9}.ant-indexbar-side-content{width:100%;height:100%;justify-content:center;align-items:center;text-align:center}.ant-indexbar-side-item{position:relative;padding-left:10px}.ant-indexbar-side-item-default{font-size:11px;font-weight:700;color:#999;display:flex;align-items:center;justify-content:center}.ant-indexbar-side-item-tip{position:absolute;left:-105px;bottom:-18px;width:50px;height:50px;border-radius:50px;line-height:50px;text-align:center;background:#ccc;color:#fff;font-size:28px}.ant-indexbar-side-item-tip::after{content:'';position:absolute;top:-15px;right:-30px;display:block;margin:20px auto;width:0;height:0;border:20px solid transparent;border-left-color:#ccc}.ant-indexbar-side-active{border-radius:8px;background-color:#1677ff;color:#fff}.ant-indexbar-side-scroll{width:100%;height:100%;overflow:scroll;scrollbar-width:none}.ant-indexbar-side-notSee{position:fixed;left:-200%;top:0;z-index:-1}
|
64
甲情_甲意/miniprogram/node_modules/antd-mini/es/IndexBar/index.axml
generated
vendored
Normal file
64
甲情_甲意/miniprogram/node_modules/antd-mini/es/IndexBar/index.axml
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
<view
|
||||
class="ant-indexbar-side {{className}}"
|
||||
disableScroll="{{true}}"
|
||||
style="{{({ width: '' + size + 'px;' })}} {{style}}"
|
||||
hoverStopPropagation
|
||||
>
|
||||
<view
|
||||
a:if="{{showMask}}"
|
||||
class="ant-indexbar-side-mask"
|
||||
></view>
|
||||
<view class="ant-indexbar-side-content">
|
||||
<view
|
||||
class="ant-indexbar-side-item"
|
||||
catchTouchStart="onTouchStart"
|
||||
catchTouchMove="onTouchMove"
|
||||
catchTouchEnd="onTouchEnd"
|
||||
data-item="{{({ item, index })}}"
|
||||
id="{{'ant-alphabet-' + index}}"
|
||||
style="{{({ width: '' + size + 'px', height: '' + size + 'px' })}}"
|
||||
a:for="{{items}}"
|
||||
a:for-index="index"
|
||||
a:for-item="item"
|
||||
>
|
||||
<view
|
||||
style="{{({ width: '' + size + 'px', height: '' + size + 'px' })}}"
|
||||
class="ant-indexbar-side-item-default {{activeClassName}}
|
||||
{{touchKey ? touchKey === item.label ? 'ant-indexbar-side-active' : '' : index === currentKey ? 'ant-indexbar-side-active' : ''}}"
|
||||
>
|
||||
{{item.label}}
|
||||
</view>
|
||||
<view
|
||||
a:if="{{item.label === touchKey && !item.disablePreview && moving}}"
|
||||
class="ant-indexbar-side-item-tip"
|
||||
>
|
||||
{{item.label}}
|
||||
<slot
|
||||
name="labelPreview"
|
||||
value="{{item}}"
|
||||
index="{{index}}"
|
||||
></slot>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view
|
||||
a:if="{{hasDefaultSlot}}"
|
||||
scrollY
|
||||
class="ant-indexbar-side-scroll {{hasDefaultSlot && topRange.length === 0 ? 'ant-indexbar-side-notSee' : ''}}"
|
||||
scrollIntoView="{{'ant-indexbar-' + touchKey + ''}}"
|
||||
onScroll="onScroll"
|
||||
>
|
||||
<view
|
||||
class="ant-indexbar-side-list"
|
||||
id="{{'ant-indexbar-' + (item.label) + ''}}"
|
||||
a:for="{{items}}"
|
||||
a:for-index="index"
|
||||
a:for-item="item"
|
||||
>
|
||||
<slot
|
||||
value="{{item}}"
|
||||
index="{{index}}"
|
||||
></slot>
|
||||
</view>
|
||||
</scroll-view>
|
1
甲情_甲意/miniprogram/node_modules/antd-mini/es/IndexBar/index.d.ts
generated
vendored
Normal file
1
甲情_甲意/miniprogram/node_modules/antd-mini/es/IndexBar/index.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
177
甲情_甲意/miniprogram/node_modules/antd-mini/es/IndexBar/index.js
generated
vendored
Normal file
177
甲情_甲意/miniprogram/node_modules/antd-mini/es/IndexBar/index.js
generated
vendored
Normal file
@ -0,0 +1,177 @@
|
||||
import { __awaiter, __generator } from "tslib";
|
||||
import equal from 'fast-deep-equal';
|
||||
import { IndexBarDefaultProps } from './props';
|
||||
Component({
|
||||
props: IndexBarDefaultProps,
|
||||
data: {
|
||||
touchClientY: 0,
|
||||
touchKeyIndex: -1,
|
||||
touchKey: '',
|
||||
itemHeight: 16,
|
||||
moving: false,
|
||||
showMask: false,
|
||||
currentKey: 0,
|
||||
topRange: [],
|
||||
hasDefaultSlot: true,
|
||||
},
|
||||
didMount: function () {
|
||||
this.init();
|
||||
},
|
||||
didUpdate: function (_prop) {
|
||||
var _a = this.props, current = _a.current, items = _a.items;
|
||||
if (!equal(_prop.items, this.props.items)) {
|
||||
this.init();
|
||||
}
|
||||
if (_prop.current !== current) {
|
||||
var _index = items.findIndex(function (u) { return current === u.label; });
|
||||
this.setData({
|
||||
currentKey: _index,
|
||||
});
|
||||
if (!this.isControlled()) {
|
||||
this.setData({
|
||||
touchKeyIndex: _index,
|
||||
touchKey: current,
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init: function () {
|
||||
var _a = this.props, defaultCurrent = _a.defaultCurrent, current = _a.current, items = _a.items;
|
||||
this.initItemHeight();
|
||||
this.initTopRange();
|
||||
var initCurrent = this.isControlled() ? current : defaultCurrent;
|
||||
var _index = items.findIndex(function (u) { return initCurrent === u.label; });
|
||||
this.setData({
|
||||
currentKey: _index,
|
||||
touchKeyIndex: _index,
|
||||
touchKey: initCurrent,
|
||||
});
|
||||
},
|
||||
isControlled: function (valueKey) {
|
||||
if (valueKey === void 0) { valueKey = 'current'; }
|
||||
if ('controlled' in this.props) {
|
||||
return this.props.controlled;
|
||||
}
|
||||
return valueKey in this.props;
|
||||
},
|
||||
// 初始化每个块的高度,用已计算滑动距离
|
||||
initItemHeight: function () {
|
||||
var _this = this;
|
||||
my.createSelectorQuery()
|
||||
.select("#ant-alphabet-0")
|
||||
.boundingClientRect()
|
||||
.exec(function (ret) {
|
||||
if (ret[0] === null)
|
||||
throw new Error('找不到Indexbar元素');
|
||||
var height = ret[0].height;
|
||||
_this.setData({ itemHeight: height });
|
||||
});
|
||||
},
|
||||
onTouchStart: function (e) {
|
||||
var moving = this.data.moving;
|
||||
var items = this.props.items;
|
||||
if (moving)
|
||||
return;
|
||||
var _a = e.target.dataset.item, item = _a.item, index = _a.index;
|
||||
var point = (e && e.touches && e.touches[0]) || {};
|
||||
var clientY = point.clientY;
|
||||
this.setData({
|
||||
touchClientY: clientY,
|
||||
touchKeyIndex: index,
|
||||
touchKey: items[index].label,
|
||||
moving: true,
|
||||
showMask: true,
|
||||
currentKey: index,
|
||||
});
|
||||
this.onAlphabetClick(item, index); // 触摸开始
|
||||
},
|
||||
onAlphabetClick: function (item, index) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, vibrate, onChange, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0:
|
||||
_a = this.props, vibrate = _a.vibrate, onChange = _a.onChange;
|
||||
_b = vibrate;
|
||||
if (!_b) return [3 /*break*/, 2];
|
||||
return [4 /*yield*/, my.vibrateShort()];
|
||||
case 1:
|
||||
_b = (_c.sent());
|
||||
_c.label = 2;
|
||||
case 2:
|
||||
_b;
|
||||
onChange(item, index);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
onTouchEnd: function () {
|
||||
// 没进入moving状态就不处理
|
||||
if (!this.data.moving)
|
||||
return;
|
||||
this.setData({
|
||||
touchKeyIndex: -1,
|
||||
touchKey: '',
|
||||
showMask: false,
|
||||
moving: false,
|
||||
});
|
||||
},
|
||||
onTouchMove: function (e) {
|
||||
var _a = this.data, touchClientY = _a.touchClientY, touchKeyIndex = _a.touchKeyIndex, itemHeight = _a.itemHeight, touchKey = _a.touchKey;
|
||||
var items = this.props.items;
|
||||
var point = e.changedTouches[0];
|
||||
var movePageY = point.clientY;
|
||||
// 滑动距离
|
||||
var movingHeight = Math.abs(movePageY - touchClientY);
|
||||
// 滑动几个itemHeight的距离即等于滑动了几格,不那么精准,但是几乎可以忽略不计
|
||||
var movingNum = parseInt("".concat(movingHeight / itemHeight), 10);
|
||||
// 上 or 下
|
||||
var isUp = movePageY < touchClientY;
|
||||
// 新的触发的索引应该在哪个index
|
||||
var newIndex = isUp
|
||||
? touchKeyIndex - movingNum
|
||||
: touchKeyIndex + movingNum;
|
||||
// 超出索引列表范围 or 索引没变化return
|
||||
if (!items[newIndex] || touchKey === items[newIndex].label)
|
||||
return;
|
||||
// 结算
|
||||
this.setData({ touchKey: items[newIndex].label, currentKey: newIndex });
|
||||
this.onAlphabetClick(items[newIndex], newIndex);
|
||||
},
|
||||
onScroll: function (e) {
|
||||
var _a = this.data, topRange = _a.topRange, currentKey = _a.currentKey, moving = _a.moving;
|
||||
var items = this.props.items;
|
||||
var scrollTop = e.detail.scrollTop;
|
||||
var newIndex = 0;
|
||||
if (scrollTop + 1 > topRange[topRange.length - 1]) {
|
||||
newIndex = topRange.length;
|
||||
}
|
||||
else {
|
||||
newIndex = topRange.findIndex(function (h) { return scrollTop + 1 < h; });
|
||||
}
|
||||
if (currentKey !== newIndex - 1 && newIndex - 1 >= 0 && !moving) {
|
||||
this.setData({
|
||||
currentKey: newIndex - 1,
|
||||
touchKeyIndex: newIndex - 1,
|
||||
touchKey: items[newIndex - 1].label,
|
||||
});
|
||||
this.onAlphabetClick(items[newIndex - 1], newIndex - 1);
|
||||
}
|
||||
},
|
||||
initTopRange: function () {
|
||||
var _this = this;
|
||||
my.createSelectorQuery()
|
||||
.selectAll('.ant-indexbar-side-list')
|
||||
.boundingClientRect()
|
||||
.exec(function (ret) {
|
||||
var arr = [];
|
||||
ret[0].forEach(function (u) {
|
||||
arr.push(u.top - ret[0][0].top);
|
||||
});
|
||||
_this.setData({ topRange: arr, hasDefaultSlot: !!ret[0][0].height });
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
3
甲情_甲意/miniprogram/node_modules/antd-mini/es/IndexBar/index.json
generated
vendored
Normal file
3
甲情_甲意/miniprogram/node_modules/antd-mini/es/IndexBar/index.json
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
37
甲情_甲意/miniprogram/node_modules/antd-mini/es/IndexBar/props.d.ts
generated
vendored
Normal file
37
甲情_甲意/miniprogram/node_modules/antd-mini/es/IndexBar/props.d.ts
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
import { IBaseProps } from '../_util/base';
|
||||
interface ItemObj {
|
||||
label: string;
|
||||
disablePreview?: boolean;
|
||||
}
|
||||
export interface IndexBarProps extends IBaseProps {
|
||||
/**
|
||||
* @description 触发的索引样式
|
||||
*/
|
||||
activeClassName: string;
|
||||
/**
|
||||
* @description 默认触发的索引
|
||||
*/
|
||||
defaultCurrent: string;
|
||||
/**
|
||||
* @description 触发的索引
|
||||
*/
|
||||
current: string;
|
||||
/**
|
||||
* @description 索引触发时是否震动
|
||||
*/
|
||||
vibrate: boolean;
|
||||
/**
|
||||
* @description 索引列表
|
||||
*/
|
||||
items: ItemObj[];
|
||||
/**
|
||||
* @description 索引的尺寸
|
||||
*/
|
||||
size: number;
|
||||
/**
|
||||
* @description 触发索引时的回调
|
||||
*/
|
||||
onChange: (value: ItemObj, index: number) => void;
|
||||
}
|
||||
export declare const IndexBarDefaultProps: Partial<IndexBarProps>;
|
||||
export {};
|
10
甲情_甲意/miniprogram/node_modules/antd-mini/es/IndexBar/props.js
generated
vendored
Normal file
10
甲情_甲意/miniprogram/node_modules/antd-mini/es/IndexBar/props.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
export var IndexBarDefaultProps = {
|
||||
className: '',
|
||||
activeClassName: '',
|
||||
defaultCurrent: null,
|
||||
vibrate: true,
|
||||
items: [],
|
||||
size: 16,
|
||||
style: '',
|
||||
onChange: function (value, index) { },
|
||||
};
|
Reference in New Issue
Block a user