Archived
1
0

try fixing drag to move for reply box

This commit is contained in:
Jeff Becker
2016-04-30 14:44:06 -04:00
parent 61e390daf0
commit ecb223ebc4
3 changed files with 30 additions and 15 deletions

View File

@@ -123,6 +123,11 @@ function DynReply(existingElem) {
this.prefix = null;
}
DynReply.prototype.moveTo = function(x,y) {
this.elem.style.top = y + "px";
this.elem.style.left = x + "px";
}
DynReply.prototype.update = function() {
if (this.prefix) {
// update captcha
@@ -171,15 +176,14 @@ DynReply.prototype.setRoot = function(roothash) {
}
// reply box function
function nntpchan_reply(prefix, parent, shorthash) {
if (prefix && parent) {
function nntpchan_reply(parent, shorthash) {
if (parent) {
var boardname = parent.getAttribute("boardname");
var roothash = parent.getAttribute("root");
var replyto = getReplyTo();
// set target
replyto.setBoard(boardname);
replyto.setRoot(roothash);
replyto.setPrefix(prefix);
// show it
replyto.show();
}
@@ -261,14 +265,22 @@ function init(prefix) {
var rpl = getReplyTo();
rpl.setPrefix(prefix);
var e = rpl.elem;
e.setAttribute("draggable", "true");
e.ondragend = function(ev) {
ev.preventDefault();
var x = 0;
var y = 0;
console.log(ev);
var el = document.getElementById("postform_container");
el.setAttribute("style", "top: "+y+"px; left: "+x+ "px; position: fixed; ");
}
var mouseDownX, mouseDownY;
var originalX = window.width - 300;
var originalY = 10;
rpl.moveTo(originalX, originalY);
e.addEventListener("mousedown", function(ev) {
mouseDownX = ev.clientX;
mouseDownY = ev.clientY;
});
e.addEventListener("mouseup", function(ev) {
var x = originalX + ev.clientX - mouseDownX
var y = originalY + ev.clientY - mouseDownY
rpl.moveTo(x, y);
});
}