u-floating.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. type TouchItem = {
  2. __$originalPosition?: UTSSourceMapPosition<"TouchItem", "components/u-floating/u-floating.vue", 9, 7>;
  3. clientX: number;
  4. clientY: number;
  5. };
  6. type TouchEvent = {
  7. __$originalPosition?: UTSSourceMapPosition<"TouchEvent", "components/u-floating/u-floating.vue", 13, 7>;
  8. touches: Array<TouchItem>;
  9. };
  10. const __sfc__ = defineComponent({
  11. name: 'FloatingButton',
  12. data() {
  13. return {
  14. top: 430,
  15. left: 20,
  16. startX: 0,
  17. startY: 0,
  18. dragging: false
  19. };
  20. },
  21. methods: {
  22. onTouchStart(event: TouchEvent) {
  23. this.startX = event.touches[0].clientX;
  24. this.startY = event.touches[0].clientY;
  25. this.dragging = true;
  26. },
  27. onTouchMove(event: TouchEvent) {
  28. if (this.dragging) {
  29. const deltaX = event.touches[0].clientX - this.startX;
  30. const deltaY = event.touches[0].clientY - this.startY;
  31. this.startX = event.touches[0].clientX;
  32. this.startY = event.touches[0].clientY;
  33. this.top += deltaY;
  34. this.left += deltaX;
  35. }
  36. },
  37. onTouchEnd() {
  38. this.dragging = false;
  39. }
  40. }
  41. });
  42. export default __sfc__;
  43. function GenComponentsUFloatingUFloatingRender(this: InstanceType<typeof __sfc__>): any | null {
  44. const _ctx = this;
  45. const _cache = this.$.renderCache;
  46. return _cE("view", _uM({
  47. class: "floating-button",
  48. style: _nS(_uM({ top: _ctx.top + 'px', left: _ctx.left + 'px' })),
  49. onTouchstart: _ctx.onTouchStart,
  50. onTouchmove: _ctx.onTouchMove,
  51. onTouchend: _ctx.onTouchEnd
  52. }), [
  53. _cE("text", _uM({
  54. class: "textIcon icon-jingwuicon_svg-",
  55. style: _nS(_uM({ "font-size": "60rpx", "color": "#FF4D4D" }))
  56. }), null, 4 /* STYLE */)
  57. ], 44 /* STYLE, PROPS, NEED_HYDRATION */, ["onTouchstart", "onTouchmove", "onTouchend"]);
  58. }
  59. export type UFloatingComponentPublicInstance = InstanceType<typeof __sfc__>;
  60. const GenComponentsUFloatingUFloatingStyles = [_uM([["floating-button", _pS(_uM([["position", "fixed"], ["zIndex", 9999], ["backgroundColor", "#ffffff"], ["paddingTop", "20rpx"], ["paddingRight", "20rpx"], ["paddingBottom", "20rpx"], ["paddingLeft", "20rpx"], ["borderTopLeftRadius", "35rpx"], ["borderTopRightRadius", "35rpx"], ["borderBottomRightRadius", "35rpx"], ["borderBottomLeftRadius", "35rpx"], ["width", "70rpx"], ["height", "70rpx"], ["display", "flex"], ["justifyContent", "center"], ["alignItems", "center"], ["boxShadow", "0 4rpx 10rpx rgba(0, 0, 0, 0.3)"]]))]])];
  61. //# sourceMappingURL=u-floating.vue.map