New Huajishe Check ChaoXing
This commit is contained in:
21
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/fab/draggable/draggable.d.ts
vendored
Normal file
21
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/fab/draggable/draggable.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { SuperComponent } from '../../common/src/index';
|
||||
import type { TdDraggableProps } from './type';
|
||||
export interface DraggableProps extends TdDraggableProps {
|
||||
}
|
||||
export default class Draggable extends SuperComponent {
|
||||
properties: TdDraggableProps;
|
||||
externalClasses: string[];
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
};
|
||||
lifetimes: {
|
||||
ready(): void;
|
||||
};
|
||||
methods: {
|
||||
onTouchStart(e: any): void;
|
||||
onTouchMove(e: any): void;
|
||||
onTouchEnd(e: any): Promise<void>;
|
||||
computedRect(): Promise<void>;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
import { SuperComponent, wxComponent } from '../../common/src/index';
|
||||
import config from '../../common/config';
|
||||
import props from './props';
|
||||
import { getRect, systemInfo } from '../../common/utils';
|
||||
const { prefix } = config;
|
||||
const name = `${prefix}-draggable`;
|
||||
let Draggable = class Draggable extends SuperComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.properties = props;
|
||||
this.externalClasses = [`${prefix}-class`];
|
||||
this.data = {
|
||||
prefix,
|
||||
classPrefix: name,
|
||||
};
|
||||
this.lifetimes = {
|
||||
ready() {
|
||||
this.computedRect();
|
||||
},
|
||||
};
|
||||
this.methods = {
|
||||
onTouchStart(e) {
|
||||
if (this.properties.direction === 'none')
|
||||
return;
|
||||
this.startX = e.touches[0].clientX + systemInfo.windowWidth - this.rect.right;
|
||||
this.startY = e.touches[0].clientY + systemInfo.windowHeight - this.rect.bottom;
|
||||
this.triggerEvent('start', { startX: this.startX, startY: this.startY, rect: this.rect, e });
|
||||
},
|
||||
onTouchMove(e) {
|
||||
if (this.properties.direction === 'none')
|
||||
return;
|
||||
let x = this.startX - e.touches[0].clientX;
|
||||
let y = this.startY - e.touches[0].clientY;
|
||||
if (this.properties.direction === 'vertical') {
|
||||
x = systemInfo.windowWidth - this.rect.right;
|
||||
}
|
||||
if (this.properties.direction === 'horizontal') {
|
||||
y = systemInfo.windowHeight - this.rect.bottom;
|
||||
}
|
||||
this.triggerEvent('move', { x, y, rect: this.rect, e });
|
||||
},
|
||||
onTouchEnd(e) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (this.properties.direction === 'none')
|
||||
return;
|
||||
yield this.computedRect();
|
||||
this.triggerEvent('end', { rect: this.rect, e });
|
||||
});
|
||||
},
|
||||
computedRect() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this.rect = { right: 0, bottom: 0, width: 0, height: 0 };
|
||||
try {
|
||||
this.rect = yield getRect(this, `.${this.data.classPrefix}`);
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
Draggable = __decorate([
|
||||
wxComponent()
|
||||
], Draggable);
|
||||
export default Draggable;
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<wxs src="../../common/utils.wxs" module="_" />
|
||||
|
||||
<view
|
||||
class="{{classPrefix}} class {{prefix}}-class"
|
||||
style="{{_._style([style, customStyle])}}"
|
||||
bind:touchstart="onTouchStart"
|
||||
catch:touchmove="onTouchMove"
|
||||
bind:touchend="onTouchEnd"
|
||||
>
|
||||
<slot></slot>
|
||||
</view>
|
||||
@@ -0,0 +1,30 @@
|
||||
.t-float-left {
|
||||
float: left;
|
||||
}
|
||||
.t-float-right {
|
||||
float: right;
|
||||
}
|
||||
@keyframes tdesign-fade-out {
|
||||
from {
|
||||
opacity: 1;
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
.hotspot-expanded.relative {
|
||||
position: relative;
|
||||
}
|
||||
.hotspot-expanded::after {
|
||||
content: '';
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
transform: scale(1.5);
|
||||
}
|
||||
.t-draggable {
|
||||
position: fixed;
|
||||
}
|
||||
3
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/fab/draggable/index.d.ts
vendored
Normal file
3
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/fab/draggable/index.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './props';
|
||||
export * from './type';
|
||||
export * from './draggable';
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from './props';
|
||||
export * from './type';
|
||||
export * from './draggable';
|
||||
3
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/fab/draggable/props.d.ts
vendored
Normal file
3
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/fab/draggable/props.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { TdDraggableProps } from './type';
|
||||
declare const props: TdDraggableProps;
|
||||
export default props;
|
||||
@@ -0,0 +1,7 @@
|
||||
const props = {
|
||||
direction: {
|
||||
type: String,
|
||||
value: 'all',
|
||||
},
|
||||
};
|
||||
export default props;
|
||||
6
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/fab/draggable/type.d.ts
vendored
Normal file
6
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/fab/draggable/type.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export interface TdDraggableProps {
|
||||
direction?: {
|
||||
type: StringConstructor;
|
||||
value?: 'all' | 'vertical' | 'horizontal' | 'none';
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user