From 72d5841a9edc6350e40a99d2dd89a45c46cae684 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 4 Apr 2014 07:09:28 -0400 Subject: [PATCH] fix(view) set current, only if height view is big enough --- lib/client/view.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/client/view.js b/lib/client/view.js index d3f7cf08..40aeb418 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -13,25 +13,33 @@ var CloudCmd, Util, DOM, CloudFunc, $; Key = CloudCmd.Key, Images = DOM.Images, View = Util.exec.bind(Util), - Element, TemplateAudio, TemplateImage, + Element, TemplateAudio, Config = { beforeShow : function() { Images.hideLoad(); Key.unsetBind(); }, - afterClose : function() { + beforeClose : function() { var element, isCurrent, overlay = DOM.getByClass('fancybox-overlay'), - position = CloudCmd.MousePosition; + inner = DOM.getByClass('fancybox-inner', overlay), + heightView = $(inner).height(), + heightWin = window.screen.height, + heightDiff = heightWin / heightView, + position = CloudCmd.MousePosition, + MAX_DIFF = 1.5; - DOM.hide(overlay); - element = DOM.getCurrentByPosition(position); - isCurrent = DOM.isCurrentFile(element); - - if (!isCurrent) - DOM.setCurrentFile(element); + if (heightDiff > MAX_DIFF) { + DOM.hide(overlay); + element = DOM.getCurrentByPosition(position); + isCurrent = DOM.isCurrentFile(element); + + if (!isCurrent) + DOM.setCurrentFile(element); + } + + Key.setBind(); }, - beforeClose : Key.setBind, fitToView : true, loop : false, openEffect : 'none',