send cursor position in text mode
This commit is contained in:
parent
5c60f68c14
commit
2a2102f725
@ -55,7 +55,7 @@ var whiteboard = {
|
|||||||
// container for other users cursors
|
// container for other users cursors
|
||||||
_this.cursorContainer = $('<div style="position: absolute; left:0px; top:0; height: 100%; width: 100%;"></div>');
|
_this.cursorContainer = $('<div style="position: absolute; left:0px; top:0; height: 100%; width: 100%;"></div>');
|
||||||
// container for texts by users
|
// container for texts by users
|
||||||
_this.textContainer = $('<div style="position: absolute; left:0px; top:0; height: 100%; width: 100%; cursor:text;"></div>');
|
_this.textContainer = $('<div class="textcontainer" style="position: absolute; left:0px; top:0; height: 100%; width: 100%; cursor:text;"></div>');
|
||||||
// mouse overlay for draw callbacks
|
// mouse overlay for draw callbacks
|
||||||
_this.mouseOverlay = $('<div style="cursor:none; position: absolute; left:0px; top:0; height: 100%; width: 100%;"></div>');
|
_this.mouseOverlay = $('<div style="cursor:none; position: absolute; left:0px; top:0; height: 100%; width: 100%;"></div>');
|
||||||
|
|
||||||
@ -128,7 +128,18 @@ var whiteboard = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(_this.mouseOverlay).on("mousemove touchmove", function (e) {
|
_this.textContainer.on("mousemove touchmove", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (_this.imgDragActive || !$(e.target).hasClass("textcontainer")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var currX = (e.offsetX || e.pageX - $(e.target).offset().left);
|
||||||
|
var currY = (e.offsetY || e.pageY - $(e.target).offset().top);
|
||||||
|
_this.sendFunction({ "t": "cursor", "event": "move", "d": [currX, currY], "username": _this.settings.username });
|
||||||
|
})
|
||||||
|
|
||||||
|
_this.mouseOverlay.on("mousemove touchmove", function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (_this.imgDragActive) {
|
if (_this.imgDragActive) {
|
||||||
return;
|
return;
|
||||||
@ -205,7 +216,7 @@ var whiteboard = {
|
|||||||
_this.sendFunction({ "t": "cursor", "event": "move", "d": [currX, currY], "username": _this.settings.username });
|
_this.sendFunction({ "t": "cursor", "event": "move", "d": [currX, currY], "username": _this.settings.username });
|
||||||
});
|
});
|
||||||
|
|
||||||
$(_this.mouseOverlay).on("mouseup touchend touchcancel", function (e) {
|
_this.mouseOverlay.on("mouseup touchend touchcancel", function (e) {
|
||||||
if (_this.imgDragActive) {
|
if (_this.imgDragActive) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -302,7 +313,7 @@ var whiteboard = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(_this.mouseOverlay).on("mouseout", function (e) {
|
_this.mouseOverlay.on("mouseout", function (e) {
|
||||||
if (_this.imgDragActive) {
|
if (_this.imgDragActive) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -316,7 +327,7 @@ var whiteboard = {
|
|||||||
_this.sendFunction({ "t": "cursor", "event": "out" });
|
_this.sendFunction({ "t": "cursor", "event": "out" });
|
||||||
});
|
});
|
||||||
|
|
||||||
$(_this.mouseOverlay).on("mouseover", function (e) {
|
_this.mouseOverlay.on("mouseover", function (e) {
|
||||||
if (_this.imgDragActive) {
|
if (_this.imgDragActive) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -336,7 +347,7 @@ var whiteboard = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//On textcontainer click (Add a new textbox)
|
//On textcontainer click (Add a new textbox)
|
||||||
$(_this.textContainer).on("click", function (e) {
|
_this.textContainer.on("click", function (e) {
|
||||||
currX = (e.offsetX || e.pageX - $(e.target).offset().left);
|
currX = (e.offsetX || e.pageX - $(e.target).offset().left);
|
||||||
currY = (e.offsetY || e.pageY - $(e.target).offset().top);
|
currY = (e.offsetY || e.pageY - $(e.target).offset().top);
|
||||||
var fontsize = _this.thickness * 0.5;
|
var fontsize = _this.thickness * 0.5;
|
||||||
@ -545,6 +556,19 @@ var whiteboard = {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
|
textBox.on("mousemove touchmove", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (_this.imgDragActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var textBoxPosition = textBox.position();
|
||||||
|
var currX = (e.offsetX + textBoxPosition.left);
|
||||||
|
var currY = (e.offsetY + textBoxPosition.top);
|
||||||
|
if($(e.target).hasClass("removeIcon")) {
|
||||||
|
currX+= textBox.width()-4;
|
||||||
|
}
|
||||||
|
_this.sendFunction({ "t": "cursor", "event": "move", "d": [currX, currY], "username": _this.settings.username });
|
||||||
|
})
|
||||||
this.textContainer.append(textBox);
|
this.textContainer.append(textBox);
|
||||||
textBox.draggable({
|
textBox.draggable({
|
||||||
handle: ".moveIcon",
|
handle: ".moveIcon",
|
||||||
@ -675,10 +699,10 @@ var whiteboard = {
|
|||||||
} else if (tool === "cursor" && _this.settings) {
|
} else if (tool === "cursor" && _this.settings) {
|
||||||
if (content["event"] === "move") {
|
if (content["event"] === "move") {
|
||||||
if (_this.cursorContainer.find("." + content["username"]).length >= 1) {
|
if (_this.cursorContainer.find("." + content["username"]).length >= 1) {
|
||||||
_this.cursorContainer.find("." + content["username"]).css({ "left": data[0] + "px", "top": data[1] + "px" });
|
_this.cursorContainer.find("." + content["username"]).css({ "left": data[0] + "px", "top": (data[1]-15) + "px" });
|
||||||
} else {
|
} else {
|
||||||
_this.cursorContainer.append('<div style="font-size:0.8em; padding-left:2px; padding-right:2px; background:gray; color:white; border-radius:3px; position:absolute; left:' + data[0] + '; top:' + data[1] + ';" class="userbadge ' + content["username"] + '">' +
|
_this.cursorContainer.append('<div style="font-size:0.8em; padding-left:2px; padding-right:2px; background:gray; color:white; border-radius:3px; position:absolute; left:' + data[0] + 'px; top:' + (data[1]-151) + 'px;" class="userbadge ' + content["username"] + '">' +
|
||||||
'<div style="width:4px; height:4px; background:gray; position:absolute; top:-2px; left:-2px; border-radius:50%;"></div>' +
|
'<div style="width:4px; height:4px; background:gray; position:absolute; top:13px; left:-2px; border-radius:50%;"></div>' +
|
||||||
content["username"] + '</div>');
|
content["username"] + '</div>');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user