Skip to content

Instantly share code, notes, and snippets.

@marcohamersma
Created March 4, 2019 14:26
Show Gist options
  • Save marcohamersma/a3bbdcf32c5cc8a36f6c062a1319d4fd to your computer and use it in GitHub Desktop.
Save marcohamersma/a3bbdcf32c5cc8a36f6c062a1319d4fd to your computer and use it in GitHub Desktop.
diff --git a/app/assets/javascripts/helpers/popper.js b/app/assets/javascripts/helpers/popper.js
index 9225d0cb6..6bace86df 100644
--- a/app/assets/javascripts/helpers/popper.js
+++ b/app/assets/javascripts/helpers/popper.js
@@ -1170,7 +1170,14 @@ const isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
* @returns {Object} The data object, properly modified
*/
function computeStyle(data, options) {
- const { x, y } = options;
+ var placement = data.placement.split('-')[0]
+
+ // var x = options.x,
+ // y = options.y;
+ // set X/Y axis depending op placement
+ // https://github.com/FezVrasta/popper.js/issues/571
+ const x = placement === 'top' ? 'top' : placement === 'bottom' ? 'bottom' : options.x;
+ const y = placement === 'left' ? 'right' : placement === 'right' ? 'left': options.y;
const { popper } = data.offsets;
// Remove this legacy support in Popper.js v2
@@ -1242,6 +1249,10 @@ function computeStyle(data, options) {
styles.willChange = `${sideA}, ${sideB}`;
}
+ // not sure why yet.
+ styles[x] = '';
+ styles[y] = '';
+
// Attributes
const attributes = {
'x-placement': data.placement
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment