mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-05-29 09:49:16 +08:00
[bugfix] Noticebar: 修复元素查询返回空,导致报错的问题 (#130)
* change quota * 修复 noticebar 查询
This commit is contained in:
parent
9092f26dd4
commit
56605cc5f3
@ -1,4 +1,4 @@
|
|||||||
var ZanNoticeBar = {
|
const ZanNoticeBar = {
|
||||||
initZanNoticeBarScroll(componentId) {
|
initZanNoticeBarScroll(componentId) {
|
||||||
this.zanNoticeBarNode = this.zanNoticeBarNode || {};
|
this.zanNoticeBarNode = this.zanNoticeBarNode || {};
|
||||||
this.zanNoticeBarNode[`${componentId}`] = {
|
this.zanNoticeBarNode[`${componentId}`] = {
|
||||||
@ -7,38 +7,53 @@ var ZanNoticeBar = {
|
|||||||
animation: null,
|
animation: null,
|
||||||
resetAnimation: null
|
resetAnimation: null
|
||||||
};
|
};
|
||||||
var currentComponent = this.zanNoticeBarNode[`${componentId}`];
|
|
||||||
wx.createSelectorQuery().select(`#${componentId}__content`).boundingClientRect((rect) => {
|
const currentComponent = this.zanNoticeBarNode[`${componentId}`];
|
||||||
if (rect.width) {
|
wx.createSelectorQuery()
|
||||||
|
.in(this)
|
||||||
|
.select(`#${componentId}__content`)
|
||||||
|
.boundingClientRect((rect) => {
|
||||||
|
if (!rect || !rect.width) {
|
||||||
|
console.warn('页面缺少 noticebar 元素');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
currentComponent.width = rect.width;
|
currentComponent.width = rect.width;
|
||||||
wx.createSelectorQuery().select(`#${componentId}__content-wrap`).boundingClientRect((rect) => {
|
wx
|
||||||
currentComponent.wrapWidth = rect.width;
|
.createSelectorQuery()
|
||||||
if (currentComponent.wrapWidth < currentComponent.width) {
|
.in(this)
|
||||||
var mstime = currentComponent.width / 40 * 1000;
|
.select(`#${componentId}__content-wrap`)
|
||||||
currentComponent.animation = wx.createAnimation({
|
.boundingClientRect((rect) => {
|
||||||
duration: mstime,
|
if (!rect || !rect.width) {
|
||||||
timingFunction: 'linear'
|
return;
|
||||||
});
|
}
|
||||||
currentComponent.resetAnimation = wx.createAnimation({
|
|
||||||
duration: 0,
|
currentComponent.wrapWidth = rect.width;
|
||||||
timingFunction: 'linear'
|
if (currentComponent.wrapWidth < currentComponent.width) {
|
||||||
});
|
var mstime = currentComponent.width / 40 * 1000;
|
||||||
this.scrollZanNoticeBar(componentId, mstime);
|
currentComponent.animation = wx.createAnimation({
|
||||||
}
|
duration: mstime,
|
||||||
}).exec();
|
timingFunction: 'linear'
|
||||||
} else {
|
});
|
||||||
console.warn('页面缺少 noticebar 元素');
|
currentComponent.resetAnimation = wx.createAnimation({
|
||||||
}
|
duration: 0,
|
||||||
}).exec();
|
timingFunction: 'linear'
|
||||||
|
});
|
||||||
|
this.scrollZanNoticeBar(componentId, mstime);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.exec();
|
||||||
|
})
|
||||||
|
.exec();
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollZanNoticeBar(componentId, mstime) {
|
scrollZanNoticeBar(componentId, mstime) {
|
||||||
var currentComponent = this.zanNoticeBarNode[`${componentId}`];
|
const currentComponent = this.zanNoticeBarNode[`${componentId}`];
|
||||||
var resetAnimationData = currentComponent.resetAnimation.translateX(currentComponent.wrapWidth).step();
|
const resetAnimationData = currentComponent.resetAnimation.translateX(currentComponent.wrapWidth).step();
|
||||||
this.setData({
|
this.setData({
|
||||||
[`${componentId}.animationData`]: resetAnimationData.export()
|
[`${componentId}.animationData`]: resetAnimationData.export()
|
||||||
});
|
});
|
||||||
var aninationData = currentComponent.animation.translateX(-mstime * 40 / 1000).step();
|
const aninationData = currentComponent.animation.translateX(-mstime * 40 / 1000).step();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.setData({
|
this.setData({
|
||||||
[`${componentId}.animationData`]: aninationData.export()
|
[`${componentId}.animationData`]: aninationData.export()
|
||||||
|
@ -155,7 +155,7 @@ module.exports = {
|
|||||||
keywords: ['contact'],
|
keywords: ['contact'],
|
||||||
src: '联系人.svg',
|
src: '联系人.svg',
|
||||||
css: 'contact',
|
css: 'contact',
|
||||||
'correct_contour_direction': true
|
correct_contour_direction: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
keywords: ['wechat'],
|
keywords: ['wechat'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user