Ball animation adaptation

// if the fixed die position of the ball, if different handsets in different resolutions, will result in different final ball position, bad sports results

// optimization ideas ball animation:

// 1. Logo to obtain horizontal and vertical coordinates, and then to obtain pellets of horizontal and vertical coordinates, the result obtained by subtracting the two is required to move the position of the ball

//2.使用DomObj.getBoundingClientRect();

// Code processing is as follows:

var ballPosition = this.$refs.ball.getBoundingClientRect();
var bagePosition = document.getElementById("bage").getBoundingClientRect();
var x = bagePosition.left - ballPosition.left;
var y = bagePosition.top - ballPosition.top;
el.style.transform = `translate(${x}px,${y}px)`;//这里使用了。

Guess you like

Origin www.cnblogs.com/hou-yuan-zhen/p/11582420.html