Skip to content

Commit

Permalink
feat(NoticeBar): add replay event (youzan#6079)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Apr 17, 2020
1 parent 31674a1 commit e95e097
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/notice-bar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ Vue.use(NoticeBar);

### Events

| Event | Description | Arguments |
| ----- | ------------------------------ | -------------- |
| click | Triggered when click NoticeBar | _event: Event_ |
| close | Triggered when closed | _event: Event_ |
| Event | Description | Arguments |
| --------------- | ------------------------------ | -------------- |
| click | Triggered when click NoticeBar | _event: Event_ |
| close | Triggered when closed | _event: Event_ |
| replay `v2.6.2` | Triggered when replay | - |

### Slots

Expand Down
9 changes: 5 additions & 4 deletions src/notice-bar/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ Vue.use(NoticeBar);

### Events

| 事件名 | 说明 | 回调参数 |
| ------ | ---------------- | -------------- |
| click | 点击通知栏时触发 | _event: Event_ |
| close | 关闭通知栏时触发 | _event: Event_ |
| 事件名 | 说明 | 回调参数 |
| --------------- | ---------------------------- | -------------- |
| click | 点击通知栏时触发 | _event: Event_ |
| close | 关闭通知栏时触发 | _event: Event_ |
| replay `v2.6.2` | 每当滚动栏重新开始滚动时触发 | - |

### Slots

Expand Down
1 change: 1 addition & 0 deletions src/notice-bar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default createComponent({
this.$nextTick(() => {
this.duration = (this.offsetWidth + this.wrapWidth) / this.speed;
this.animationClass = bem('play--infinite');
this.$emit('replay');
});
},
},
Expand Down
14 changes: 13 additions & 1 deletion src/notice-bar/test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NoticeBar from '..';
import { mount } from '../../../test';
import { mount, later } from '../../../test';

test('click event', () => {
const wrapper = mount(NoticeBar);
Expand Down Expand Up @@ -36,3 +36,15 @@ test('icon slot', () => {

expect(wrapper).toMatchSnapshot();
});

test('replay event', async () => {
const wrapper = mount(NoticeBar, {
propsData: {
text: 'foo',
},
});

wrapper.find('.van-notice-bar__content').trigger('animationend');
await later();
expect(wrapper.emitted('replay')).toBeTruthy();
});

0 comments on commit e95e097

Please sign in to comment.