Last active
November 28, 2015 10:29
-
-
Save softwarespot/358581ceb6ac597024c4 to your computer and use it in GitHub Desktop.
Simple hover effect - http://jsbin.com/kakevuwiye/edit?output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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