Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds show / hide delay #173

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ tooltip-controller="" | String() | '' | Set a controller to your external toolti
tooltip-smart="" | String(Boolean) | false | Set the tooltip to automatically search the best position on the screen
tooltip-show-trigger="" | String('event1 event2') | 'mouseover' | Show the tooltip on specific event/events
tooltip-hide-trigger="" | String('event1 event2') | 'mouseleave' | Hide the tooltip on specific event/events
tooltip-show-delay="" | String(number) | '' | Adds a delay time (in milliseconds) to show the tooltip
tooltip-hide-delay="" | String(number) | '' | Adds a delay time (in milliseconds) to hide the tooltip
tooltip-close-button="" | String(Boolean) | false | Enable the tooltip close button
tooltip-class="" | String() | '' | Set custom tooltip CSS class/classes
tooltip-size="" | String('large', 'small') | 'medium' | Set your tooltip dimensions
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"angular"
],
"main": [
"./dist/angular-tooltips.min.js",
"./dist/angular-tooltips.min.css"
"./dist/angular-tooltips.js",
"./dist/angular-tooltips.css"
],
"license": "MIT",
"homepage": "http://720kb.github.io/angular-tooltips",
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-tooltips.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/angular-tooltips.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 23 additions & 4 deletions dist/angular-tooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* http://720kb.github.io/angular-tooltips
*
* MIT license
* Mon Jun 06 2016
* Thu Jul 21 2016
*/
/*global angular,window*/
(function withAngular(angular, window) {
Expand Down Expand Up @@ -133,6 +133,18 @@
element.removeAttr('tooltip-speed');
}

if (element.attr('tooltip-show-delay') !== undefined) {

attributesToAdd['tooltip-show-delay'] = element.attr('tooltip-show-delay');
element.removeAttr('tooltip-show-delay');
}

if (element.attr('tooltip-hide-delay') !== undefined) {

attributesToAdd['tooltip-hide-delay'] = element.attr('tooltip-hide-delay');
element.removeAttr('tooltip-hide-delay');
}

return attributesToAdd;
}
, getStyle = function getStyle(anElement) {
Expand Down Expand Up @@ -272,6 +284,8 @@
$attrs.tooltipSize = $attrs.tooltipSize || tooltipsConf.size;
$attrs.tooltipSpeed = $attrs.tooltipSpeed || tooltipsConf.speed;
$attrs.tooltipAppendToBody = $attrs.tooltipAppendToBody === 'true';
$attrs.tooltipShowDelay = $attrs.tooltipShowDelay || tooltipsConf.tooltipShowDelay;
$attrs.tooltipHideDelay = $attrs.tooltipHideDelay || tooltipsConf.tooltipHideDelay;

$transcludeFunc($scope, function onTransclusionDone(element, scope) {
var attributes = getAttributesToAdd(element)
Expand Down Expand Up @@ -500,7 +514,10 @@
if (event &&
$attrs.tooltipHidden !== 'true') {

tooltipElement.addClass('active');
$timeout(function addActiveClass() {
tooltipElement.addClass('active');
}, $attrs.tooltipShowDelay);

}
}
}
Expand All @@ -510,8 +527,10 @@

removeAppendedTip(tooltipElement);
} else {

tooltipElement.removeClass('active');
$timeout(function removeActiveClass() {
tooltipElement.removeClass('active');
}, $attrs.tooltipHideDelay);

}
}
, registerOnScrollFrom = function registerOnScrollFrom(theElement) {
Expand Down
Loading