Final decision.
JavaScript
//getting parent DIV SVG element by its ID
function setZIndexForSvgParent(divId) {
//Get element by ID
const element = document.getElementById(divId);
//does the element exist?
if (element) {
//Find all SVGs inside an element
const svgs = element.getElementsByTagName('svg');
//Do SVGs exist?
if (svgs.length > 0) {
//use first SVG
const svg = svgs[0];
//Find the parent DIV element
const parentDiv = svg.parentElement;
//does the parent exist and is it a DIV?
if (parentDiv && parentDiv.tagName.toLowerCase() === 'div') {
// set z-index
parentDiv.style.zIndex = '5';
} else {
console.log('Parent not found or not a DIV.');
}
} else {
console.log('SVG not found within element with ID:', divId);
}
} else {
console.log('Element not found:', divId);
}
}
function krpano_onready_callback(krpano_interface) {
if ( krpano_interface.get("device.html5") ) {
// for HTML5 it s possible to assign JS functions directly to krpano events
krpano_interface.set("events.onviewchanged", function() {
krpanoonviewchangeevent();
}.bind(null));
} else {
// for Flash the js() action need to be used to call from Flash to JS (this code would work for Flash and HTML5)
krpano_interface.set("events.onviewchanged", "js(krpanoonviewchangeevent(););");
}
}
embedpano({html5:"only", id:"krpanoViewer", target:"krpanoDiv", xml:"compare-panos.xml", vars:krpano_vars, passQueryParameters:false, consolelog : true, onready : krpano_onready_callback});
function krpanoonviewchangeevent() {
setZIndexForSvgParent('krpanoViewer'); //krpanoViewer or krpanoSWFObject
}
Display More