mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(NoticeBar): add replay event (#6079)
This commit is contained in:
parent
31674a162c
commit
e95e09764a
@ -72,9 +72,10 @@ Vue.use(NoticeBar);
|
|||||||
### Events
|
### Events
|
||||||
|
|
||||||
| Event | Description | Arguments |
|
| Event | Description | Arguments |
|
||||||
| ----- | ------------------------------ | -------------- |
|
| --------------- | ------------------------------ | -------------- |
|
||||||
| click | Triggered when click NoticeBar | _event: Event_ |
|
| click | Triggered when click NoticeBar | _event: Event_ |
|
||||||
| close | Triggered when closed | _event: Event_ |
|
| close | Triggered when closed | _event: Event_ |
|
||||||
|
| replay `v2.6.2` | Triggered when replay | - |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -80,9 +80,10 @@ Vue.use(NoticeBar);
|
|||||||
### Events
|
### Events
|
||||||
|
|
||||||
| 事件名 | 说明 | 回调参数 |
|
| 事件名 | 说明 | 回调参数 |
|
||||||
| ------ | ---------------- | -------------- |
|
| --------------- | ---------------------------- | -------------- |
|
||||||
| click | 点击通知栏时触发 | _event: Event_ |
|
| click | 点击通知栏时触发 | _event: Event_ |
|
||||||
| close | 关闭通知栏时触发 | _event: Event_ |
|
| close | 关闭通知栏时触发 | _event: Event_ |
|
||||||
|
| replay `v2.6.2` | 每当滚动栏重新开始滚动时触发 | - |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ export default createComponent({
|
|||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.duration = (this.offsetWidth + this.wrapWidth) / this.speed;
|
this.duration = (this.offsetWidth + this.wrapWidth) / this.speed;
|
||||||
this.animationClass = bem('play--infinite');
|
this.animationClass = bem('play--infinite');
|
||||||
|
this.$emit('replay');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import NoticeBar from '..';
|
import NoticeBar from '..';
|
||||||
import { mount } from '../../../test';
|
import { mount, later } from '../../../test';
|
||||||
|
|
||||||
test('click event', () => {
|
test('click event', () => {
|
||||||
const wrapper = mount(NoticeBar);
|
const wrapper = mount(NoticeBar);
|
||||||
@ -36,3 +36,15 @@ test('icon slot', () => {
|
|||||||
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
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();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user