[英]Draw on draggable canvas using HTML5 and JavaScript
I am currently creating post notes. 我目前正在创建记事。 You can add notes by a button.
您可以通过按钮添加注释。 You can click on those notes when you want to draw into them.
您可以在需要时单击这些便笺。
The problem is when I want to draw on a canvas I can only do that when it's in the left top corner. 问题是,当我想在画布上绘画时,只能在它的左上角进行操作。 I think there is a problem with the registration point of the context.
我认为上下文的注册点存在问题。
How can I let the context follow the canvas when I drag it? 拖动画布时如何让上下文跟随画布?
to get the offset of your element use: 要获取元素的偏移量,请使用:
function getOffset(el) {
var _x = 0;
var _y = 0;
while(el && !isNaN(el.offsetLeft) && !isNaN(el.offsetTop)) {
_x += el.offsetLeft - el.scrollLeft;
_y += el.offsetTop - el.scrollTop;
el = el.parentNode;
}
return {
top : _y,
left : _x
};
}
where el is your note element. el是您的note元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.