share-element.uvue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <page-head title="share-element"></page-head>
  3. <view class="main">
  4. <share-element class="share-element" share-key="left" :shuttle-on-pop="shuttleOnPopType"
  5. :transition-on-gesture="transitionOnGesture" :shuttle-on-push="shuttleOnPushType" :easing-function="easingFunctionType" @tap="openPage()">
  6. <image style="width: 100px;height: 150px;"
  7. src="https://web-ext-storage.dcloud.net.cn/hello-uni-app-x/drop-card-1.jpg">
  8. </image>
  9. </share-element>
  10. </view>
  11. <button type="primary" @click="openPage" class="button">
  12. 打开share-element页面
  13. </button>
  14. <scroll-view style="flex: 1">
  15. <view class="content">
  16. <boolean-data :defaultValue="transitionOnGesture" title="transition-on-gesture= true(仅iOS生效)"
  17. @change="changeTransitionOnGesture"></boolean-data>
  18. <text class="uni-common-mt choose-property-title">easing-function:</text>
  19. <radio-group class="choose-property-type-radio-group" @change="handleEasingFunction">
  20. <radio class="ml-10 uni-common-mt" v-for="item in easingFunctionTypeList" :key="item" :value="item"
  21. :checked="easingFunctionType == item">{{ item }}
  22. </radio>
  23. </radio-group>
  24. <text class="uni-common-mt choose-property-title">shuttle-on-push(仅iOS生效):</text>
  25. <radio-group class="choose-property-type-radio-group" @change="handleShuttleOnPushType">
  26. <radio class="ml-10 uni-common-mt" v-for="item in shuttleOnTypeList" :key="item" :value="item"
  27. :checked="shuttleOnPushType == item">{{ item }}
  28. </radio>
  29. </radio-group>
  30. <text class="uni-common-mt choose-property-title">shuttle-on-pop(仅iOS生效):</text>
  31. <radio-group class="choose-property-type-radio-group" @change="handleShuttleOnPopType">
  32. <radio class="ml-10 uni-common-mt" v-for="item in shuttleOnTypeList" :key="item" :value="item"
  33. :checked="shuttleOnPopType == item">{{ item }}
  34. </radio>
  35. </radio-group>
  36. <text class="uni-common-mt choose-property-title">animationType(页面动画降级):</text>
  37. <radio-group class="choose-property-type-radio-group" @change="handleOpenAnimationType">
  38. <radio class="ml-10 uni-common-mt" v-for="item in openAnimationTypeList" :key="item" :value="item"
  39. :checked="openAnimationType == item">{{ item }}
  40. </radio>
  41. </radio-group>
  42. </view>
  43. </scroll-view>
  44. <view style="height: 80px;"></view>
  45. <share-element class="bottomWrap" share-key="bottom" @tap="openPage()" transitionOnGesture=true>
  46. <view class="bottom">
  47. <text style="color: white;">share-element(底部固定)</text>
  48. </view>
  49. </share-element>
  50. </template>
  51. <script>
  52. type ShareElementOpenAnimationType =
  53. 'auto' |
  54. 'none' |
  55. 'slide-in-right' |
  56. 'slide-in-left' |
  57. 'slide-in-top' |
  58. 'slide-in-bottom' |
  59. 'fade-in' |
  60. 'pop-in' |
  61. 'zoom-out' |
  62. 'zoom-fade-out'
  63. type ShareElementEasingFunctionType =
  64. 'ease' |
  65. 'ease-in' |
  66. 'ease-out' |
  67. 'ease-in-out' |
  68. 'linear'
  69. type ShuttleOnType =
  70. 'from' |
  71. 'to'
  72. import { ItemType } from '@/components/enum-data/enum-data-types'
  73. export default {
  74. data() {
  75. return {
  76. transitionOnGesture: true,
  77. shuttleOnPopType: 'to' as ShuttleOnType,
  78. shuttleOnPushType: 'to' as ShuttleOnType,
  79. shuttleOnTypeList: [
  80. 'from',
  81. 'to'
  82. ],
  83. openAnimationType: 'slide-in-right' as ShareElementOpenAnimationType,
  84. openAnimationTypeList: [
  85. 'auto',
  86. 'none',
  87. 'slide-in-right',
  88. 'slide-in-left',
  89. 'slide-in-top',
  90. 'slide-in-bottom',
  91. 'fade-in',
  92. 'pop-in',
  93. 'zoom-out',
  94. 'zoom-fade-out'
  95. ],
  96. easingFunctionType: 'ease' as ShareElementEasingFunctionType,
  97. easingFunctionTypeList: [
  98. 'ease',
  99. 'ease-in',
  100. 'ease-out',
  101. 'ease-in-out',
  102. 'linear'
  103. ]
  104. }
  105. },
  106. methods: {
  107. openPage() {
  108. uni.navigateTo({
  109. animationType: this.openAnimationType,
  110. url: "/pages/component/share-element/share-element-to?shuttleOnPush=" + this.shuttleOnPushType + "&transitionOnGesture=" + this.transitionOnGesture
  111. })
  112. },
  113. changeTransitionOnGesture(checked : boolean) {
  114. console.log(`changeTransitionOnGesture:${checked}`)
  115. this.transitionOnGesture = checked
  116. },
  117. handleOpenAnimationType(e : RadioGroupChangeEvent) {
  118. this.openAnimationType = e.detail.value as ShareElementOpenAnimationType
  119. },
  120. handleEasingFunction(e : RadioGroupChangeEvent) {
  121. this.easingFunctionType = e.detail.value as ShareElementEasingFunctionType
  122. },
  123. handleShuttleOnPopType(e : RadioGroupChangeEvent) {
  124. this.shuttleOnPopType = e.detail.value as ShuttleOnType
  125. },
  126. handleShuttleOnPushType(e : RadioGroupChangeEvent) {
  127. this.shuttleOnPushType = e.detail.value as ShuttleOnType
  128. },
  129. }
  130. }
  131. </script>
  132. <style>
  133. .ml-10 {
  134. margin-left: 10px;
  135. }
  136. .choose-property-title {
  137. font-weight: bold;
  138. }
  139. .choose-property-type-radio-group {
  140. flex-direction: row;
  141. flex-wrap: wrap;
  142. }
  143. .bottomWrap {
  144. width: 100%;
  145. bottom: 0px;
  146. height: 80px;
  147. position: fixed;
  148. }
  149. .bottom {
  150. width: 100%;
  151. height: 100%;
  152. align-items: center;
  153. justify-content: center;
  154. background-color: #007aff;
  155. }
  156. .main {
  157. padding: 5px 0;
  158. align-items: center;
  159. justify-content: center;
  160. }
  161. </style>