1

I want to have a tooltip using foundation 5 that appears only on click (disable on hover) and that can be closed.

Basically something to the first tooltip you see in this joyride example but without using joyride.

I couldn't find a way to fix it and documentation is scarce for it, How could this be possibly hacked around?

Community
  • 1
  • 1
ccot
  • 1,875
  • 3
  • 36
  • 54

1 Answers1

2

Seems like you would have to modify the source of the foundation library you're working with. In the Foundation.lib.tooltip it sets up an event listener for mouseenter and mouseleave. You would want to delete and only have listeners to touchstart (for mobile / touchscreen devices) & a mouseclick (which I'm assuming is what MSPointerDown does).

reference: https://github.com/zurb/foundation/blob/master/js/foundation/foundation.tooltip.js#L62

I think you could also clear the logic on lines 86 - 92 that only follows the tooltip if the user has hovered over the tooltip for a certain duration

https://github.com/zurb/foundation/blob/master/js/foundation/foundation.tooltip.js#L86-L92

  • Lidral-Porter I thought about it, but is there a way around so I don't have to play with the source code? – ccot Dec 22 '14 at 18:00
  • Certainly, it gets a little trickier. You would have to remove the event listeners for `mouseenter` and `mouseleave`. To do so, you have to call `.removeEventListener`, which takes 2 arguments: a type (i.e. "click") & the listener you want to remove. This second argument has to be a reference to the same function that is handling the event. See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.removeEventListener for examples / more details – Keenan Lidral-Porter Dec 22 '14 at 19:38