如何获得centerY
和centerX
这个对象“区域”。两者均返回NaN,因为this.left
和this.right
返回NULL:
const area = {
top: viewportHeight * 20 / 100,
bottom: viewportHeight - (viewportHeight * 20 / 100),
left: 300,
right: (viewportWidth * 30 / 100) + 300,
centerX: (this.left + this.right) / 2, // NaN
centerY: (this.top + this.bottom) / 2, // NaN
};