How do I dynamically place the layer to the opposite side if the hotspot's location is too close to the edge?
You can change the layer edge property.
Here is the action example, it works better if your layer aligned to "top"
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<action name="change_edge" type="Javascript"><![CDATA[
var hotspotName = args[1];
var layerName = args[2];
var offset = parseFloat(args[3]);
var l = krpano.layer.getItem(layerName);
// save original edge
if (!l.origedge) l.origedge = l.edge || l.align;
function getEdge (hs, offset) {
var edges = krpano.spheretoscreen(krpano.hotspot.getItem(hs).ath, 0);
return edges.x < offset ?
'lefttop' :
edges.x > (krpano.stagewidth - offset) ? 'righttop' : l.origedge;
};
l.edge = getEdge(hotspotName, offset);
]]></action>
|
and call it on hotspot click
|
Source code
|
1
|
change_edge(get(name), layername, offsetvalue)
|
layername - name of the layer child of the hotspot
offsetvalue is a number for example: 50