.notice-text{
overflow: hidden;
white-space: nowrap;
}
.marqueeText_style {
-webkit-animation: marqueeText 5s linear 1s infinite;
animation: marqueeText 5s linear 1s infinite;
white-space: nowrap;
}
@keyframes marqueeText {
from {
text-indent:0%;
}
to {
text-indent:-200%;
}
/* from {
transform: translateX(0%);
-webkit-transform: translateX(0%);
}
to {
transform: translateX(-100%);
-webkit-transform: translateX(-100%);
} */
}
js中textWidth=文字长度*文字大小(我是40rpx的字号,所以填了20)
getSwiperWidth(){
const that = this
var obj = wx.createSelectorQuery();
obj.select('.playInfo').boundingClientRect(function (rect) {
if(rect){
const textWidth = that.data.currentActivity.themeName.length * 20
const swiperWidth = rect.width
console.log('textWidth > swiperWidth?',textWidth , swiperWidth);
that.setData({
hasMarquee: textWidth > swiperWidth ? true : false
})
}
})
obj.exec() ;
},
html: