初始化项目, 添加TDesign等包
This commit is contained in:
3
miniprogram/miniprogram_npm/tdesign-miniprogram/pull-down-refresh/props.d.ts
vendored
Normal file
3
miniprogram/miniprogram_npm/tdesign-miniprogram/pull-down-refresh/props.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { TdPullDownRefreshProps } from './type';
|
||||
declare const props: TdPullDownRefreshProps;
|
||||
export default props;
|
||||
@@ -0,0 +1 @@
|
||||
const props={disabled:{type:Boolean,value:!1},enableBackToTop:{type:Boolean,value:!0},enablePassive:{type:Boolean,value:!1},loadingBarHeight:{type:null,value:50},loadingProps:{type:Object},loadingTexts:{type:Array,value:[]},lowerThreshold:{type:null,value:50},maxBarHeight:{type:null,value:80},refreshTimeout:{type:Number,value:3e3},scrollIntoView:{type:String,value:""},showScrollbar:{type:Boolean,value:!0},successDuration:{type:null,value:500},upperThreshold:{type:null,value:50},usingCustomNavbar:{type:Boolean,value:!1},value:{type:Boolean,value:null},defaultValue:{type:Boolean,value:!1}};export default props;
|
||||
60
miniprogram/miniprogram_npm/tdesign-miniprogram/pull-down-refresh/pull-down-refresh.d.ts
vendored
Normal file
60
miniprogram/miniprogram_npm/tdesign-miniprogram/pull-down-refresh/pull-down-refresh.d.ts
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import { RelationsOptions, SuperComponent } from '../common/src/index';
|
||||
export default class PullDownRefresh extends SuperComponent {
|
||||
pixelRatio: number;
|
||||
startPoint: {
|
||||
pageX: number;
|
||||
pageY: number;
|
||||
} | null;
|
||||
isPulling: boolean;
|
||||
maxRefreshAnimateTimeFlag: number;
|
||||
closingAnimateTimeFlag: number;
|
||||
refreshStatusTimer: any;
|
||||
externalClasses: string[];
|
||||
behaviors: string[];
|
||||
options: {
|
||||
multipleSlots: boolean;
|
||||
pureDataPattern: RegExp;
|
||||
};
|
||||
relations: RelationsOptions;
|
||||
properties: import("./type").TdPullDownRefreshProps;
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
distanceTop: number;
|
||||
barHeight: number;
|
||||
tipsHeight: number;
|
||||
refreshStatus: number;
|
||||
loosing: boolean;
|
||||
enableToRefresh: boolean;
|
||||
scrollTop: number;
|
||||
_maxBarHeight: number;
|
||||
_loadingBarHeight: number;
|
||||
};
|
||||
lifetimes: {
|
||||
attached(): void;
|
||||
detached(): void;
|
||||
};
|
||||
observers: {
|
||||
value(val: any): void;
|
||||
barHeight(val: any): void;
|
||||
maxBarHeight(v: any): void;
|
||||
loadingBarHeight(v: any): void;
|
||||
};
|
||||
methods: {
|
||||
updateDistanceTop(): void;
|
||||
resetTimer(): void;
|
||||
onScrollToBottom(): void;
|
||||
onScrollToTop(): void;
|
||||
onScroll(e: any): void;
|
||||
onTouchStart(e: WechatMiniprogram.Component.TrivialInstance): void;
|
||||
onTouchMove(e: WechatMiniprogram.Component.TrivialInstance): void;
|
||||
onTouchEnd(e: WechatMiniprogram.Component.TrivialInstance): void;
|
||||
onDragStart(e: WechatMiniprogram.ScrollViewDragStart): void;
|
||||
onDragging(e: WechatMiniprogram.ScrollViewDragging): void;
|
||||
onDragEnd(e: WechatMiniprogram.ScrollViewDragEnd): void;
|
||||
doRefresh(): void;
|
||||
setRefreshBarHeight(value: number): Promise<unknown>;
|
||||
setScrollTop(scrollTop: number): void;
|
||||
scrollToTop(): void;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
import{__decorate}from"tslib";import{getObserver}from"../common/wechat";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import props from"./props";import{getRect,systemInfo,unitConvert}from"../common/utils";import{canUseProxyScrollView}from"../common/version";const{prefix:prefix}=config,name=`${prefix}-pull-down-refresh`,defaultLoadingTexts=["下拉刷新","松手刷新","正在刷新","刷新完成"];let PullDownRefresh=class extends SuperComponent{constructor(){super(...arguments),this.pixelRatio=1,this.startPoint=null,this.isPulling=!1,this.maxRefreshAnimateTimeFlag=0,this.closingAnimateTimeFlag=0,this.refreshStatusTimer=null,this.externalClasses=[`${prefix}-class`,`${prefix}-class-loading`,`${prefix}-class-text`,`${prefix}-class-indicator`],this.behaviors=canUseProxyScrollView()?["wx://proxy-scroll-view"]:[],this.options={multipleSlots:!0,pureDataPattern:/^_/},this.relations={"../back-top/back-top":{type:"descendant"}},this.properties=props,this.data={prefix:prefix,classPrefix:name,distanceTop:0,barHeight:0,tipsHeight:0,refreshStatus:-1,loosing:!1,enableToRefresh:!0,scrollTop:0,_maxBarHeight:0,_loadingBarHeight:0},this.lifetimes={attached(){const{screenWidth:t}=systemInfo,{loadingTexts:e,maxBarHeight:s,loadingBarHeight:i}=this.properties,r=Array.isArray(e)&&e.length>=4;this.setData({_maxBarHeight:unitConvert(s),_loadingBarHeight:unitConvert(i),loadingTexts:r?e:defaultLoadingTexts}),this.pixelRatio=750/t,this.updateDistanceTop()},detached(){clearTimeout(this.maxRefreshAnimateTimeFlag),clearTimeout(this.closingAnimateTimeFlag),this.resetTimer()}},this.observers={value(t){t?this.doRefresh():(clearTimeout(this.maxRefreshAnimateTimeFlag),this.data.refreshStatus>0&&this.setData({refreshStatus:3}),this.setData({barHeight:0}))},barHeight(t){this.resetTimer(),0===t&&-1!==this.data.refreshStatus&&(this.refreshStatusTimer=setTimeout(()=>{this.setData({refreshStatus:-1})},240)),this.setData({tipsHeight:Math.min(t,this.data._loadingBarHeight)})},maxBarHeight(t){this.setData({_maxBarHeight:unitConvert(t)})},loadingBarHeight(t){this.setData({_loadingBarHeight:unitConvert(t)})}},this.methods={updateDistanceTop(){const t=t=>{this.setData({distanceTop:t})};getRect(this,`.${name}`).then(e=>{e.top?t(e.top):getObserver(this,`.${name}`).then(e=>{e.intersectionRatio>0&&t(e.boundingClientRect.top)})})},resetTimer(){this.refreshStatusTimer&&(clearTimeout(this.refreshStatusTimer),this.refreshStatusTimer=null)},onScrollToBottom(){this.triggerEvent("scrolltolower")},onScrollToTop(){this.setData({enableToRefresh:!0})},onScroll(t){const{scrollTop:e}=t.detail;this.setData({enableToRefresh:0===e}),this.triggerEvent("scroll",{scrollTop:e})},onTouchStart(t){if(this.isPulling||!this.data.enableToRefresh||this.properties.disabled)return;const{touches:e}=t;if(1!==e.length)return;const{pageX:s,pageY:i}=e[0];this.setData({loosing:!1}),this.startPoint={pageX:s,pageY:i},this.isPulling=!0},onTouchMove(t){if(!this.startPoint||this.properties.disabled)return;const{touches:e}=t;if(1!==e.length)return;const{pageY:s}=e[0],i=s-this.startPoint.pageY;i>0&&this.setRefreshBarHeight(i)},onTouchEnd(t){if(!this.startPoint||this.properties.disabled)return;const{changedTouches:e}=t;if(1!==e.length)return;const{pageY:s}=e[0],i=s-this.startPoint.pageY;this.startPoint=null,this.isPulling=!1,this.setData({loosing:!0}),i>this.data._loadingBarHeight?(this._trigger("change",{value:!0}),this.triggerEvent("refresh")):this.setData({barHeight:0})},onDragStart(t){const{scrollTop:e,scrollLeft:s}=t.detail;this.triggerEvent("dragstart",{scrollTop:e,scrollLeft:s})},onDragging(t){const{scrollTop:e,scrollLeft:s}=t.detail;this.triggerEvent("dragging",{scrollTop:e,scrollLeft:s})},onDragEnd(t){const{scrollTop:e,scrollLeft:s}=t.detail;this.triggerEvent("dragend",{scrollTop:e,scrollLeft:s})},doRefresh(){this.properties.disabled||(this.setData({barHeight:this.data._loadingBarHeight,refreshStatus:2,loosing:!0}),this.maxRefreshAnimateTimeFlag=setTimeout(()=>{this.maxRefreshAnimateTimeFlag=null,2===this.data.refreshStatus&&(this.triggerEvent("timeout"),this._trigger("change",{value:!1}))},this.properties.refreshTimeout))},setRefreshBarHeight(t){const e=Math.min(t,this.data._maxBarHeight),s={barHeight:e};return e>=this.data._loadingBarHeight?s.refreshStatus=1:s.refreshStatus=0,new Promise(t=>{this.setData(s,()=>t(e))})},setScrollTop(t){this.setData({scrollTop:t})},scrollToTop(){this.setScrollTop(0)}}}};PullDownRefresh=__decorate([wxComponent()],PullDownRefresh);export default PullDownRefresh;
|
||||
@@ -0,0 +1 @@
|
||||
{"component":true,"styleIsolation":"apply-shared","usingComponents":{"t-loading":"../loading/loading"}}
|
||||
@@ -0,0 +1 @@
|
||||
<wxs src="../common/utils.wxs" module="_"/><scroll-view style="{{_._style([style, customStyle, 'max-height: calc(100vh - ' + distanceTop + 'px)'])}}" class="{{classPrefix}} class {{prefix}}-class" type="list" scroll-top="{{scrollTop}}" scroll-y enable-back-to-top="{{enableBackToTop}}" enable-passive="{{enablePassive}}" lower-threshold="{{lowerThreshold}}" upper-threshold="{{upperThreshold}}" scroll-into-view="{{scrollIntoView}}" show-scrollbar="{{showScrollbar}}" enhanced scroll-with-animation bounces="{{false}}" bind:touchstart="onTouchStart" bind:touchmove="onTouchMove" bind:touchend="onTouchEnd" bind:scroll="onScroll" binddragstart="onDragStart" binddragging="onDragging" binddragend="onDragEnd" bindscrolltoupper="onScrollToTop" bindscrolltolower="onScrollToBottom" throttle="{{false}}"><slot name="header"/><view class="{{classPrefix}}__track {{classPrefix + '__track--' + (loosing ? 'loosing' : '')}}" style="{{barHeight > 0 ? 'transform: translate3d(0, ' + barHeight + 'px, 0);' : ''}}"><view class="{{classPrefix}}__tips {{classPrefix + '__tips--' + (loosing ? 'loosing' : '')}}" style="height: {{tipsHeight}}px" aria-live="polite"><t-loading wx:if="{{refreshStatus === 2}}" delay="{{loadingProps.delay || 0}}" duration="{{loadingProps.duration || 800}}" indicator="{{loadingProps.indicator || true}}" layout="{{loadingProps.layout || 'horizontal'}}" loading="{{loadingProps.loading || true}}" pause="{{loadingProps.pause || false}}" progress="{{loadingProps.progress || 0}}" reverse="{{loadingProps.reverse || false}}" size="{{loadingProps.size || '50rpx'}}" text="{{loadingProps.text || loadingTexts[refreshStatus]}}" theme="{{loadingProps.theme || 'circular'}}" t-class="{{prefix}}-class-loading" t-class-indicator="{{prefix}}-class-indicator"/><view wx:elif="{{refreshStatus >= 0}}" class="{{classPrefix}}__text {{prefix}}-class-text">{{loadingTexts[refreshStatus]}}</view></view><slot/></view></scroll-view>
|
||||
@@ -0,0 +1,6 @@
|
||||
@import '../common/style/index.wxss';.t-pull-down-refresh{overflow:hidden;height:100%;}
|
||||
.t-pull-down-refresh__track{position:relative;}
|
||||
.t-pull-down-refresh__track--loosing{transition:transform ease .24s;}
|
||||
.t-pull-down-refresh__tips{position:absolute;color:var(--td-pull-down-refresh-color,var(--td-text-color-placeholder,var(--td-font-gray-3,rgba(0,0,0,.4))));font-size:24rpx;top:0;width:100%;transform:translateY(-100%);display:flex;justify-content:center;align-items:center;flex-direction:column;overflow:hidden;}
|
||||
.t-pull-down-refresh__tips--loosing{transition:height ease .24s;}
|
||||
.t-pull-down-refresh__text{margin:16rpx 0 0;}
|
||||
67
miniprogram/miniprogram_npm/tdesign-miniprogram/pull-down-refresh/type.d.ts
vendored
Normal file
67
miniprogram/miniprogram_npm/tdesign-miniprogram/pull-down-refresh/type.d.ts
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
import { LoadingProps } from '../loading/index';
|
||||
export interface TdPullDownRefreshProps {
|
||||
disabled?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
enableBackToTop?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
enablePassive?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
loadingBarHeight?: {
|
||||
type: null;
|
||||
value?: string | number;
|
||||
};
|
||||
loadingProps?: {
|
||||
type: ObjectConstructor;
|
||||
value?: LoadingProps;
|
||||
};
|
||||
loadingTexts?: {
|
||||
type: ArrayConstructor;
|
||||
value?: string[];
|
||||
};
|
||||
lowerThreshold?: {
|
||||
type: null;
|
||||
value?: string | number;
|
||||
};
|
||||
maxBarHeight?: {
|
||||
type: null;
|
||||
value?: string | number;
|
||||
};
|
||||
refreshTimeout?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
scrollIntoView?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
showScrollbar?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
successDuration?: {
|
||||
type: null;
|
||||
value?: string | number;
|
||||
};
|
||||
upperThreshold?: {
|
||||
type: null;
|
||||
value?: string | number;
|
||||
};
|
||||
usingCustomNavbar?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
value?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
defaultValue?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export{};
|
||||
Reference in New Issue
Block a user