From 269c78e33b4025efb328f629b00db8079e7f995f Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Fri, 27 Feb 2015 08:19:20 +0200 Subject: client: bubble: fix resize missing initial value --- src/client/view/bubble.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/client/view/bubble.js') diff --git a/src/client/view/bubble.js b/src/client/view/bubble.js index dff59eae..02f5a73a 100644 --- a/src/client/view/bubble.js +++ b/src/client/view/bubble.js @@ -5,10 +5,12 @@ function Bubble(raw_parent, radius) { var circle = document.createElementNS(xmlns, 'circle'); var setTransformToCenter = function (elem) { - var width = $(document.body).innerWidth(); - var height = $(document.body).innerHeight(); - - elem.setAttribute('transform', 'translate(' + width / 2 + ',' + height / 2 + ')'); + var width = $(document.body).innerWidth(), + height = $(document.body).innerHeight(), + bx = width / 2, + by = height / 2; + console.log("setting bubble at " + bx + ", " + by); + elem.setAttribute('transform', 'translate(' + bx + ',' + by + ')'); } g.appendChild(circle); @@ -18,7 +20,7 @@ function Bubble(raw_parent, radius) { circle.id = 'bubble'; // reset bubble on radius change and window resize - Bacon.combineWith(function (r, _) { return r; }, radius, $(window).asEventStream('resize')).onValue( + Bacon.combineWith(function (r, _) { return r; }, radius, $(window).asEventStream('resize').toProperty(0)).onValue( function (r) { setTransformToCenter(g); circle.setAttribute("r", r); -- cgit v1.3.1