From be77215fd784ddbff6acda5a68c7f4bcd6e2db65 Mon Sep 17 00:00:00 2001 From: Jim Wrubel Date: Sat, 30 Jul 2016 10:17:41 -0400 Subject: [PATCH] CSS absolute doesn't respect bottom and right properties - it uses height and width instead --- public/javascripts/Manuscript.js | 8 ++++---- spec/javascripts/ManuscriptSpec.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/public/javascripts/Manuscript.js b/public/javascripts/Manuscript.js index b15efab..b7d0926 100644 --- a/public/javascripts/Manuscript.js +++ b/public/javascripts/Manuscript.js @@ -8,7 +8,7 @@ Manuscript.bboxToStyle = function(bbox_str) { arr = bbox_str.split(" "); left_pos = "left:"+arr[1]+"px; "; top_pos = "top:"+arr[2]+"px; "; - right_pos = "right:"+arr[3]+"px; "; - bottom_pos = "bottom:"+arr[4]+"px; "; - return left_pos + top_pos + right_pos + bottom_pos; -}; \ No newline at end of file + width = "width:"+(arr[3]-arr[1])+"px; "; + height = "height:"+(arr[4]-arr[2])+"px; "; + return left_pos + top_pos + width + height; +}; diff --git a/spec/javascripts/ManuscriptSpec.js b/spec/javascripts/ManuscriptSpec.js index c135ead..7cf0974 100644 --- a/spec/javascripts/ManuscriptSpec.js +++ b/spec/javascripts/ManuscriptSpec.js @@ -3,9 +3,9 @@ describe("Manuscript", function() { describe ("class methods", function() { it("#bboxToStyle", function() { result = Manuscript.bboxToStyle("bbox 197 272 249 281"); - expect(result).toEqual("left:197px; top:272px; right:249px; bottom:281px; "); + expect(result).toEqual("left:197px; top:272px; width:52px; height:9px; "); }); }); -}); \ No newline at end of file +});