@nutui/nutui 4.0.0-beta.18 → 4.0.0-beta.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { useSlots, computed, ref, onMounted, onUnmounted, onDeactivated, watch, nextTick, openBlock, createElementBlock, normalizeClass, createElementVNode, renderSlot, createCommentVNode } from "vue";
1
+ import { useSlots, computed, ref, onMounted, onUnmounted, watch, nextTick, openBlock, createElementBlock, normalizeClass, createElementVNode, renderSlot, createCommentVNode } from "vue";
2
2
  import { c as createComponent } from "./component-81a4c1d0.js";
3
3
  import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
4
4
  import "../locale/lang";
@@ -31,7 +31,6 @@ const _sfc_main = create({
31
31
  default: true
32
32
  }
33
33
  },
34
- emits: ["click"],
35
34
  setup(props, { slots }) {
36
35
  const classTime = new Date().getTime();
37
36
  const slotDefault = !!useSlots().default;
@@ -51,6 +50,13 @@ const _sfc_main = create({
51
50
  const speeds = props.speeds;
52
51
  const danmuCWidth = ref(0);
53
52
  onMounted(() => {
53
+ init();
54
+ });
55
+ onUnmounted(() => {
56
+ danmuList.value = [];
57
+ clearTime();
58
+ });
59
+ const init = () => {
54
60
  var _a;
55
61
  danmuCWidth.value = dmBody.value.offsetWidth;
56
62
  if (slotDefault) {
@@ -70,17 +76,11 @@ const _sfc_main = create({
70
76
  (_a2 = dmBody.value) == null ? void 0 : _a2.style.setProperty("--move-distance", `-${danmuCWidth.value}px`);
71
77
  run();
72
78
  }, 300);
73
- });
74
- onUnmounted(() => {
75
- danmuList.value = [];
76
- clearInterval(timer);
77
- timer = 0;
78
- });
79
- onDeactivated(() => {
80
- danmuList.value = [];
81
- clearInterval(timer);
79
+ };
80
+ const clearTime = () => {
81
+ clearTimeout(timer);
82
82
  timer = 0;
83
- });
83
+ };
84
84
  watch(
85
85
  () => props.danmu,
86
86
  (newValue) => {
@@ -98,8 +98,7 @@ const _sfc_main = create({
98
98
  }
99
99
  };
100
100
  const run = () => {
101
- clearInterval(timer);
102
- timer = 0;
101
+ clearTime();
103
102
  timer = setTimeout(() => {
104
103
  play();
105
104
  run();
@@ -132,20 +131,15 @@ const _sfc_main = create({
132
131
  el.style.width = width + 20 + "px";
133
132
  }
134
133
  el.dataset.index = `${_index}`;
135
- if (slotDefault) {
136
- index2.value++;
137
- el.addEventListener("animationend", () => {
138
- var _a3;
139
- if ((_a3 = el == null ? void 0 : el.classList) == null ? void 0 : _a3.contains("move")) {
140
- el.classList.remove("move");
141
- }
142
- });
143
- } else {
144
- el.addEventListener("animationend", () => {
134
+ el.addEventListener("animationend", () => {
135
+ var _a3;
136
+ if (slotDefault) {
137
+ ((_a3 = el == null ? void 0 : el.classList) == null ? void 0 : _a3.contains("move")) && el.classList.remove("move");
138
+ } else {
145
139
  dmContainer.value.removeChild(el);
146
- });
147
- index2.value++;
148
- }
140
+ }
141
+ });
142
+ index2.value++;
149
143
  });
150
144
  };
151
145
  return { classTime, classes, danmuList, dmBody, dmContainer, add };
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
4
  "name": "NutUI",
5
- "version": "4.0.0-beta.18",
5
+ "version": "4.0.0-beta.19",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "tags": [
@@ -616,7 +616,7 @@
616
616
  },
617
617
  {
618
618
  "name": "speeds",
619
- "default": "`2000`",
619
+ "default": "`5000`",
620
620
  "description": "每个弹幕的滚动时间",
621
621
  "value": {
622
622
  "type": "number",
@@ -625,7 +625,7 @@
625
625
  },
626
626
  {
627
627
  "name": "rows",
628
- "default": "`1`",
628
+ "default": "`3`",
629
629
  "description": "弹幕行数,分几行展示",
630
630
  "value": {
631
631
  "type": "number",