Need to double click on Firefox
Asked Answered
S

1

7

I have my code:

+function($) {
'use strict';
var Ripple = function(element) {
    var $this = $(this)
    $(element).on('mousedown', $this.start)
}
Ripple.prototype.start = function(e) {
    var $this = $(this)
    var r = $this.find('.ripple-wave')
    if(r.length == 0) {
        $this.prepend('<div class="ripple-wave"></div>')
        r = $this.find('.ripple-wave')
    }
    if($this.hasClass('btn') || $this.hasClass('single-action')) {
        var posX = $(this).offset().left, posY = $(this).offset().top
        r.css('left', e.pageX - posX)
        r.css('top', e.pageY - posY)
    }
    r = r.parent()
    r.addClass('active')
    r.one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(e) {
        r.removeClass('active')
    })

}

var old = $.fn.ripple

$.fn.ripple = function() {
    return this.each(function() {
        new Ripple(this)
    })
}

$.fn.ripple.Constructor = Ripple

$.fn.ripple.noConflict = function () {
    $.fn.ripple = old
    return this
}}(jQuery);

But if i test on Mozilla Firefox, i have to double click the element in order to do its function.

I initialize this to my on page load using:

$('.ripple').ripple()

PS: I also have on click event on each element from other JS file.

In chrome, it's working properly, in a single click.

Slowly answered 27/10, 2015 at 7:54 Comment(4)
can you post the html to reproduce it?Bowfin
don't think this solves your problem but shouldn't $(element).on('mousedown', $this.start) be $(element).on('mousedown', this.start)?Maxwell
Can you please provide us with the full JQuery code, full html code, and possibly elaborate your prob a bit better?Suffruticose
it would be better if you can provide a jsFiddle to help debug :)Culbertson
P
1
  1. $( "p" ).dblclick(function() { alert( "Hello World!" ); });

  2. <p ondblclick="myFunction()">Double-click me</p>

Protolithic answered 2/11, 2015 at 12:1 Comment(1)
It is my comment to your deleted question. Start to learn PHP. The main advantage is not that it is easy than C++. The main advantage is that it provides good job opportunities compared with C++. C++ programmers are required nowhere.Altis

© 2022 - 2024 — McMap. All rights reserved.