Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd event to created element
    primarykey
    data
    text
    <p>I am updating my code ... Most things are solve. A problem remains:</p> <p>When I move mouse faster between elements (1 and 2) the tooltip does not show.</p> <p>I think this happens because I have a delay on element mouse leave:</p> <pre><code>$this.mouseleave(function (e) { tooltip.timer = setTimeout(function () { $("." + options.class).detach(); }, !options.mouse || options.static ? options.delay || 0 : 0); }), // Mouse leave </code></pre> <p>I have it to allow the mouse to move over the tooltip for when there is a link in it.</p> <p>The idea would be to cancel the hide delay when the mouse goes over another element.</p> <p>The plugin can be tested in <a href="http://jsfiddle.net/mdmoura/RPUX6/" rel="nofollow">http://jsfiddle.net/mdmoura/RPUX6/</a></p> <p>And the entire code is the following:</p> <pre><code>(function ($) { $.fn.Tooltip = function (options) { var defaults = { class: 'Tooltip', content: '', delay: 120, mouse: false, offset: [0, -20], static: true, effect: function ($element, $tooltip) { $tooltip.fadeIn(200); } }; options = $.extend({}, defaults, options); $(this).each(function (e) { var $this = $(this); var tooltip = { timer: null, title: $this.attr('title') }; $this.mouseenter(function (e) { var $tooltip = $("&lt;div&gt;") .attr("class", options.class) .html(options.content !== '' ? (typeof options.content === 'string' ? options.content : options.content($this, $tooltip)) : tooltip.title) .appendTo('body'); $this.attr('title', ''); var position = [0, 0]; if (options.mouse) { position = [e.clientX + options.offset[0] + $(window).scrollLeft(), e.clientY + options.offset[1] + $(window).scrollTop()]; } else { var coordinates = $this[0].getBoundingClientRect(); position = [ (function () { if (options.offset[0] &lt; 0) return coordinates.left - Math.abs(options.offset[0]) - $tooltip.outerWidth() + $(window).scrollLeft(); else if (options.offset[0] === 0) return coordinates.left - (($tooltip.outerWidth() - $this.outerWidth()) / 2) + $(window).scrollLeft(); else return coordinates.left + $this.outerWidth() + options.offset[0] + $(window).scrollLeft(); })(), (function () { if (options.offset[1] &lt; 0) return coordinates.top - Math.abs(options.offset[1]) - $tooltip.outerHeight() + $(window).scrollTop(); else if (options.offset[1] === 0) return coordinates.top - (($tooltip.outerHeight() - $this.outerHeight()) / 2) + $(window).scrollTop(); else return coordinates.top + $this.outerHeight() + options.offset[1] + $(window).scrollTop(); })() ]; } $tooltip.css({ left: position[0] + 'px', top: position[1] + 'px' }); options.effect($this, $tooltip.stop(true, true)); $tooltip.mouseenter(function () { window.clearTimeout(tooltip.timer); tooltip.timer = null; }); // Tooltip enter $tooltip.mouseleave(function () { tooltip.timer = setTimeout(function () { $tooltip.remove(); }, !options.mouse || options.static ? options.delay || 0 : 0); }); }), // Mouse enter $this.mouseleave(function (e) { tooltip.timer = setTimeout(function () { $("." + options.class).remove(); }, !options.mouse || options.static ? options.delay || 0 : 0); }), // Mouse leave $this.mousemove(function (e) { if (options.mouse &amp;&amp; !options.static) { $("." + options.class).css({ left: e.clientX + options.offset[0] + $(window).scrollLeft() + 'px', top: e.clientY + options.offset[1] + $(window).scrollTop() + 'px' }); } }); // Mouse move }); // Each }; // Tooltip })(jQuery); // JQuery </code></pre> <p>I am using timeouts to allow the mouse to move over the tooltip.</p> <p>Does anyone knows how to solve the current problem?</p> <p>Thank You!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload