notic() {
// 頁面顯示
var that = this;
var length = that.data.text.length * that.data.size; //文字長度
var windowWidth = wx.getSystemInfoSync().windowWidth; // 屏幕寬度
//console.log(length,windowWidth);
that.setData({
length: length,
windowWidth: windowWidth
});
that.scrolltxt(); // 第一個字消失後當即從右邊出現
},
scrolltxt: function() {
var that = this;
var length = that.data.length; //滾動文字的寬度
var windowWidth = that.data.windowWidth; //屏幕寬度
if (length > windowWidth) {
var interval = setInterval(function() {
var maxscrollwidth = length + that.data.marquee_margin; //滾動的最大寬度,文字寬度+間距,若是須要一行文字滾完後再顯示第二行能夠修改marquee_margin值等於windowWidth便可
var crentleft = that.data.marqueeDistance;
if (crentleft < maxscrollwidth) { //判斷是否滾動到最大寬度
that.setData({
marqueeDistance: crentleft + that.data.marqueePace
})
} else {
//console.log("替換");
that.setData({
marqueeDistance: 0 // 直接從新滾動
});
clearInterval(interval);
that.scrolltxt();
}
}, that.data.interval);
} else {
that.setData({
marquee_margin: "1000"
}); //只顯示一條不滾動右邊間距加大,防止重複顯示
}
},