1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- Component({
-
-
-
-
-
-
-
-
- data: {
- popShow: false,
- top: 0,
- startX: 0,
- startY: 0,
- windowWidth: 0,
- windowHeight: 0,
- elementHeight: 60
- },
- attached() {
-
- const systemInfo = wx.getWindowInfo();
- this.setData({
- windowWidth: systemInfo.windowWidth,
- windowHeight: systemInfo.windowHeight,
- top: systemInfo.windowHeight - 180
- });
- },
-
- methods: {
- onClose() {
-
- this.setData({
- popShow: false
- })
- },
- onOpen() {
-
- },
- onShow() {
- this.setData({
- popShow: true
- })
- },
- onTouchStart(e: any) {
-
- this.setData({
- startY: e.touches[0].clientY
- });
- },
-
- onTouchMove(e: any) {
-
- const deltaY = e.touches[0].clientY - this.data.startY;
-
-
- this.setData({
- top: this.data.top + deltaY,
- startY: e.touches[0].clientY
- });
- },
-
- onTouchEnd() {
- const { top, windowHeight, elementHeight } = this.data;
-
- const distanceTop = top;
- const moveHeight = top + elementHeight
-
- if (distanceTop < 0) {
- this.setData({ top: 0 });
- } else if(moveHeight >= windowHeight) {
- this.setData({ top: windowHeight - elementHeight })
- } else {
- this.setData({ top })
- }
- }
- }
- })
|