Skip to content

Commit

Permalink
Fix the 'Hover to Show' newtab option; Only add mouse move listener w…
Browse files Browse the repository at this point in the history
…hen 'Always On' is selected
  • Loading branch information
ahal-test committed Oct 28, 2015
1 parent 7ef2dab commit 96ef555
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions data/newtabicons-content.js
Expand Up @@ -9,11 +9,13 @@
'use strict';

function mouseOverListener(e) {
e.target.style.backgroundImage = e.target.dataset.newPreview;
let thumb = e.target.previousElementSibling;
thumb.style.backgroundImage = thumb.dataset.newPreview;
}

function mouseOutListener(e) {
e.target.style.backgroundImage = e.target.dataset.oldPreview;
let thumb = e.target.previousElementSibling;
thumb.style.backgroundImage = thumb.dataset.oldPreview;
}

function mouseMoveListener (e) {
Expand Down Expand Up @@ -82,6 +84,7 @@ function updateThumbnails() {
thumb.style.backgroundImage = thumb.dataset.newPreview;
thumb.removeEventListener('mouseover', mouseOverListener);
thumb.removeEventListener('mouseout', mouseOutListener);
window.addEventListener('mousemove', mouseMoveListener);
break;
case 3:
thumb.style.backgroundImage = thumb.dataset.oldPreview;
Expand All @@ -90,8 +93,6 @@ function updateThumbnails() {
}
}
}

window.addEventListener('mousemove', mouseMoveListener);
}

function addThumbnails(thumbnails) {
Expand Down

0 comments on commit 96ef555

Please sign in to comment.