0

How do I offset the boat from the anchor by a few pixels?

You can find a code pen where I have unsuccessfully tried to set an offset here

https://codepen.io/anon/pen/wXraLK?editors=1111

HTML

<script src="https://unpkg.com/popper.js/dist/umd/popper.min.js"></script>

<div class="anchor">Anchor</div>
<div class="boat">Boat</div>

CSS

.boat {
  display: inline-block;
  background-color: yellow;
}
.anchor {
  display: inline-block;
  background-color: gray;
}

JavaScript

var anchor = document.getElementsByClassName("anchor")[0];
var boat = document.getElementsByClassName("boat")[0];

var offsetTopModifier = function (data) {
  data.offsets.popper.top += 50;
  return data;
}

var popper = new Popper(
  anchor,
  boat,
  {
    placement: 'bottom-end',
    modifiers: [offsetTopModifier]
  }
);

This was the source that inspired my attempt:

https://github.com/FezVrasta/popper.js/issues/107

user1283776
  • 19,640
  • 49
  • 136
  • 276

1 Answers1

0

One work around was to set margins on the boat.

user1283776
  • 19,640
  • 49
  • 136
  • 276