Created
August 5, 2014 09:19
-
-
Save MarZab/023f1896ecf14c01a8df to your computer and use it in GitHub Desktop.
my take on popup tool-tips title replacements with Angular.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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); | |
}}; | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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