canvas-draw
canvas-draw copied to clipboard
当我页面上有其他dom结构时,绘画的起点就偏移了 ToT...
<div class="header"> <img src="../../../static/img/bg.png" alt="" width="100%"> </div> <div class="line-s"> <van-row> <van-col> <div style="margin-left:6px;"> <i class="iconfont icon-xiezi little-i"></i><span class="title">电子签名</span> </div> </van-col> </van-row> <div class="box-area"> <!-- 签名版 --> <sign/> </div>
当我把header这个img去掉之后,就可以正常签名,但是加上了之后,我的落笔点和实际出来的笔触偏移了很多
是不是canvas画布定位有问题,加debugger排查下touchstart时定位对不对?
滚动条确实会造成偏移
const create = signal => (e) => { e.preventDefault(); if (signal === 1) { pressed = true; } if (signal === 1 || pressed) { e = isMobile ? e.touches[0] : e; point.x = e.clientX - left; scrollTop = $("#myModal_sign").scrollTop(); // console.log('scrollTop ---- ' + scrollTop) // console.log('clientY ---- ' + e.clientY) point.y = e.clientY + scrollTop - 30; paint(signal); } };
这里我自己算了一下
现在问题解决了吗?