0
我使用內嵌模式框的巨大彈出窗口。這個模式中有一個圖像庫,我也想使用這個巨大的彈出窗口。 有沒有什麼辦法讓「更深一層」,並通過點擊圖像,進入畫廊顯示模式與這些圖像,並退出此模式框時,只是返回到原來的模態框?Magnific Popup - 模態框內的圖片庫
感謝您的任何建議
我使用內嵌模式框的巨大彈出窗口。這個模式中有一個圖像庫,我也想使用這個巨大的彈出窗口。 有沒有什麼辦法讓「更深一層」,並通過點擊圖像,進入畫廊顯示模式與這些圖像,並退出此模式框時,只是返回到原來的模態框?Magnific Popup - 模態框內的圖片庫
感謝您的任何建議
剛剛實施這個昨天,所以在這裏。
var parentPopup = false;
$.magnificPopup.open({
items: {src: '#inline-content'},
type: 'inline',
callbacks: {
open: function() {
$('#gallery')
.off('click')
.on('click', function(e) {
e.stopPropagation();
// If an instance is open, keep track and close it
if ($.magnificPopup.instance.isOpen) {
parentPopup = true;
// Here we could also store the parent instance in a global var using $.magnificPopup.instance.clone() to, for example, know which was the parent popup if we have multiple of them.
$.magnificPopup.close();
}
})
.magnificPopup({
type: 'image',
gallery: {
enabled: true
},
callbacks: {
afterClose: function() {
// If we come from a parent popup
if (parentPopup === true) {
// Reopen initial popup here
}
}
}
});
}
}
});
在你的情況,我不認爲跟蹤全局變量,這兩個條件語句是必要的,但我的實現是比較複雜的,所以我離開了他們那裏。
這裏關鍵的是你必須在打開下一個之前關閉第一個彈出窗口,然後在關閉第二個之後重新打開它。
希望它有幫助。
非常感謝Marc。我在一週前放棄了這個解決方案,但將來我可能會回到你的優秀解決方案並使用它:) –