Prevent the quote overlay from overflowing the container
authorAlexander Ebert <ebert@woltlab.com>
Tue, 9 Jul 2019 16:57:05 +0000 (18:57 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 9 Jul 2019 16:57:05 +0000 (18:57 +0200)
wcfsetup/install/files/js/WCF.Message.js

index 94fede9a15ab28fd8a5ef4e2325cd3a33a557521..de5ba71b488a8c3adfeb5487e9f1c722ece10df1 100644 (file)
@@ -1303,6 +1303,15 @@ if (COMPILER_TARGET_DEFAULT) {
                        var $dimensions = this._copyQuote.getDimensions('outer');
                        var $left = ($coordinates.right - $coordinates.left) / 2 - ($dimensions.width / 2) + $coordinates.left;
                        
+                       // Prevent the overlay from overflowing the left or right boundary of the container.
+                       var containerBoundaries = $container[0].getBoundingClientRect();
+                       if ($left < containerBoundaries.left) {
+                               $left = containerBoundaries.left;
+                       }
+                       else if ($left + $dimensions.width > containerBoundaries.right) {
+                               $left = containerBoundaries.right - $dimensions.width;
+                       }
+                       
                        this._copyQuote.css({
                                top: $coordinates.bottom + 7 + 'px',
                                left: $left + 'px'