From 66864bfb51152a1d0da0ecd1976b469f87d24ac2 Mon Sep 17 00:00:00 2001 From: Fabrice Daugan Date: Sun, 6 Nov 2016 17:00:05 +0100 Subject: [PATCH] Performance and handly usage --- scripts/material.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/material.js b/scripts/material.js index 3b64ef37..334fec04 100644 --- a/scripts/material.js +++ b/scripts/material.js @@ -256,9 +256,17 @@ }); }, "ripples": function (selector) { - $(document).on('mousedown', selector || this.options.withRipples, function() { - $(this).ripples(); - }); + if (this.options.ripplesDelegate) { + // Delegate mode, lazy creation + $(document).on('mousedown touchstart', selector || this.options.withRipples, function(event) { + if(!$.data($(this), "plugin_ripples")) { + $(this).ripples({}, event); + } + }); + } else { + // Immediate and static creation + $((selector) ? selector : this.options.withRipples).ripples(); + }; }, "autofill": function () { // This part of code will detect autofill when the page is loading (username and password inputs for example)