From 7148a53dc87e9ce8047bceeb30213ddd67ea6a9b Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 14 Apr 2016 18:38:47 +0800 Subject: [PATCH] small modifications for space module --- app/views/admin/spaces/floor_layout.html.erb | 13 ++++++++----- app/views/admin/spaces/unit_layout.html.erb | 18 ++++++------------ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/app/views/admin/spaces/floor_layout.html.erb b/app/views/admin/spaces/floor_layout.html.erb index b4076f6..5dc02c1 100644 --- a/app/views/admin/spaces/floor_layout.html.erb +++ b/app/views/admin/spaces/floor_layout.html.erb @@ -76,16 +76,18 @@ cover.append(dragBox); } }) - cover.on("mousemove",function(e){ e.preventDefault(); if(isDragging){ diffX = e.offsetX - offsetX; diffY = e.offsetY - offsetY; - currentDragBox.css({ - width : diffX + "px", - height : diffY + "px" - }) + if(diffX > 0 && diffY > 0){ + console.log(diffX,diffY); + currentDragBox.css({ + width : diffX + "px", + height : diffY + "px" + }) + } } }) @@ -97,6 +99,7 @@ btn = $(""); btn.on("click",selectAreaOkBtnHandler); currentDragBox.append(btn); + currentDragBox.addClass("hover"); currentDragBox.hover(function(){ $(this).addClass("hover"); },function(){ diff --git a/app/views/admin/spaces/unit_layout.html.erb b/app/views/admin/spaces/unit_layout.html.erb index 8652079..10430e6 100644 --- a/app/views/admin/spaces/unit_layout.html.erb +++ b/app/views/admin/spaces/unit_layout.html.erb @@ -88,24 +88,17 @@ cover.append(dragBox); } }) - var tempX = 0, - tempY = 0; cover.on("mousemove",function(e){ e.preventDefault(); if(isDragging){ diffX = e.offsetX - offsetX; diffY = e.offsetY - offsetY; if(diffX > 0 && diffY > 0){ - console.log("Difference :", diffX, diffY); - console.log("Old :", tempX, tempY); - tempX = diffX; - tempY = diffY; - if(diffX >= tempX && diffY >= tempY){ - currentDragBox.css({ - width : diffX + "px", - height : diffY + "px" - }) - } + console.log(diffX,diffY); + currentDragBox.css({ + width : diffX + "px", + height : diffY + "px" + }) } } }) @@ -123,6 +116,7 @@ btn = $(""); btn.on("click",selectAreaOkBtnHandler); currentDragBox.append(btn); + currentDragBox.addClass("hover"); currentDragBox.hover(function(){ $(this).addClass("hover"); },function(){