Skip to content

Instantly share code, notes, and snippets.

@softwarespot
Last active November 28, 2015 10:29
Show Gist options
  • Save softwarespot/358581ceb6ac597024c4 to your computer and use it in GitHub Desktop.
Save softwarespot/358581ceb6ac597024c4 to your computer and use it in GitHub Desktop.
<style>
.company-popup {
background: red;
height: 300px;
position: absolute;
right: -150px;
transition: right .2s linear;
width: 200px;
}
.company-popup.fully-extended {
right: 0;
}
.company-popup.partially-extended {
right: -130px;
}
</style>
<div class="company-popup"></div>
<script>
(function popupHoverModule($) {
var _$popup = $('.company-popup');
var _isExpanded = false;
_$popup.on('click.popup', function clickPopup() {
_$popup.removeClass('partially-extended');
_$popup.toggleClass('fully-extended');
_isExpanded = !_isExpanded;
});
_$popup.on('mouseenter.popup', function mouseEnterPopup() {
if (_isExpanded) {
return;
}
_$popup.addClass('partially-extended');
});
_$popup.on('mouseleave.popup', function mouseLeavePopup() {
if (_isExpanded) {
return;
}
_$popup.removeClass('partially-extended');
});
})(window.jQuery);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment