From 81327641cd4d2d5bf5e1de8438ebf44d0c318314 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Sep 2010 00:27:47 -0700 Subject: Fix two bugs with the context menu: 1) Prevent it from "bouncing" which happens when we queue up a lot of open and close events. Stop any running animations before starting new ones. This fixes #1340. 2) Prevent a bug that's not really visible to the user where we wind up re-initializing a context menu over and over which results in us binding tons of hover events. I don't think this causes any serious damage, but it's probably not good. --- lib/gallery.common.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/gallery.common.js') diff --git a/lib/gallery.common.js b/lib/gallery.common.js index 81e26e1b..2dbd7c7c 100644 --- a/lib/gallery.common.js +++ b/lib/gallery.common.js @@ -132,22 +132,23 @@ $.fn.gallery_context_menu = function() { if ($(".g-context-menu li").length) { var hover_target = $(this).find(".g-context-menu"); + if (hover_target.attr("context_menu_initialized")) { + return; + } var list = $(hover_target).find("ul"); - var in_progress = 0; hover_target.find("*").removeAttr('title'); list.hide(); hover_target.hover( function() { - if (in_progress == 0) { - list.slideDown("fast", function() { in_progress = 1; }); - $(this).find(".g-dialog-link").gallery_dialog(); - $(this).find(".g-ajax-link").gallery_ajax(); - } + list.stop(true, true).slideDown("fast"); + $(this).find(".g-dialog-link").gallery_dialog(); + $(this).find(".g-ajax-link").gallery_ajax(); }, function() { - list.slideUp("slow", function() { in_progress = 0; }); + list.stop(true, true).slideUp("slow"); } ); + hover_target.attr("context_menu_initialized", 1); } }; -- cgit v1.2.3