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)
},
微信小程序图片在视频上运动,触边反弹,全屏可用
最新推荐文章于 2024-06-17 23:49:16 发布