Skip to content

Commit

Permalink
Criada funcao que retorna a posicao x e y de um elemento
Browse files Browse the repository at this point in the history
  • Loading branch information
felquis committed Mar 30, 2012
1 parent ffe941e commit ce247ef
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions wall3dparallax/script.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@ var $imgs = $doc.querySelectorAll('img'),
screenWidth = $win.screen.width / 2, screenWidth = $win.screen.width / 2,
screenHeight = $win.screen.height / 2, screenHeight = $win.screen.height / 2,
validPropertyPrefix = '', 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 // Faz as imagens aparecerem com uma opacidade
for (var i = totalImg; i>=0; i--) { for (var i = totalImg; i>=0; i--) {
Expand Down Expand Up @@ -40,4 +51,5 @@ var $imgs = $doc.querySelectorAll('img'),
$imgs[i].parentNode.style[validPropertyPrefix] = otherProperty + 'rotateY('+ degX +'deg) rotateX('+ degY +'deg)'; $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.