Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

fix(tooltip): tooltips breach viewports #4205

Closed
SteffanLong opened this issue Aug 13, 2015 · 5 comments
Closed

fix(tooltip): tooltips breach viewports #4205

SteffanLong opened this issue Aug 13, 2015 · 5 comments

Comments

@SteffanLong
Copy link
Contributor

Plunkr

This particular issue was fixed in Bootstrap v3.2.0. This also affects popovers.

Relevent issue: twbs/bootstrap#12328

@wesleycho
Copy link
Contributor

This may be tricky to fix, but it's certainly one that is on the plate.

@levin81
Copy link

levin81 commented Aug 24, 2015

This was posted by some user in a different issue regarding this, it is a current workaround that will reposition the tooltip/popover. It looks a bit ugly without the fade animation, though.

angular
    .module('app.components')
    .directive("positionTooltip", positionTooltip);

function positionTooltip($timeout) {
    var directive = {
        restrict: 'A',
        link: positionTooltipPostLink
    };

    function positionTooltipPostLink(scope, element, attrs) {
        var el, arrow, offset;

        element.bind('mouseenter', function () {
            $timeout(function () {
                el = element.next();
                if (el[0] !== undefined) {
                    if (el[0].offsetLeft < 0) {
                        offset = el[0].offsetLeft;
                        el.css('left', 0);
                        arrow = el[0].querySelector('.tooltip-arrow');
                        arrow = angular.element(arrow);
                        arrow.css('margin-left', (offset + -5) + 'px');
                    }
                    if (el[0].offsetTop < 0) {
                        offset = el[0].offsetTop;
                        el.css('top', 0);
                        arrow = el[0].querySelector('.tooltip-arrow');
                        arrow = angular.element(arrow);
                        arrow.css('margin-top', (offset + -5) + 'px');
                    }
                }
            });
        });
    }

    return directive;
}

@ghost
Copy link

ghost commented Sep 11, 2015

This approach won't work since 0.13.4
The position is since then always 0
See this plunker http://plnkr.co/edit/Dk7SKLUSzVwkKTeZvhkJ?p=preview
and change the bootstrap versions

@lukasz-karolewski
Copy link

angular-strap has it working very nicely - just merge, copy&paste or whatever

https://github.com/mgcrea/angular-strap/blob/master/src/tooltip/tooltip.js search for viewport

@icfantv
Copy link
Contributor

icfantv commented Oct 28, 2015

Closing in favor of #4762.

@icfantv icfantv closed this as completed Oct 28, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants