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.
$(element).on('mousedown', $this.start)
be$(element).on('mousedown', this.start)
? – Maxwell