index.axml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <import-sjs
  2. name="util"
  3. from="./index.sjs" />
  4. <view class="ant-swipe">
  5. <view
  6. class="ant-swipe-action"
  7. style="{{{ width: util.getWidth(rightWidth, leftWidth, inertiaWidth) }}}">
  8. <movable-area
  9. class="ant-swipe-action-movable"
  10. style="{{{
  11. marginLeft: util.getMarginLeft(rightWidth, leftWidth, inertiaWidth),
  12. }}}">
  13. <movable-view
  14. class="ant-swipe-action-movable-content"
  15. style="{{{
  16. width: util.getWidth2(rightWidth, leftWidth, inertiaWidth),
  17. marginLeft: util.getMarginLeft2(rightWidth, leftWidth, inertiaWidth)}}}"
  18. x="{{swipeX}}"
  19. data-type="content"
  20. animation="{{animation}}"
  21. damping="{{damping}}"
  22. direction="horizontal"
  23. out-of-bounds="{{ false }}"
  24. disabled="{{disabled}}"
  25. onTap="onSwipeTap"
  26. onChange="onChange"
  27. onChangeEnd="onChangeEnd"
  28. catchTouchEnd="onTouchEnd"
  29. onTouchCancel="onTouchCancel"
  30. catchTouchStart="onTouchStart">
  31. <view
  32. class="ant-swipe-action-movable-content-view"
  33. style="{{util.getSlotWidthStyle(rightWidth, leftWidth, _leftButtons, _rightButtons, inertiaWidth)}}"
  34. onTap="onClick">
  35. <view
  36. class="ant-swipe-action-movable-content-view-modal"
  37. a:if="{{swipedR || swipedL}}"></view>
  38. <slot />
  39. </view>
  40. </movable-view>
  41. <movable-view
  42. class="ant-swipe-action-movable-content {{`ant-swipe-action-movable-right-${$id}`}}"
  43. a:for="{{_rightButtons}}"
  44. a:for-item="item"
  45. a:for-index="idx"
  46. damping="{{damping}}"
  47. a:key="{{idx}}"
  48. style="{{{
  49. zIndex: tapTypeR === `R-${idx}` ? 1 : 0,
  50. marginLeft: util.getMarginLeft3(rightWidth, leftWidth, inertiaWidth),
  51. width: ((rightWidth - 0.1) / 2) + 'px' }}}"
  52. data-type="content"
  53. animation="{{false}}"
  54. disabled="{{true}}"
  55. direction="horizontal"
  56. x="{{moveX * (util.getMoveX(_rightButtons, idx) / rightWidth)}}">
  57. <view
  58. class="ant-swipe-action-movable-content-right"
  59. style="{{{background: item.bgColor,width: ((item.width + inertiaWidth + 1) / 2) + 'px'}}}">
  60. <view
  61. class="ant-swipe-action-movable-content-right-text"
  62. onTap="onItemTap"
  63. data-item="{{item, idx}}"
  64. aria-hidden="{{!swipedR}}"
  65. style="{{{
  66. fontSize: ((item.fontSize || 28) / 2) + 'px',
  67. color: item.color,
  68. background: item.bgColor,
  69. width: tapTypeR && tapTypeR === `R-${idx}` ? ((rightWidth + 1 + (item.confirmType === 'move' && inTouch ? inertiaWidth : 0)) / 2) + 'px' : `${item.width / 2}px`,
  70. ...(tapTypeR && tapTypeR === `R-${idx}` ? myStyle : {})
  71. }}}">
  72. <text
  73. class="right-text {{util.getLeft(tapTypeR, idx, _rightButtons, true)}}">
  74. {{tapTypeR && tapTypeR === `R-${idx}` ? (item.confirmText ||
  75. item.text) : item.text}}
  76. </text>
  77. </view>
  78. </view>
  79. </movable-view>
  80. <movable-view
  81. class="ant-swipe-action-movable-content ant-swipe-action-is-right-swipe {{`ant-swipe-action-movable-left-${$id}`}}"
  82. a:for="{{_leftButtons}}"
  83. a:for-item="itemL"
  84. a:for-index="idx"
  85. damping="{{damping}}"
  86. a:key="{{`left-${idx}`}}"
  87. style="{{{
  88. zIndex: tapTypeL === `L-${idx}` ? 1 : 0,
  89. marginLeft: `${inertiaWidth / 2}px`,
  90. width: ((leftWidth - 1) / 2) + 'px'}}}"
  91. data-type="content"
  92. animation="{{false}}"
  93. disabled="{{true}}"
  94. direction="horizontal"
  95. x="{{moveX * (util.getMoveX(_leftButtons, idx) / leftWidth)}}">
  96. <view
  97. class="ant-swipe-action-movable-content-left"
  98. style="{{{background: tapTypeL && tapTypeL === `L-${idx}` && _leftButtons.length === 3 && idx === 1 ? 'none' : itemL.bgColor,width: ((leftWidth + inertiaWidth) / 2) + 'px'}}}">
  99. <view
  100. class="ant-swipe-action-movable-content-left-text1 ant-swipe-action-left"
  101. onTap="onItemTap"
  102. data-item="{{itemL, idx}}"
  103. aria-hidden="{{!swipedL}}"
  104. style="{{{
  105. background: itemL.bgColor,
  106. height: `calc(100% + 2px)`,
  107. fontSize: ((itemL.fontSize || 28) / 2) + 'px',
  108. color: itemL.color,
  109. ...(tapTypeL && tapTypeL === `L-${idx}` ? myStyle : {}),
  110. width: tapTypeL && tapTypeL === `L-${idx}` ? ((leftWidth + 1 + (itemL.confirmType === 'move' && inTouch ? inertiaWidth : 0)) / 2) + 'px' : `${itemL.width / 2}px`,
  111. }}}">
  112. <text
  113. class="right-text"
  114. style="{{{ width: `100%` }}}">
  115. <text
  116. class="right-text {{util.getLeft(tapTypeL, idx, _leftButtons, false)}}">
  117. {{tapTypeL && tapTypeL === `L-${idx}` ? (itemL.confirmText ||
  118. itemL.text) : itemL.text}}
  119. </text>
  120. </text>
  121. </view>
  122. </view>
  123. </movable-view>
  124. </movable-area>
  125. </view>
  126. </view>