Skip to content

Instantly share code, notes, and snippets.

@MarZab
Created August 5, 2014 09:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MarZab/023f1896ecf14c01a8df to your computer and use it in GitHub Desktop.
Save MarZab/023f1896ecf14c01a8df to your computer and use it in GitHub Desktop.
my take on popup tool-tips title replacements with Angular.js
/*
Why include huge tooltip libraries when something like this does the job perfectly
*/
app.directive('tooltip', [function () {
return { link: function (scope, element, attr) {
// use tag's title text for a popup
element
.addClass('tooltip-wrap')
.append(angular.element('<div class="tooltip-text">'+attr.title+'</div>'))
.attr('title', null);
}};
}]);
/*
Style to your needs
*/
.tooltip-wrap {
position: relative;
.tooltip-text {
@include transition(opacity 0.7s ease);
@include opacity(0);
position: absolute;
width: 200%;
text-align: center;
left: -50%;
}
&:hover .tooltip-text {
@include opacity(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment