Skip to content

Commit 242b3ea

Browse files
author
FezVrasta
committed
fixed troubles with "non-click" on browsers different by Chrome, it has still lot of problems...
1 parent f786000 commit 242b3ea

3 files changed

Lines changed: 18 additions & 17 deletions

File tree

css-compiled/ripples.css

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Generated by less 1.7.0 */
1+
/* Generated by less 1.7.5 */
22
.withripple {
33
position: relative;
44
}
@@ -21,17 +21,14 @@
2121
border-radius: 100%;
2222
background-color: rgba(0, 0, 0, 0.05);
2323
-webkit-transform: scale(1);
24-
-ms-transform: scale(1);
2524
transform: scale(1);
2625
-webkit-transform-origin: 50%;
27-
-ms-transform-origin: 50%;
2826
transform-origin: 50%;
2927
opacity: 0;
28+
pointer-events: none;
3029
}
3130
.ripple.ripple-on {
3231
-webkit-transition: opacity 0.15s ease-in 0s, -webkit-transform 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
33-
-ms-transition: opacity 0.15s ease-in 0s, -ms-transform 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
34-
-moz-transition: opacity 0.15s ease-in 0s, -moz-transform 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
3532
transition: opacity 0.15s ease-in 0s, transform 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
3633
opacity: 1;
3734
}

less/ripples.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
-ms-transform-origin: 50%;
2929
transform-origin: 50%;
3030
opacity: 0;
31+
pointer-events: none;
3132
}
3233
.ripple.ripple-on {
3334
-webkit-transition: opacity 0.15s ease-in 0s, -webkit-transform 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;

scripts/ripples.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* Copyright 2014+, Federico Zivolo, LICENSE at https://github.com/FezVrasta/bootstrap-material-design/blob/master/LICENSE.md */
2-
/* globals CustomEvent, navigator */
2+
/* globals CustomEvent */
3+
34
var ripples = {
45
init : function(withRipple) {
56
"use strict";
@@ -28,7 +29,7 @@ var ripples = {
2829
var rippleStart = function(e, target) {
2930

3031
// Init variables
31-
var $rippleWrapper = (matchesSelector(target, ".ripple-wrapper")) ? target : target.parentNode,
32+
var $rippleWrapper = target,
3233
$el = $rippleWrapper.parentNode,
3334
$ripple = document.createElement("div"),
3435
elPos = $el.getBoundingClientRect(),
@@ -37,6 +38,8 @@ var ripples = {
3738
rippleEnd = new CustomEvent("rippleEnd", {detail: $ripple}),
3839
refreshElementStyle;
3940

41+
$ripplecache = $ripple;
42+
4043
// Set ripple class
4144
$ripple.className = "ripple";
4245

@@ -56,11 +59,6 @@ var ripples = {
5659
$ripple.className = "ripple ripple-on";
5760
$ripple.setAttribute("style", $ripple.getAttribute("style") + ["-ms-" + scale,"-moz-" + scale,"-webkit-" + scale,scale].join(";"));
5861

59-
// Dirty fix for Firefox... seems like absolute elements inside <A> tags do not trigger the "click" event
60-
if (/firefox|crios|(^(?!.*chrome).*safari)|ip(ad|hone|od)/i.test(navigator.userAgent)) {
61-
$el.click();
62-
}
63-
6462
// This function is called when the animation is finished
6563
setTimeout(function() {
6664

@@ -73,6 +71,7 @@ var ripples = {
7371
};
7472

7573
var rippleOut = function($ripple) {
74+
console.log($ripple);
7675
// Clear previous animation
7776
$ripple.className = "ripple ripple-on ripple-out";
7877

@@ -99,25 +98,29 @@ var ripples = {
9998
var $rippleWrapper = document.createElement("div");
10099
$rippleWrapper.className = "ripple-wrapper";
101100
target.appendChild($rippleWrapper);
102-
rippleStart(e, $rippleWrapper);
103101
}
104102

105103
};
106104

105+
106+
var $ripplecache;
107+
107108
// Events handler
108109
// init RippleJS and start ripple effect on mousedown
109-
bind("mousedown", withRipple, rippleInit);
110+
bind("mouseover", withRipple, rippleInit);
110111

112+
console.log(withRipple);
111113
// start ripple effect on mousedown
112-
bind("mousedown", ".ripple-wrapper, .ripple-wrapper .ripple", rippleStart);
114+
bind("mousedown", ".ripple-wrapper", rippleStart);
113115
// if animation ends and user is not holding mouse then destroy the ripple
114-
bind("rippleEnd", ".ripple-wrapper, .ripple-wrapper .ripple", function(e, $ripple) {
116+
bind("rippleEnd", ".ripple-wrapper .ripple", function(e, $ripple) {
115117
if (!mouseDown) {
116118
rippleOut($ripple);
117119
}
118120
});
119121
// Destroy ripple when mouse is not holded anymore if the ripple still exists
120-
bind("mouseup", ".ripple-wrapper, .ripple-wrapper .ripple", function(e, $ripple) {
122+
bind("mouseup", ".ripple-wrapper", function() {
123+
var $ripple = $ripplecache;
121124
if ($ripple.dataset.animating != 1) {
122125
rippleOut($ripple);
123126
}

0 commit comments

Comments
 (0)