RollingTextItem.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. var __defProp = Object.defineProperty;
  2. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  3. var __getOwnPropNames = Object.getOwnPropertyNames;
  4. var __hasOwnProp = Object.prototype.hasOwnProperty;
  5. var __export = (target, all) => {
  6. for (var name2 in all)
  7. __defProp(target, name2, { get: all[name2], enumerable: true });
  8. };
  9. var __copyProps = (to, from, except, desc) => {
  10. if (from && typeof from === "object" || typeof from === "function") {
  11. for (let key of __getOwnPropNames(from))
  12. if (!__hasOwnProp.call(to, key) && key !== except)
  13. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  14. }
  15. return to;
  16. };
  17. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  18. var stdin_exports = {};
  19. __export(stdin_exports, {
  20. default: () => stdin_default,
  21. props: () => props
  22. });
  23. module.exports = __toCommonJS(stdin_exports);
  24. var import_vue = require("vue");
  25. var import_utils = require("../utils");
  26. const props = {
  27. figureArr: (0, import_utils.makeArrayProp)(),
  28. delay: Number,
  29. duration: (0, import_utils.makeNumberProp)(2),
  30. isStart: Boolean,
  31. direction: (0, import_utils.makeStringProp)("down"),
  32. height: (0, import_utils.makeNumberProp)(40)
  33. };
  34. const [name, bem] = (0, import_utils.createNamespace)("rolling-text-item");
  35. var stdin_default = (0, import_vue.defineComponent)({
  36. name,
  37. props,
  38. setup(props2) {
  39. const newFigureArr = (0, import_vue.computed)(() => props2.direction === "down" ? props2.figureArr.slice().reverse() : props2.figureArr);
  40. const translatePx = (0, import_vue.computed)(() => {
  41. const totalHeight = props2.height * (props2.figureArr.length - 1);
  42. return `-${totalHeight}px`;
  43. });
  44. const itemStyle = (0, import_vue.computed)(() => ({
  45. lineHeight: (0, import_utils.addUnit)(props2.height)
  46. }));
  47. const rootStyle = (0, import_vue.computed)(() => ({
  48. height: (0, import_utils.addUnit)(props2.height),
  49. "--van-translate": translatePx.value,
  50. "--van-duration": props2.duration + "s",
  51. "--van-delay": props2.delay + "s"
  52. }));
  53. return () => (0, import_vue.createVNode)("div", {
  54. "class": bem([props2.direction]),
  55. "style": rootStyle.value
  56. }, [(0, import_vue.createVNode)("div", {
  57. "class": bem("box", {
  58. animate: props2.isStart
  59. })
  60. }, [Array.isArray(newFigureArr.value) && newFigureArr.value.map((figure) => (0, import_vue.createVNode)("div", {
  61. "class": bem("item"),
  62. "style": itemStyle.value
  63. }, [figure]))])]);
  64. }
  65. });