云链智安app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view class="l-liquid" :class="{'l-liquid--outline': outline}" :style="[styles]">
  3. <view class="l-liquid__inner" :style="[innerStyle]">
  4. <view class="l-liquid__waves" :style="[wavesStyle]">
  5. <view class="wave" :style="[waveStyle]"></view>
  6. <view class="wave two" :style="[waveStyle]"></view>
  7. </view>
  8. </view>
  9. <view class="l-liquid__value">
  10. <slot></slot>
  11. </view>
  12. </view>
  13. </template>
  14. <script lang="ts">
  15. // @ts-nocheck
  16. import {computed, ref, watch, onUnmounted, defineComponent} from '@/uni_modules/lime-shared/vue';
  17. import { useTransition, UseTransitionOptions } from "@/uni_modules/lime-shared/animation/useTransition";
  18. import liquidProps from './props';
  19. // import {useTransition} from '@/uni_modules/lime-use';
  20. const name = 'l-liquid'
  21. export default defineComponent({
  22. name,
  23. props: liquidProps,
  24. emits: ['update:current'],
  25. setup(props, {emit}) {
  26. const percent = ref(0)
  27. // const current = ref(props.percent)
  28. const current = useTransition(percent, {duration: 300})
  29. // const classes = computed(() => ({
  30. // [name + '--outline']: props.outline
  31. // }))
  32. const styles = computed(() => {
  33. return {
  34. width: props.size,
  35. height: props.size,
  36. 'border-radius': props.radius
  37. }
  38. })
  39. const innerStyle = computed(() => {
  40. return {
  41. 'border-radius': props.radius,
  42. 'background': props.innerColor
  43. }
  44. })
  45. const wavesStyle = computed(() => {
  46. return {
  47. '--l-liquid-percent': current.value * -1 + '%'
  48. }
  49. })
  50. const waveStyle = computed(() => {
  51. return {
  52. background: props.waveColor
  53. }
  54. })
  55. // let timer = null
  56. // const stopPercent = watch(() => props.percent, (v) => {
  57. // percent.value = v
  58. // clearTimeout(timer)
  59. // const step = () => {
  60. // if(v == current.value) {
  61. // clearTimeout(timer)
  62. // emit('update:current', current.value)
  63. // return
  64. // }
  65. // const value = (v - current.value)
  66. // if(value > 0) {
  67. // current.value += 1
  68. // }
  69. // if(value < 0){
  70. // current.value -= 1
  71. // }
  72. // emit('update:current', current.value)
  73. // timer = setTimeout(step, 1000 / 60)
  74. // }
  75. // timer = setTimeout(step, 1000 / 60)
  76. // }, {immediate: true})
  77. const stopCurrent = watch(current, (v) => {
  78. emit('update:current', Math.round(v))
  79. })
  80. const stopPercent = watch(() => props.percent, (v) => {
  81. percent.value = v
  82. }, {immediate: true})
  83. onUnmounted(() => {
  84. stopCurrent && stopCurrent()
  85. stopPercent && stopPercent()
  86. })
  87. return {
  88. // classes,
  89. styles,
  90. innerStyle,
  91. wavesStyle,
  92. waveStyle
  93. }
  94. }
  95. })
  96. </script>
  97. <style lang="scss">
  98. // @import './index';
  99. @import './index-u';
  100. </style>