Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions demos/mouse-follow.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,41 @@
<link href="css/demo.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../dist/shine.min.js"></script>
</head>
<body>
<body style="height:1000px">

<h1 id="headline" class="demo-text">Shine Mouse-Follow Demo</h1>
<h1 id="headline" class="demo-text" style="position:relative;top:250px;">Shine Mouse-Follow Demo</h1>

<script type="text/javascript">
// use new shinejs.Shine(...) if Shine is already defined somewhere else
// var shine = new shinejs.Shine(document.getElementById('headline'));
var shine = new Shine(document.getElementById('headline'));


//use 'cursor' to bind light source to cursor or 'scroll' to bind to the scroll position
var useMouseOrScroll = 'scroll';

if (useMouseOrScroll === 'scroll'){
shine.light.position.x = window.innerWidth/2;
shine.light.position.y = document.body.scrollTop;
shine.draw();
}

function handleMouseMove(event) {
shine.light.position.x = event.clientX;
shine.light.position.y = event.clientY;
shine.draw();
}

window.addEventListener('mousemove', handleMouseMove, false);
if (useMouseOrScroll === 'scroll') {
shine.light.position.x = window.innerWidth/2;
shine.light.position.y = document.body.scrollTop;
shine.draw();
} else {
shine.light.position.x = event.clientX;
shine.light.position.y = event.clientY;
shine.draw();
}
}

if (useMouseOrScroll === 'scroll') {
window.addEventListener('scroll', handleMouseMove, false);
} else {
window.addEventListener('mousemove', handleMouseMove, false);
}
</script>
</body>
</html>
1 change: 0 additions & 1 deletion dist/shine.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ exports.Shadow.prototype.disableAutoUpdates = function() {
* @private Called when DOM event listeners fire
*/
exports.Shadow.prototype.handleViewportUpdate = function() {
console.log('vp update');
var boundingRect = this.domElement.getBoundingClientRect();
this.position.x = boundingRect.left + boundingRect.width * 0.5;
this.position.y = boundingRect.top + boundingRect.height * 0.5;
Expand Down
1 change: 0 additions & 1 deletion lib/shine.shadow.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ exports.Shadow.prototype.disableAutoUpdates = function() {
* @private Called when DOM event listeners fire
*/
exports.Shadow.prototype.handleViewportUpdate = function() {
console.log('vp update');
var boundingRect = this.domElement.getBoundingClientRect();
this.position.x = boundingRect.left + boundingRect.width * 0.5;
this.position.y = boundingRect.top + boundingRect.height * 0.5;
Expand Down