From 315edb288f3001d339d5ddaed248febe47955bef Mon Sep 17 00:00:00 2001 From: Pawel Szymczykowski Date: Fri, 3 Jun 2016 18:25:44 -0700 Subject: [PATCH] Fix odd rounding errors Prevent this behavior: ```javascript (450 - 449.99999999999994) + 'px' "5.684341886080802e-14px" ``` --- draggable_background.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/draggable_background.js b/draggable_background.js index 33c47ce..6d216e6 100644 --- a/draggable_background.js +++ b/draggable_background.js @@ -112,7 +112,7 @@ x0 = x; y0 = y; - $el.css('background-position', xPos + 'px ' + yPos + 'px'); + $el.css('background-position', Math.round(xPos) + 'px ' + Math.round(yPos) + 'px'); }); $window.on('mouseup.dbg touchend.dbg mouseleave.dbg', function() {