| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<style> |
| 5 |
.reference { |
| 6 |
background:#ff0000; |
| 7 |
width:150px; |
| 8 |
height:150px; |
| 9 |
border:1px solid red; |
| 10 |
} |
| 11 |
|
| 12 |
.popper { |
| 13 |
background:black; |
| 14 |
width:50px; |
| 15 |
height:50px; |
| 16 |
color:#fff; |
| 17 |
} |
| 18 |
|
| 19 |
.scrollable { |
| 20 |
width:400px; |
| 21 |
height:300px; |
| 22 |
overflow:scroll; |
| 23 |
border:1px solid red; |
| 24 |
} |
| 25 |
|
| 26 |
.reference-container { |
| 27 |
width:300%; |
| 28 |
height:300%; |
| 29 |
background:yellow; |
| 30 |
display:flex; |
| 31 |
justify-content:center; |
| 32 |
align-items:center; |
| 33 |
} |
| 34 |
|
| 35 |
</style> |
| 36 |
</head> |
| 37 |
<body> |
| 38 |
<div class="scrollable" id="boundaries"> |
| 39 |
<div class="reference-container"> |
| 40 |
<div class="reference"></div> |
| 41 |
</div> |
| 42 |
</div> |
| 43 |
<div class="popper">test popper</div> |
| 44 |
|
| 45 |
<script src="../../dist/popper.js"></script> |
| 46 |
<script> |
| 47 |
var reference = document.querySelector('.reference'); |
| 48 |
var popperElem = document.querySelector('.popper'); |
| 49 |
var thePopper = new Popper( |
| 50 |
reference, |
| 51 |
popperElem, |
| 52 |
{ |
| 53 |
placement: 'right-start', |
| 54 |
boundariesElement: boundaries, |
| 55 |
modifiers: { |
| 56 |
preventOverflow: { |
| 57 |
enabled: true, |
| 58 |
escapeWithReference: true |
| 59 |
}, |
| 60 |
flip: { |
| 61 |
flipVariations: true |
| 62 |
} |
| 63 |
} |
| 64 |
} |
| 65 |
); |
| 66 |
</script> |
| 67 |
</body> |
| 68 |
</html> |