stevenbenner / jquery-powertip

:speech_balloon: A jQuery plugin that creates hover tooltips.
https://stevenbenner.github.io/jquery-powertip/
MIT License
821 stars 137 forks source link

MouseOn and Touch Support #172

Closed aroundi closed 2 years ago

aroundi commented 6 years ago

Hello,

Is it possible for PowerTip to support both mouseOn and touch on the same element?

I am trying to use PowerTip with FullCalendar. Mouse over works well but on touch screens the tool tip just flashes. The same behavior can be seen on the Mouse on to popup example at [https://stevenbenner.github.io/jquery-powertip/]

Thank you for this well designed plugin.

stevenbenner commented 6 years ago

Yes, but in the case the the mouse on to popup example on the project page it needs some extra logic. The reason is that it needs to have two types of behavior based on the event type (mouse travel handling for mouse events, and a basic click-to-toggle handing for touch).

This is handled by the focus events on elements that can receive focus (like links and inputs). But elements that cannot receive focus don't cause PowerTip to behave like it should right now. Unfortunately, I haven't spent much time making everything work well for touch environments.

I think the easiest way to get this working with the current version would be to add "click" and/or "touchstart" to the openEvents and closeEvents options, for example:

$('.tooltips').powerTip({
    openEvents: $.fn.powerTip.defaults.openEvents.concat([ 'click' ]),
    closeEvents: $.fn.powerTip.defaults.closeEvents.concat([ 'click' ])
});

and/or

$('.tooltips').powerTip({
    openEvents: $.fn.powerTip.defaults.openEvents.concat([ 'touchstart' ]),
    closeEvents: $.fn.powerTip.defaults.closeEvents.concat([ 'touchstart' ])
});

I know it's not pretty, but I think it would get you mostly there. Though I haven't tested it yet.

Let me know if this works or you run into any problems.

stevenbenner commented 2 years ago

This issue has not had any response for a long time. Closing issue.