From 96ef555886c89d9d57671e9de353ecf44415ff2a Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Tue, 27 Oct 2015 17:37:22 -0400 Subject: [PATCH] Fix the 'Hover to Show' newtab option; Only add mouse move listener when 'Always On' is selected --- data/newtabicons-content.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/data/newtabicons-content.js b/data/newtabicons-content.js index b24dee7..b055ca9 100644 --- a/data/newtabicons-content.js +++ b/data/newtabicons-content.js @@ -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) { @@ -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; @@ -90,8 +93,6 @@ function updateThumbnails() { } } } - - window.addEventListener('mousemove', mouseMoveListener); } function addThumbnails(thumbnails) {