VciEffectRectEdgeStreamer.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <div
  3. :class="{'ers-debug': isDebug, 'ers-double': !isSingle}"
  4. :style="sylGlobal"
  5. class="VciEffectRectEdgeStreamer"
  6. >
  7. <div
  8. :style="{ height: `${toVw(height)}`}"
  9. class="ers-edge ers-top"
  10. >
  11. <div
  12. :style="[syl, { height: `${toVw(height)}` }]"
  13. class="ers-flow"
  14. >
  15. <i
  16. :style="sylErs"
  17. class="ers vci-bg-fill"
  18. ></i>
  19. </div>
  20. </div>
  21. <div
  22. :style="{ width: `${toVw(height)}`}"
  23. class="ers-edge ers-right"
  24. >
  25. <div
  26. :style="[syl, {'animation-delay': `${halfOfDuration}ms`}]"
  27. class="ers-flow"
  28. >
  29. <i
  30. :style="[sylErs, { 'transform-origin': `100% ${toVw(height / 2)}`, right: toVw(height / 2), bottom: toVw(-height / 2)}]"
  31. class="ers vci-bg-fill"
  32. ></i>
  33. </div>
  34. </div>
  35. <div
  36. :style="{ height: `${toVw(height)}`}"
  37. class="ers-edge ers-bottom"
  38. >
  39. <div
  40. :style="[syl, {'animation-delay': `${halfOfDuration * 2}ms`}]"
  41. class="ers-flow"
  42. >
  43. <i
  44. :style="sylErs"
  45. class="ers vci-bg-fill"
  46. ></i>
  47. </div>
  48. </div>
  49. <div
  50. :style="{ width: `${toVw(height)}`}"
  51. class="ers-edge ers-left"
  52. >
  53. <div
  54. :style="[syl, {'animation-delay': `${halfOfDuration * 3}ms`}]"
  55. class="ers-flow"
  56. >
  57. <i
  58. :style="[sylErs, { 'transform-origin': `100% ${toVw(height / 2)}`, right: toVw(height / 2), bottom: toVw(-height / 2)}]"
  59. class="ers vci-bg-fill"
  60. ></i>
  61. </div>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. // power by visual-ceiling, at 2023/6/30 16:48
  67. import { toVw } from "@vci/vci/other/adapt";
  68. export default {
  69. name: "VciEffectRectEdgeStreamer",
  70. props: {
  71. duration: {
  72. type: [Number, String],
  73. default: 2000
  74. },
  75. isDebug: {
  76. type: Boolean,
  77. default: false
  78. },
  79. isSingle: {
  80. type: Boolean,
  81. default: false
  82. },
  83. width: {
  84. type: [Number, String],
  85. default: 100
  86. },
  87. height: {
  88. type: [Number, String],
  89. default: 20
  90. }
  91. },
  92. data() {
  93. return {};
  94. },
  95. computed: {
  96. sylGlobal() {
  97. return {
  98. // left: toVw(-this.height / 2),
  99. // top: toVw(-this.height / 2),
  100. // width: `calc(100% + ${toVw(this.height)})`,
  101. // height: `calc(100% + ${toVw(this.height)})`
  102. };
  103. },
  104. syl() {
  105. return {
  106. animationDuration: `${this.duration}ms`
  107. };
  108. },
  109. sylErs() {
  110. return {
  111. width: toVw(this.width),
  112. height: toVw(this.height)
  113. };
  114. },
  115. halfOfDuration() {
  116. return Number(this.duration) / (this.isSingle ? 4 : 2);
  117. }
  118. },
  119. methods: { toVw }
  120. };
  121. </script>
  122. <style lang="scss" scoped>
  123. $thickness: 12;
  124. .VciEffectRectEdgeStreamer {
  125. position: absolute;
  126. left: 0;
  127. top: 0;
  128. width: 100%;
  129. height: 100%;
  130. pointer-events: none;
  131. .ers-edge {
  132. position: absolute;
  133. overflow: hidden;
  134. .ers-flow {
  135. width: 100%;
  136. height: 100%;
  137. //animation: none !important;
  138. .ers {
  139. position: absolute;
  140. display: block;
  141. width: 100%;
  142. height: 100%;
  143. background-image: linear-gradient(90deg, transparent, #fff);
  144. }
  145. }
  146. }
  147. .ers-top {
  148. left: 0;
  149. top: 0;
  150. width: 100%;
  151. height: $thickness + px;
  152. transform: translateY(-50%);
  153. .ers-flow {
  154. transform: translateX(-100%);
  155. animation: amtErsHorizontal infinite both linear;
  156. .ers {
  157. right: 0;
  158. top: 0;
  159. }
  160. }
  161. }
  162. .ers-right {
  163. right: 0;
  164. top: 0;
  165. width: $thickness + px;
  166. height: 100%;
  167. transform: translateX(50%);
  168. .ers-flow {
  169. transform: translateY(-100%);
  170. animation: amtErsVertical infinite both linear;
  171. .ers {
  172. right: $thickness / 2 + px;
  173. bottom: -$thickness / 2 + px;
  174. transform-origin: 100% $thickness / 2 + px;
  175. transform: rotateZ(90deg);
  176. }
  177. }
  178. }
  179. .ers-bottom {
  180. left: 0;
  181. bottom: 0;
  182. width: 100%;
  183. height: $thickness + px;
  184. transform: translateY(50%) rotateY(180deg);
  185. .ers-flow {
  186. transform: translateX(-100%);
  187. animation: amtErsHorizontal infinite both linear;
  188. .ers {
  189. left: 0;
  190. top: 0;
  191. }
  192. }
  193. }
  194. .ers-left {
  195. left: 0;
  196. top: 0;
  197. transform: translateX(-50%) rotateX(180deg);
  198. width: $thickness + px;
  199. height: 100%;
  200. .ers-flow {
  201. transform: translateY(-100%);
  202. animation: amtErsVertical infinite both linear;
  203. .ers {
  204. right: $thickness / 2 + px;
  205. bottom: -$thickness / 2 + px;
  206. transform-origin: 100% $thickness / 2 + px;
  207. transform: rotateZ(90deg);
  208. }
  209. }
  210. }
  211. &.ers-debug {
  212. .ers-edge {
  213. overflow: visible;
  214. .ers-flow {
  215. border: 3px solid #fff;
  216. .ers {
  217. border: 3px solid #1984ff;
  218. }
  219. }
  220. }
  221. }
  222. &.ers-double {
  223. .ers-top .ers-flow {
  224. animation-name: amtErsHorizontalDouble;
  225. }
  226. .ers-right .ers-flow {
  227. animation-name: amtErsVerticalDouble;
  228. }
  229. .ers-bottom .ers-flow {
  230. animation-name: amtErsHorizontalDouble;
  231. }
  232. .ers-left .ers-flow {
  233. animation-name: amtErsVerticalDouble;
  234. }
  235. }
  236. }
  237. @keyframes amtErsHorizontal {
  238. from {
  239. opacity: 1;
  240. transform: translateX(-100%);
  241. }
  242. 50% {
  243. opacity: 1;
  244. }
  245. to {
  246. opacity: 1;
  247. transform: translateX(300%);
  248. }
  249. }
  250. @keyframes amtErsVertical {
  251. from {
  252. opacity: 1;
  253. transform: translateY(-100%);
  254. }
  255. 50% {
  256. opacity: 1;
  257. }
  258. to {
  259. opacity: 1;
  260. transform: translateY(300%);
  261. }
  262. }
  263. @keyframes amtErsHorizontalDouble {
  264. from {
  265. opacity: 1;
  266. transform: translateX(-100%);
  267. }
  268. 50% {
  269. opacity: 1;
  270. }
  271. to {
  272. opacity: 1;
  273. transform: translateX(100%);
  274. }
  275. }
  276. @keyframes amtErsVerticalDouble {
  277. from {
  278. opacity: 1;
  279. transform: translateY(-100%);
  280. }
  281. 50% {
  282. opacity: 1;
  283. }
  284. to {
  285. opacity: 1;
  286. transform: translateY(100%);
  287. }
  288. }
  289. </style>