Skip to content

Commit

Permalink
fixed error when share box is hidden - issue #8
Browse files Browse the repository at this point in the history
  • Loading branch information
jpchateau committed Jul 31, 2020
1 parent 437763a commit 628df4a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/js/event/behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,35 @@ export default class Behavior {
}

bindSceneEvents() {
// Mouse enters scene -> show all hotspots and share box
// Mouse enters scene -> show all hotspots and share box (if exists)
this.$image.on('mouseenter', function() {
const $hotspots = $(this).find('.hotspot');
$.each($hotspots, function() {
$(this).fadeIn();
});

const $shareBox = $(this).find('.social-share-box');
if (!$shareBox.length) {
return;
}

setTimeout(() => {
$shareBox.css('display', 'flex');
}, 100);
});

// Mouse leaves scene -> hide all hotspots, containers and share box
// Mouse leaves scene -> hide all hotspots, containers and share box (if exists)
this.$image.on('mouseleave', function() {
const $elements = $(this).find('.hotspot, .item');
$.each($elements, function() {
DomHelper.hideElement($(this)[0]);
});

const $shareBox = $(this).find('.social-share-box');
if (!$shareBox.length) {
return;
}

DomHelper.hideElement($shareBox[0]);
});
}
Expand Down

0 comments on commit 628df4a

Please sign in to comment.