u-floating.vue.ts 2.3 KB

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