return true;
});
- $(document).on('click touchend', '#zoomPopupOverlay, #zoomPopupWrapper', function (e) {
-
+ $(document).on('click touchend', '#zoomPopupOverlay, #zoomPopupWrapper, #zoomPopupClose', function (e) {
$this.zoomLinkReset();
+ return false;
});
},
z.data('scale', zoomScale);
// Show overlay
- $('body').addClass('zoomPopup');
+ $this.showOverlay();
});
},
immediate = false;
}
- if (!$('body').hasClass('zoomPopup')) return false; // Already open
var z = $('#zoomPopupWrapper'),
scale = z.data('scale');
});
if (immediate) {
$('#zoomPopupWrapper').hide();
- $('body').removeClass('zoomPopup');
+ this.hideOverlay(1);
}
// Hide popup after transition completes
// ToDo: use CSS transition end event to do this without needing a timeout value (or use Web Animation API)
// ToDo: see https://davidwalsh.name/css-animation-callback
+ this.hideOverlay(500);
setTimeout(function () {
$('#zoomPopupWrapper').hide();
- $('body').removeClass('zoomPopup');
}, 500);
return false;
+ },
+
+ hideOverlay: function (delay) {
+ if (delay == undefined) {
+ delay = 500;
+ }
+ $("#zoomPopupOverlay").css('opacity', 0);
+ setTimeout(function () {
+ $("#zoomPopupOverlay").hide();
+ }, delay);
+ },
+ showOverlay: function () {
+ $("#zoomPopupOverlay").css('opacity', 0).show();
+ setTimeout(function () {
+ $("#zoomPopupOverlay").css('opacity', 1)
+ }, 10)
}
}
\ No newline at end of file