Angular uib-popover is displayed in the wrong position if installed on crowded text

I have a working example of my problem here: http://plnkr.co/edit/vwZS5e?p=preview

Here's the task space:

<div class="test-container">
    <span uib-popover="Test"
          popover-placement="top"
          popover-trigger="mouseenter"
          popover-append-to-body="true">
        MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe
    </span>
</div>

I am trying to display a popover above the center of this range when I hover over it. I use text overflow to cut my text when it is too long. But it seems that uib-popover does not account for overflow. Popper looks too far right.

Here is my css:

.test-container {
    text-overflow:ellipsis; 
    overflow:hidden; 
    width:100px; 
    border:1px solid red; 
    margin-top:50px; 
    margin-left:50px;
}

I know I can put a popover in a test-container div, but I would prefer the popover to be in the center of the range.

Does anyone have an idea how to fix this?

+4
1

<span> - inline, width inline . , .

. <span>, , width of <span> , width .test-container.

uib-popover width of <span>. <span>, uib-popover.

, <span> a block .

(function(){
  'use strict';

  angular
    .module('app', ['ui.bootstrap', 'ngAnimate']);
})();

(function(){
  'use strict';

  angular
    .module('app')
    .controller('appController', AppController);

  AppController.$inject = ['$log', '$timeout'];

  function AppController($log, $timeout) {
    var vm = this;

    return vm;
  }
})();
html,
body {
  background-color:darkgray;
}

.test-container {
  width:100px; 
  border:1px solid red; 
  margin-top:50px; 
  margin-left:50px;
}

.test-container span {
  text-overflow:ellipsis; 
  overflow:hidden;
  display: block;
}
<link data-require="bootstrap@*" data-semver="3.3.5" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
  <script data-require="jquery@*" data-semver="2.1.4" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
  <script data-require="bootstrap@*" data-semver="3.3.5" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  <script data-require="angular.js@1.4.6" data-semver="1.4.6" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.6/angular.min.js"></script>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular-animate.js"></script>
  <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.14.3/ui-bootstrap-tpls.min.js"></script>

<div ng-app="app" data-ng-controller="appController as vm">
  <div class="test-container">
    <span uib-popover="Test"
          popover-placement="top"
          popover-trigger="mouseenter"
          popover-append-to-body="true">
      MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe
    </span>
  </div>
</div>
Hide result
+1

Source: https://habr.com/ru/post/1620009/


All Articles