Browse files

removed the dependancy of hoverIntent

  • Loading branch information...
1 parent fc7d060 commit a5b61dd77eff71cf183676539e188f57065a326a Adrian Adkison committed Nov 30, 2011
Showing with 31 additions and 21 deletions.
  1. +31 −21 js/popouts.js
View
52 js/popouts.js
@@ -1,24 +1,34 @@
-(function($) {
+(function ($){
+ $.fn.popout = function(options){
+
+ var settings = $.extend({},{
+ enterDelay:750,
+ leaveDelay:750
+ },options);
+
+ return this.each(function(){
+
+ var $elem = $(this);
+ var isHovered = true;
- /* Requires hoverIntent plugin */
- /* Not working super well */
-
- var config = {
- over: openPopup,
- timeout: 750,
- out: closePopup
- },
- allQs = $('.q');
+ $elem.hover(function(){
+ isHovered = true;
+ setTimeout(function(){
+ if(isHovered){
+ $elem.addClass("open");
+ }
+ },settings.enterDelay);
+ },function(){
+ isHovered = false;
+ setTimeout(function(){
+ if(!isHovered){
+ $elem.removeClass("open");
+ }
+ },settings.leaveDelay);
+ });
+ });
+ }
- function openPopup(el) {
- allQs.removeClass("open");
- $(el.currentTarget).addClass("open");
- };
+})(jQuery);
- function closePopup(el) {
- $(el.currentTarget).removeClass("open");
- };
-
- allQs.hoverIntent(config);
-
-})(jQuery);
+$('.q').popout();

0 comments on commit a5b61dd

Please sign in to comment.