diff options
author | Zarino Zappia <mail@zarino.co.uk> | 2016-04-21 16:50:22 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-06-01 12:46:06 +0100 |
commit | 95c278025f06a08c22e490269d8784cda774b577 (patch) | |
tree | f8be6b342814dc6a96469b788ab25004a1e42ba0 /web/cobrands | |
parent | f87d065b307e4b952071836788d1acfc79fd63c6 (diff) |
Centre map on pin location when creating a report.
Always centre the map on the new point when creating a new report. This
will be helpful when the map element can change width to accommodate the
.with-notes variant, is easier than the previous method, and feels very
natural.
Diffstat (limited to 'web/cobrands')
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index 5935d2bae..f148f5ad7 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -56,24 +56,20 @@ function tabs(elem, indirect) { } } -/* Geographic functions for faking map centre, as it appears to be offset from +/* Geographic function for faking map centre, as it appears to be offset from where it actually is */ -function midpoint_box_excluding_column(col_offset, col_width, box_offset, box_width) { - var r2l = isR2L(), - diff = r2l ? box_width : (box_offset.left - col_width), - q = (col_offset.left - diff) / 2; +function fixmystreet_midpoint() { + var $content = $('.content'), mb = $('#map_box'); + r2l = isR2L(), + diff = r2l ? mb.width() : (mb.offset().left - $content.width()), + q = ($content.offset().left - diff) / 2; if ((r2l && q > 0) || (!r2l && q < 0)) { return 0; } return q; } -function fixmystreet_midpoint() { - var $content = $('.content'), mb = $('#map_box'); - return midpoint_box_excluding_column($content.offset(), $content.width(), mb.offset(), mb.width()); -} - $(function(){ var $html = $('html'); |