ソースを参照

Merge branch 'next' of https://github.com/jdf2e/nutui into next

Drjnigfubo 3 年 前
コミット
162645bbae

+ 10 - 0
src/packages/__VUE/noticebar/__tests__/noticebar.spec.ts

@@ -45,6 +45,16 @@ test('close event', async () => {
   expect(content.html()).toContain('123');
   expect(content.html()).toContain('123');
 });
 });
 
 
+test('across-end event', async () => {
+  const wrapper = mount(NoticeBar, {
+    props: {
+      text: 'NutUI 是京东风格的移动端组件库,使用 Vue 语言来编写可以在 H5,小程序平台上的应用,帮助研发人员提升开发效率,改善开发体验。'
+    }
+  });
+  wrapper.vm.onAnimationEnd();
+  expect(wrapper.emitted('across-end')).toBeTruthy();
+});
+
 test('slot event', async () => {
 test('slot event', async () => {
   const wrapper = mount(NoticeBar, {
   const wrapper = mount(NoticeBar, {
     slots: {
     slots: {

+ 24 - 4
src/packages/__VUE/noticebar/demo.vue

@@ -68,11 +68,19 @@
         </template>
         </template>
       </nut-noticebar>
       </nut-noticebar>
     </div>
     </div>
+
+    <h2>{{ translate('scrollEvent') }}</h2>
+    <div class="interstroll-list">
+      <nut-noticebar
+        :text="`${translate('text')} - ${translate('scrollCount')}:[${acrossCount}]`"
+        @across-end="onAcrossEnd"
+      />
+    </div>
   </div>
   </div>
 </template>
 </template>
 
 
 <script lang="ts">
 <script lang="ts">
-import { onMounted, reactive, toRefs } from 'vue';
+import { reactive, toRefs } from 'vue';
 import { createComponent } from '@/packages/utils/create';
 import { createComponent } from '@/packages/utils/create';
 const { createDemo, translate } = createComponent('noticebar');
 const { createDemo, translate } = createComponent('noticebar');
 import { useTranslate } from '@/sites/assets/util/useTranslate';
 import { useTranslate } from '@/sites/assets/util/useTranslate';
@@ -91,7 +99,9 @@ const initTranslate = () =>
       text: 'NutUI 是京东风格的移动端组件库,使用 Vue 语言来编写可以在 H5,小程序平台上的应用,帮助研发人员提升开发效率,改善开发体验。',
       text: 'NutUI 是京东风格的移动端组件库,使用 Vue 语言来编写可以在 H5,小程序平台上的应用,帮助研发人员提升开发效率,改善开发体验。',
       textShort: 'NutUI 是移动端组件库',
       textShort: 'NutUI 是移动端组件库',
       horseLamp: ['NoticeBar 公告栏', 'Cascader 级联选择', 'DatePicker 日期选择器', 'CheckBox 复选按钮'],
       horseLamp: ['NoticeBar 公告栏', 'Cascader 级联选择', 'DatePicker 日期选择器', 'CheckBox 复选按钮'],
-      jd: '京东商城'
+      jd: '京东商城',
+      scrollCount: '滚动次数',
+      scrollEvent: '横向 - 滚动结束事件'
     },
     },
     'en-US': {
     'en-US': {
       basic: 'Basic Usage',
       basic: 'Basic Usage',
@@ -105,7 +115,9 @@ const initTranslate = () =>
       text: 'Nutui is a Jingdong style mobile terminal component library. It uses Vue language to write applications that can be used on H5 and applet platforms to help R & D personnel improve development efficiency and development experience.',
       text: 'Nutui is a Jingdong style mobile terminal component library. It uses Vue language to write applications that can be used on H5 and applet platforms to help R & D personnel improve development efficiency and development experience.',
       textShort: 'Nutui is a mobile terminal component library.',
       textShort: 'Nutui is a mobile terminal component library.',
       horseLamp: ['NoticeBar', 'Cascader', 'DatePicker', 'CheckBox'],
       horseLamp: ['NoticeBar', 'Cascader', 'DatePicker', 'CheckBox'],
-      jd: 'Jingdong'
+      jd: 'Jingdong',
+      scrollCount: 'scroll count',
+      scrollEvent: 'across - scrolling end event'
     }
     }
   });
   });
 
 
@@ -117,7 +129,8 @@ export default createDemo({
       horseLamp1: translate('horseLamp'),
       horseLamp1: translate('horseLamp'),
       horseLamp2: translate('horseLamp'),
       horseLamp2: translate('horseLamp'),
       horseLamp3: translate('horseLamp'),
       horseLamp3: translate('horseLamp'),
-      text: translate('text')
+      text: translate('text'),
+      acrossCount: 0
     });
     });
 
 
     const hello = () => {
     const hello = () => {
@@ -127,10 +140,16 @@ export default createDemo({
       console.log(item);
       console.log(item);
     };
     };
 
 
+    const onAcrossEnd = () => {
+      state.acrossCount++;
+      console.log('动画结束');
+    };
+
     return {
     return {
       ...toRefs(state),
       ...toRefs(state),
       hello,
       hello,
       go,
       go,
+      onAcrossEnd,
       translate
       translate
     };
     };
   }
   }
@@ -147,6 +166,7 @@ export default createDemo({
     color: $dark-color;
     color: $dark-color;
   }
   }
 }
 }
+
 .demo {
 .demo {
   padding-bottom: 30px !important;
   padding-bottom: 30px !important;
 
 

+ 1 - 0
src/packages/__VUE/noticebar/doc.en-US.md

@@ -254,3 +254,4 @@ When text is long, you can enable multi-line display by setting the wrapable pro
 | ---------- | --------------------------------------- | ------------ |
 | ---------- | --------------------------------------- | ------------ |
 | click      | Emitted when NoticeBar is clicked       | event: Event |
 | click      | Emitted when NoticeBar is clicked       | event: Event |
 | close      | Emitted when NoticeBar is closed        | event: Event |
 | close      | Emitted when NoticeBar is closed        | event: Event |
+| across-end | Emitted when across scrolling ends      | event: Event |

+ 2 - 1
src/packages/__VUE/noticebar/doc.md

@@ -254,4 +254,5 @@ app.use(NoticeBar);
 | 字段  | 说明             | 回调参数     |
 | 字段  | 说明             | 回调参数     |
 | ----- | ---------------- | ------------ |
 | ----- | ---------------- | ------------ |
 | click | 外层点击事件回调 | event: Event |
 | click | 外层点击事件回调 | event: Event |
-| close | 关闭通知栏时触发 | event: Event |
+| close | 关闭通知栏时触发 | event: Event |
+| across-end | 横向滚动结束时触发 | event: Event |

+ 3 - 3
src/packages/__VUE/noticebar/index.taro.vue

@@ -152,7 +152,7 @@ export default create({
       return h(props.item);
       return h(props.item);
     }
     }
   },
   },
-  emits: ['click', 'close'],
+  emits: ['click', 'close', 'across-end'],
 
 
   setup(props, { emit, slots }) {
   setup(props, { emit, slots }) {
     // console.log('componentName', componentName);
     // console.log('componentName', componentName);
@@ -308,9 +308,9 @@ export default create({
       emit('close', event);
       emit('close', event);
     };
     };
 
 
-    const onAnimationEnd = () => {
+    const onAnimationEnd = (event: Event) => {
       state.firstRound = false;
       state.firstRound = false;
-
+      emit('across-end', event);
       setTimeout(() => {
       setTimeout(() => {
         state.duration = (state.offsetWidth + state.wrapWidth) / props.speed;
         state.duration = (state.offsetWidth + state.wrapWidth) / props.speed;
         state.animationClass = 'play-infinite';
         state.animationClass = 'play-infinite';

+ 3 - 3
src/packages/__VUE/noticebar/index.vue

@@ -163,7 +163,7 @@ export default create({
       return h(props.item);
       return h(props.item);
     }
     }
   },
   },
-  emits: ['click', 'close'],
+  emits: ['click', 'close', 'across-end'],
 
 
   setup(props, { emit, slots }) {
   setup(props, { emit, slots }) {
     // console.log('componentName', componentName);
     // console.log('componentName', componentName);
@@ -306,9 +306,9 @@ export default create({
       emit('close', event);
       emit('close', event);
     };
     };
 
 
-    const onAnimationEnd = () => {
+    const onAnimationEnd = (event: Event) => {
       state.firstRound = false;
       state.firstRound = false;
-
+      emit('across-end', event);
       setTimeout(() => {
       setTimeout(() => {
         state.duration = (state.offsetWidth + state.wrapWidth) / props.speed;
         state.duration = (state.offsetWidth + state.wrapWidth) / props.speed;
         state.animationClass = 'play-infinite';
         state.animationClass = 'play-infinite';