Skip to content

Commit 7430d78

Browse files
committed
Fix iframe overlay and z-index
1 parent 79d8a53 commit 7430d78

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

code.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,11 @@ Code.loadDemoArea = function () {
481481
localStorage.demoAreaHeight = area.style.height;
482482
});
483483

484+
$('#demo-area').contents().click(function() {
485+
simulatorArea.style.zIndex = '';
486+
area.style.zIndex = '9999';
487+
});
488+
484489
content.addEventListener('mousedown', function (e) {
485490
e.stopPropagation();
486491
});
@@ -1160,6 +1165,18 @@ Code.loadSimulator = function () {
11601165
updateHeight();
11611166
});
11621167

1168+
$('#simulator-area').contents().click(function() {
1169+
demoArea.style.zIndex = '';
1170+
area.style.zIndex = '9999';
1171+
});
1172+
1173+
$('#simulator-frame').load(function(){
1174+
$('#simulator-frame').contents().click(function() {
1175+
demoArea.style.zIndex = '';
1176+
area.style.zIndex = '9999';
1177+
});
1178+
});
1179+
11631180
content.addEventListener('mousedown', function (e) {
11641181
e.stopPropagation();
11651182
});
@@ -2224,11 +2241,20 @@ Code.reloadSandbox = function () {
22242241
data.js = ctx.data.js;
22252242
}
22262243
}
2227-
2244+
2245+
var area = document.getElementById('demo-area');
2246+
var simulatorArea = document.getElementById('simulator-area');
22282247
var frame = container.querySelector('#demo-frame');
22292248
if (frame) {
22302249
frame.contentWindow.addEventListener('unload', function () {
22312250
createIframe();
2251+
2252+
$('#demo-frame').load(function(){
2253+
$('#demo-frame').contents().click(function() {
2254+
simulatorArea.style.zIndex = '';
2255+
area.style.zIndex = '9999';
2256+
});
2257+
});
22322258
}, false);
22332259

22342260
var event = new UIEvent('beforeunload');
@@ -2241,6 +2267,13 @@ Code.reloadSandbox = function () {
22412267
}, 50);
22422268
} else {
22432269
createIframe();
2270+
2271+
$('#demo-frame').load(function(){
2272+
$('#demo-frame').contents().click(function() {
2273+
simulatorArea.style.zIndex = '';
2274+
area.style.zIndex = '9999';
2275+
});
2276+
});
22442277
}
22452278

22462279
function createIframe() {

0 commit comments

Comments
 (0)