riku
2024-11-14 00a96d6881dd10ae7d3c4f5437bfceaabe677723
miniprogram_npm/tdesign-miniprogram/notice-bar/notice-bar.js
@@ -27,14 +27,15 @@
            `${prefix}-class-suffix-icon`,
        ];
        this.options = {
            styleIsolation: 'apply-shared',
            multipleSlots: true,
            pureDataPattern: /^__/,
        };
        this.properties = props;
        this.data = {
            prefix,
            classPrefix: name,
            loop: -1,
            __ready: false,
        };
        this.observers = {
            marquee(val) {
@@ -49,6 +50,8 @@
                }
            },
            visible(visible) {
                if (!this.data.__ready)
                    return;
                if (visible) {
                    this.show();
                }
@@ -65,6 +68,8 @@
                });
            },
            content() {
                if (!this.data.__ready)
                    return;
                this.clearNoticeBarAnimation();
                this.initAnimation();
            },
@@ -81,6 +86,7 @@
            },
            ready() {
                this.show();
                this.setData({ __ready: true });
            },
        };
        this.methods = {
@@ -88,7 +94,8 @@
                const warpID = `.${name}__content-wrap`;
                const nodeID = `.${name}__content`;
                getAnimationFrame(this, () => {
                    Promise.all([getRect(this, nodeID), getRect(this, warpID)]).then(([nodeRect, wrapRect]) => {
                    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;
@@ -108,7 +115,8 @@
                            });
                            marquee.loop !== 0 && this.startScrollAnimation(true);
                        }
                    });
                    })
                        .catch(() => { });
                });
            },
            startScrollAnimation(isFirstScroll = false) {
@@ -159,6 +167,10 @@
                    _prefixIcon: calcIcon(v, THEME_ICON[theme]),
                });
            },
            onChange(e) {
                const { current, source } = e.detail;
                this.triggerEvent('change', { current, source });
            },
            clickPrefixIcon() {
                this.triggerEvent('click', { trigger: 'prefix-icon' });
            },