Permalink
Browse files

Criada funcao que retorna a posicao x e y de um elemento

  • Loading branch information...
1 parent ffe941e commit ce247ef9f36f0b9773650ea4febdd7325b3b58bb @felquis committed Mar 30, 2012
Showing with 14 additions and 2 deletions.
  1. +14 −2 wall3dparallax/script.js
View
@@ -12,7 +12,18 @@ var $imgs = $doc.querySelectorAll('img'),
screenWidth = $win.screen.width / 2,
screenHeight = $win.screen.height / 2,
validPropertyPrefix = '',
- otherProperty = 'perspective(600px)';
+ otherProperty = 'perspective(600px)',
+// Esta function retorna a posição top e left do elemento
+ returnPosition = function (obj) {
+ var currentTop = currentLeft = 0;
+ if (obj.offsetParent) {
+ do {
+ currentTop += obj.offsetTop;
+ currentLeft += obj.offsetLeft;
+ } while (obj = obj.offsetParent);
+ return [currentTop, currentLeft]
+ }
+ };
// Faz as imagens aparecerem com uma opacidade
for (var i = totalImg; i>=0; i--) {
@@ -40,4 +51,5 @@ var $imgs = $doc.querySelectorAll('img'),
$imgs[i].parentNode.style[validPropertyPrefix] = otherProperty + 'rotateY('+ degX +'deg) rotateX('+ degY +'deg)';
}
});
-})(document, window);
+})(document, window);
+

0 comments on commit ce247ef

Please sign in to comment.