Avoid rounding errors when positioning elements
authorAlexander Ebert <ebert@woltlab.com>
Sun, 17 Apr 2016 07:55:37 +0000 (09:55 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 17 Apr 2016 07:55:56 +0000 (09:55 +0200)
wcfsetup/install/files/js/WoltLab/WCF/Ui/Alignment.js

index 87888f78b42ebae77e05e9584f419ecdca054611..8987b00797beb88b85b13d7f3ab0e530664c8c0c 100644 (file)
@@ -152,11 +152,16 @@ define(['Core', 'Language', 'Dom/Traverse', 'Dom/Util'], function(Core, Language
                                el.classList[(left === 'auto' ? 'add' : 'remove')](options.pointerClassNames[pointerRight]);
                        }
                        
+                       if (bottom !== 'auto') bottom = Math.round(bottom) + 'px';
+                       if (left !== 'auto') left = Math.ceil(left) + 'px';
+                       if (right !== 'auto') right = Math.floor(right) + 'px';
+                       if (top !== 'auto') top = Math.round(top) + 'px';
+                       
                        DomUtil.setStyles(el, {
-                               bottom: bottom + (bottom !== 'auto' ? 'px' : ''),
-                               left: left + (left !== 'auto' ? 'px' : ''),
-                               right: right + (right !== 'auto' ? 'px' : ''),
-                               top: top + (top !== 'auto' ? 'px' : '')
+                               bottom: bottom,
+                               left: left,
+                               right: right,
+                               top: top
                        });
                        
                        elShow(el);