Update ripples.js

This commit is contained in:
Fabrice Daugan 2016-12-04 20:23:24 +01:00 committed by GitHub
parent 779902d7eb
commit 4caca986a5

17
dist/js/ripples.js vendored
View File

@ -26,7 +26,7 @@
/** /**
* Create the main plugin function * Create the main plugin function
*/ */
function Ripples(element, options) { function Ripples(element, options, event) {
self = this; self = this;
this.element = $(element); this.element = $(element);
@ -36,17 +36,16 @@
this._defaults = defaults; this._defaults = defaults;
this._name = ripples; this._name = ripples;
this.init(); this.init(event);
} }
/** /**
* Initialize the plugin * Initialize the plugin
*/ */
Ripples.prototype.init = function() { Ripples.prototype.init = function(event) {
var $element = this.element; var $element = this.element;
var rippleStart = function(event) {
$element.on("mousedown touchstart", function(event) {
/** /**
* Verify if the user is just touching on a device and return if so * Verify if the user is just touching on a device and return if so
*/ */
@ -142,7 +141,9 @@
} }
}); });
}); };
$element.on("mousedown touchstart", rippleStart);
event && rippleStart(event);
}; };
@ -313,10 +314,10 @@
/** /**
* Create the jquery plugin function * Create the jquery plugin function
*/ */
$.fn.ripples = function(options) { $.fn.ripples = function(options, event) {
return this.each(function() { return this.each(function() {
if(!$.data(this, "plugin_" + ripples)) { if(!$.data(this, "plugin_" + ripples)) {
$.data(this, "plugin_" + ripples, new Ripples(this, options)); $.data(this, "plugin_" + ripples, new Ripples(this, options, event));
} }
}); });
}; };