Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The placement can be a function instead of a string. An example of auto placement written by <strong>fat</strong> and then ported to the most recent version of bootstrap by <strong>wleeper</strong> is in one of the github issues on the project here: <a href="https://github.com/twitter/bootstrap/issues/345" rel="noreferrer">https://github.com/twitter/bootstrap/issues/345</a></p> <p>Here is the result of compiling the CoffeeScript to JavaScript:</p> <pre><code>$("a[rel=popover]").popover({ placement: function(tip, element) { var $element, above, actualHeight, actualWidth, below, boundBottom, boundLeft, boundRight, boundTop, elementAbove, elementBelow, elementLeft, elementRight, isWithinBounds, left, pos, right; isWithinBounds = function(elementPosition) { return boundTop &lt; elementPosition.top &amp;&amp; boundLeft &lt; elementPosition.left &amp;&amp; boundRight &gt; (elementPosition.left + actualWidth) &amp;&amp; boundBottom &gt; (elementPosition.top + actualHeight); }; $element = $(element); pos = $.extend({}, $element.offset(), { width: element.offsetWidth, height: element.offsetHeight }); actualWidth = 283; actualHeight = 117; boundTop = $(document).scrollTop(); boundLeft = $(document).scrollLeft(); boundRight = boundLeft + $(window).width(); boundBottom = boundTop + $(window).height(); elementAbove = { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 }; elementBelow = { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 }; elementLeft = { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth }; elementRight = { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }; above = isWithinBounds(elementAbove); below = isWithinBounds(elementBelow); left = isWithinBounds(elementLeft); right = isWithinBounds(elementRight); if (above) { return "top"; } else { if (below) { return "bottom"; } else { if (left) { return "left"; } else { if (right) { return "right"; } else { return "right"; } } } } } }); </code></pre> <p>It is working well for me except for one case: if the item is in the upper right corner there is no good spot for the popover to appear that is one of the options and it appears partially off the screen.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload