拖拽旋转的怎么角度怎么算呀?
来源:16-11 年龄分布图表组件开发

希卡利
2020-09-09
算了两天,硬是没算出来,太菜了
我可以获取到 被选物 的位置信息和宽高信息计算出中心点
鼠标 按下 事件获取 开始点位
鼠标 移动 事件获取 当前点位
计算一次完后 当前点位变成下一次的开始点位
这是我目前的算法 但是算不出来呀
const { clientX, clientY } = event
const central = this.central // 圆心点
const start = [this.prevX, this.prevY] // 开始点
const current = [clientX, clientY] // 当前点
const rad = Math.atan2(clientY - central[1], clientX - central[0])
const lastRad = Math.atan2(this.prevY - central[1], this.prevX - central[0])
this.prevX = clientX
this.prevY = clientY
const rotation = (rad - lastRad) * (180 / Math.PI)
this.resize({ deg: rotation })
写回答
2回答
-
扬_灵
2020-09-23
同学你好,这里你要实现的效果是什么,可以把你的需求说一下吗,
042020-09-27 -
希卡利
提问者
2020-09-09
看到了,老师吧 home 的 v-show 换成了 v-if 啊,虽然不跟着敲代码,节约了讲解的时间,但是坑变多了。
00
相似问题