Guest User

Untitled

a guest
Dec 16th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. var request = null;
  2. var mouse = { x: 0, y: 0 };
  3. var cx = window.innerWidth / 2;
  4. var cy = window.innerHeight / 2;
  5.  
  6. $('html').mousemove(function(event) {
  7.  
  8. mouse.x = event.pageX;
  9. mouse.y = event.pageY;
  10.  
  11. cancelAnimationFrame(request);
  12. request = requestAnimationFrame(update);
  13. });
  14.  
  15. function update() {
  16.  
  17. dx = mouse.x - cx;
  18. dy = mouse.y - cy;
  19.  
  20. tiltx = (dy / cy);
  21. tilty = - (dx / cx);
  22. radius = Math.sqrt(Math.pow(tiltx,2) + Math.pow(tilty,2));
  23. degree = (radius * 15);
  24. TweenLite.to("#container", 2, {transform:'rotate3d(' + tiltx + ', ' + tilty + ', 0, ' + degree + 'deg)', ease:Power2.easeOut});
  25. }
  26.  
  27. $(window).resize(function() {
  28. cx = window.innerWidth / 2;
  29. cy = window.innerHeight / 2;
  30. });
Add Comment
Please, Sign In to add comment