tooltip.js updated

pull/3845/head
Furkan Sezis 2023-04-10 11:01:28 +03:00
parent c3cd42a317
commit bcac4b7776
1 changed files with 32 additions and 32 deletions

View File

@ -1,5 +1,7 @@
import { ConnectedOverlayScrollHandler, DomHandler, ObjectUtils, UniqueComponentId, ZIndexUtils } from 'primevue/utils'; import { ConnectedOverlayScrollHandler, DomHandler, ObjectUtils, UniqueComponentId, ZIndexUtils } from 'primevue/utils';
let timer;
function bindEvents(el) { function bindEvents(el) {
const modifiers = el.$_ptooltipModifiers; const modifiers = el.$_ptooltipModifiers;
@ -86,50 +88,48 @@ function onKeydown(event) {
event.code === 'Escape' && hide(event.currentTarget, hideDelay); event.code === 'Escape' && hide(event.currentTarget, hideDelay);
} }
let timer; function tooltipActions(el) {
if (el.$_ptooltipDisabled) {
function show(el, showDelay) { return;
function tooltipActions() {
if (el.$_ptooltipDisabled) {
return;
}
let tooltipElement = create(el);
align(el);
DomHandler.fadeIn(tooltipElement, 250);
window.addEventListener('resize', function onWindowResize() {
if (!DomHandler.isTouchDevice()) {
hide(el);
}
this.removeEventListener('resize', onWindowResize);
});
bindScrollListener(el);
ZIndexUtils.set('tooltip', tooltipElement, el.$_ptooltipZIndex);
} }
let tooltipElement = create(el);
align(el);
DomHandler.fadeIn(tooltipElement, 250);
window.addEventListener('resize', function onWindowResize() {
if (!DomHandler.isTouchDevice()) {
hide(el);
}
this.removeEventListener('resize', onWindowResize);
});
bindScrollListener(el);
ZIndexUtils.set('tooltip', tooltipElement, el.$_ptooltipZIndex);
}
function show(el, showDelay) {
if (showDelay !== undefined) { if (showDelay !== undefined) {
timer = setTimeout(tooltipActions, showDelay); timer = setTimeout(() => tooltipActions(el), showDelay);
} else { } else {
tooltipActions(); tooltipActions(el);
} }
} }
function hide(el, hideDelay) { function tooltipRemoval(el) {
function tooltipRemoval() { remove(el);
remove(el); unbindScrollListener(el);
unbindScrollListener(el); }
}
function hide(el, hideDelay) {
clearTimeout(timer); clearTimeout(timer);
if (hideDelay !== undefined) { if (hideDelay !== undefined) {
setTimeout(tooltipRemoval, hideDelay); setTimeout(() => tooltipRemoval(el), hideDelay);
} else { } else {
tooltipRemoval(); tooltipRemoval(el);
} }
} }