Created
March 7, 2016 20:10
-
-
Save anonymous/48d4bf21d56b2932db9e to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/ciyekufaca
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-2.1.4.js"></script> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
body { | |
perspective: 500px; | |
} | |
.block { | |
width:200px; | |
height:200px; | |
background: #333; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="block"></div> | |
<script id="jsbin-javascript"> | |
$('body').on('mousemove',function(e){ | |
var elem = $(this), | |
xR = ((e.pageX/elem.width())*100-50)/5; | |
yR = -((e.pageY/elem.height())*100-50)/5; | |
console.log('x: '+xR,' y: '+yR); | |
$('.block').css({ | |
transform: 'rotate3d(1, 0, 0, '+yR+'deg) rotate3d(0, 1, 0, '+xR+'deg)' | |
}); | |
}); | |
</script> | |
<script id="jsbin-source-css" type="text/css">body { | |
perspective: 500px; | |
} | |
.block { | |
width:200px; | |
height:200px; | |
background: #333; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">$('body').on('mousemove',function(e){ | |
var elem = $(this), | |
xR = ((e.pageX/elem.width())*100-50)/5; | |
yR = -((e.pageY/elem.height())*100-50)/5; | |
console.log('x: '+xR,' y: '+yR); | |
$('.block').css({ | |
transform: 'rotate3d(1, 0, 0, '+yR+'deg) rotate3d(0, 1, 0, '+xR+'deg)' | |
}); | |
});</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
perspective: 500px; | |
} | |
.block { | |
width:200px; | |
height:200px; | |
background: #333; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('body').on('mousemove',function(e){ | |
var elem = $(this), | |
xR = ((e.pageX/elem.width())*100-50)/5; | |
yR = -((e.pageY/elem.height())*100-50)/5; | |
console.log('x: '+xR,' y: '+yR); | |
$('.block').css({ | |
transform: 'rotate3d(1, 0, 0, '+yR+'deg) rotate3d(0, 1, 0, '+xR+'deg)' | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment