全屏可用"/>
微信小程序图片在视频上运动,触边反弹,全屏可用
data() {return {theWidth: null, //可视最大宽theHeight: null, //可视最大高thex: 0, //动态x they: 0, //动态y speed:50, //X运动速度speed2:50, //Y运动速度ee:null, //全屏事件对象}move(){this.timer = setInterval(()=>{this.thex = this.thex + this.speed;this.they = this.they + this.speed2;if(this.thex >= this.theWidth){ this.thex = this.theWidth;this.speed = -this.speed;}else if(this.thex <= 0){this.thex = 0;this.speed = -this.speed;};if(this.they >= this.theHeight){this.they = this.theHeight;this.speed2 = -this.speed2;}else if(this.they <= 0){this.they = 0;this.speed2 = -this.speed2;} },1000)},screenChange(e){//全屏与退出全屏都要重新获取可视宽高this.ee = e;setTimeout(()=>{console.log("全屏或者退出全屏!!!");let getWindowInfo = uni.getWindowInfo();console.log("getWindowInfo=>",getWindowInfo);this.maxWidth = getWindowInfo.windowWidth;this.maxHeight = getWindowInfo.windowHeight;this.theWidth = (this.maxWidth * 2) - 160;console.log("this.theWidth=>", this.theWidth);this.theHeight = (this.maxHeight * 2) - 160;console.log("this.theHeight=>", this.theHeight);if(this.ee.detail.fullscreen == true){this.showMenu = false;console.log("全屏");}else if(this.ee.detail.fullscreen == false){this.showMenu = true;console.log("非全屏");}},1000)},
更多推荐
微信小程序图片在视频上运动,触边反弹,全屏可用
发布评论