Skip to content

Commit

Permalink
BUG FIX: Broken waves-ripple position
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfiana E. Sibuea committed Aug 12, 2014
1 parent 72ce963 commit 730616d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 31 deletions.
36 changes: 22 additions & 14 deletions dist/waves.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/*!
* Waves v0.5.0
* Waves v0.5.1
* https://publicis-indonesia.github.io/Waves
*
* Copyright 2014 Publicis Metro Indonesia, PT. and other contributors
Expand All @@ -15,21 +15,29 @@
var $$ = document.querySelectorAll.bind(document);

// Find exact position of element
function position(obj) {
function isWindow(obj) {
return obj !== null && obj === obj.window;
}

var left = 0;
var top = 0;

if (obj.offsetParent) {
do {
left += obj.offsetLeft;
top += obj.offsetTop;
} while (obj === obj.offsetParent);
}
function getWindow(elem) {
return isWindow(elem) ? elem : elem.nodeType === 9 && elem.defaultView;
}

function offset(elem) {

var docElem, win,
box = {top: 0, left: 0},
doc = elem && elem.ownerDocument;

docElem = doc.documentElement;

if (typeof elem.getBoundingClientRect !== typeof undefined) {
box = elem.getBoundingClientRect();
}
win = getWindow(doc);
return {
top: top,
left: left
top: box.top + win.pageYOffset - docElem.clientTop,
left: box.left + win.pageXOffset - docElem.clientLeft
};
}

Expand Down Expand Up @@ -61,7 +69,7 @@
el.appendChild(ripple);

// Get click coordinate and element witdh
var pos = position(el);
var pos = offset(el);
var relativeY = (e.pageY - pos.top) - 45;
var relativeX = (e.pageX - pos.left) - 45;
var scale = 'scale('+((el.clientWidth / 100) * 2.5)+')';
Expand Down
4 changes: 2 additions & 2 deletions dist/waves.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/waves.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 22 additions & 14 deletions src/js/waves.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/*!
* Waves v0.5.0
* Waves v0.5.1
* https://publicis-indonesia.github.io/Waves
*
* Copyright 2014 Publicis Metro Indonesia, PT. and other contributors
Expand All @@ -15,21 +15,29 @@
var $$ = document.querySelectorAll.bind(document);

// Find exact position of element
function position(obj) {
function isWindow(obj) {
return obj !== null && obj === obj.window;
}

var left = 0;
var top = 0;

if (obj.offsetParent) {
do {
left += obj.offsetLeft;
top += obj.offsetTop;
} while (obj === obj.offsetParent);
}
function getWindow(elem) {
return isWindow(elem) ? elem : elem.nodeType === 9 && elem.defaultView;
}

function offset(elem) {

var docElem, win,
box = {top: 0, left: 0},
doc = elem && elem.ownerDocument;

docElem = doc.documentElement;

if (typeof elem.getBoundingClientRect !== typeof undefined) {
box = elem.getBoundingClientRect();
}
win = getWindow(doc);
return {
top: top,
left: left
top: box.top + win.pageYOffset - docElem.clientTop,
left: box.left + win.pageXOffset - docElem.clientLeft
};
}

Expand Down Expand Up @@ -61,7 +69,7 @@
el.appendChild(ripple);

// Get click coordinate and element witdh
var pos = position(el);
var pos = offset(el);
var relativeY = (e.pageY - pos.top) - 45;
var relativeX = (e.pageX - pos.left) - 45;
var scale = 'scale('+((el.clientWidth / 100) * 2.5)+')';
Expand Down

0 comments on commit 730616d

Please sign in to comment.