diff --git a/src/input/__test__/demo.test.js b/src/input/__test__/demo.test.js index cdffa0aab..603f344e8 100644 --- a/src/input/__test__/demo.test.js +++ b/src/input/__test__/demo.test.js @@ -5,7 +5,21 @@ import path from 'path'; import simulate from 'miniprogram-simulate'; -const mapper = ['align', 'banner', 'base', 'bordered', 'custom', 'label', 'layout', 'maxlength', 'prefix', 'size', 'special', 'status', 'suffix']; +const mapper = [ + 'align', + 'banner', + 'base', + 'bordered', + 'custom', + 'label', + 'layout', + 'maxlength', + 'prefix', + 'size', + 'special', + 'status', + 'suffix', +]; describe('Input', () => { mapper.forEach((demoName) => { diff --git a/src/notice-bar/notice-bar.less b/src/notice-bar/notice-bar.less index 271f9367b..c1b2b52c7 100644 --- a/src/notice-bar/notice-bar.less +++ b/src/notice-bar/notice-bar.less @@ -43,6 +43,7 @@ } &__content--vertical { + display: block; height: @notice-bar-line-height; line-height: @notice-bar-line-height; diff --git a/src/notice-bar/notice-bar.ts b/src/notice-bar/notice-bar.ts index ff68277e5..de69cedc3 100644 --- a/src/notice-bar/notice-bar.ts +++ b/src/notice-bar/notice-bar.ts @@ -97,29 +97,31 @@ export default class NoticeBar extends SuperComponent { const warpID = `.${name}__content-wrap`; const nodeID = `.${name}__content`; getAnimationFrame(this, () => { - Promise.all([getRect(this, nodeID), getRect(this, warpID)]).then(([nodeRect, wrapRect]) => { - const { marquee } = this.properties; - - if (nodeRect == null || wrapRect == null || !nodeRect.width || !wrapRect.width) { - return; - } - - if (marquee || wrapRect.width < nodeRect.width) { - const speeding = marquee.speed || 50; - const delaying = marquee.delay || 0; - const animationDuration = ((wrapRect.width + nodeRect.width) / speeding) * 1000; - const firstAnimationDuration = (nodeRect.width / speeding) * 1000; - this.setData({ - wrapWidth: Number(wrapRect.width), - nodeWidth: Number(nodeRect.width), - animationDuration: animationDuration, - delay: delaying, - loop: marquee.loop - 1, - firstAnimationDuration: firstAnimationDuration, - }); - marquee.loop !== 0 && this.startScrollAnimation(true); - } - }); + Promise.all([getRect(this, nodeID), getRect(this, warpID)]) + .then(([nodeRect, wrapRect]) => { + const { marquee } = this.properties; + + if (nodeRect == null || wrapRect == null || !nodeRect.width || !wrapRect.width) { + return; + } + + if (marquee || wrapRect.width < nodeRect.width) { + const speeding = marquee.speed || 50; + const delaying = marquee.delay || 0; + const animationDuration = ((wrapRect.width + nodeRect.width) / speeding) * 1000; + const firstAnimationDuration = (nodeRect.width / speeding) * 1000; + this.setData({ + wrapWidth: Number(wrapRect.width), + nodeWidth: Number(nodeRect.width), + animationDuration: animationDuration, + delay: delaying, + loop: marquee.loop - 1, + firstAnimationDuration: firstAnimationDuration, + }); + marquee.loop !== 0 && this.startScrollAnimation(true); + } + }) + .catch(() => {}); }); }, diff --git a/src/notice-bar/notice-bar.wxml b/src/notice-bar/notice-bar.wxml index 7bed99aa7..d61f322cc 100644 --- a/src/notice-bar/notice-bar.wxml +++ b/src/notice-bar/notice-bar.wxml @@ -26,7 +26,7 @@ circular="true" interval="{{interval}}" display-multiple-items="1" - class="{{classPrefix}}__content--vertical" + class="{{classPrefix}}__content {{classPrefix}}__content--vertical" bindchange="onChange" > diff --git a/src/rate/__test__/demo.test.js b/src/rate/__test__/demo.test.js index fe7849981..4d10e7c23 100644 --- a/src/rate/__test__/demo.test.js +++ b/src/rate/__test__/demo.test.js @@ -5,7 +5,18 @@ import path from 'path'; import simulate from 'miniprogram-simulate'; -const mapper = ['action', 'base', 'color', 'count', 'custom', 'custom-prefix', 'show-text', 'size', 'special', 'un-filled']; +const mapper = [ + 'action', + 'base', + 'color', + 'count', + 'custom', + 'custom-prefix', + 'show-text', + 'size', + 'special', + 'un-filled', +]; describe('Rate', () => { mapper.forEach((demoName) => {