简体   繁体   English

Fabric JS画布边框影响鼠标偏移

[英]Fabric js canvas border affects mouse offset

Using Fabric JS, I have a 100px border as an inline style for my canvas 使用Fabric JS,我有一个100px的边框作为画布的嵌入式样式

<canvas id='c' style = 'border: solid red 100px;'></canvas>

This is causing issues with selecting objects as the mouse position seems to be offset by the border width 这导致选择对象时出现问题,因为鼠标位置似乎被边框宽度偏移

FIDDLE 小提琴

I have tried to fix the issue using 我尝试使用解决问题

obj.setCoords();

and

canvas.calcOffset();

with no joy?.. 没有喜悦?

Try jsFiddle . 尝试jsFiddle FabricJs generates 2 canvases and they are not placed coreectly inside .canvas-container class FabricJs生成2个画布,它们并没有牢固地放置在.canvas-container类中

#c{
    border: 100px solid #AAA;
}
.upper-canvas{
    top: 100px !important;
    left: 100px !important;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM