You are not logged in.

21

Friday, October 5th 2018, 12:42am

how can I put a button inside the html to close html div?

Hi,

see the 'Here a link for testing the krpano JS API' part in the example.
It shows how to call any krpano code and that can be also used to remove or hide the layer (e.g. call removelayer or set visible to false).

Best regards,
Klaus


Hi Klaus

"Here a link"
I don´t see it



Thanks
Suso
tmhok has attached the following image:
  • QQ图片20181005064050.png

Fernando

Intermediate

Posts: 202

Location: Habana, Cuba

Occupation: Architect, Photographer, Programmer.

  • Send private message

22

Tuesday, November 6th 2018, 6:07am

solved: modify style for handheld device

Hi, this is about the klaus example "div inside krpano" and the user indexofrefraction code in order to modify the text of div section for handheld device:

I modified the project for working with styles in HTML file instead multiple styles lines in .xml, example:

old xml (witout use class) :

<data name="info"><![CDATA[
<span style="text-decoration:none;cursor:pointer;font-size:16px;" >
example1
</span><br><br>
(...)
Solution by indexofrefraction user, for change text size if handheld device:
(...)
var ishandheld = document.getElementById('krpanoSWFObject').get('device.handheld');
var fs = (ishandheld == true || ishandheld == 'true') ? 20 : 16;
div.innerHTML = args[1].replace(/font-sizeW:Wd+px/g, 'font-size:'+fs+'px');
(...)


current xml:

<data name="info"><![CDATA[
<span class="panos">
example1
</span><br>

In current html add style definition:
<style>
.panos { color:#B6D1F0;text-decoration:none;cursor:pointer;font-size:1rem }
.panos_handheld { color:#B6D1F0;text-decoration:none;cursor:pointer;font-size:1.5rem }
</style>

For change the chain class="panos", with class="panos_handheld" if the device is handheld, my solution is:


var ishandheld = document.getElementById('krpanoSWFObject').get('device.handheld');
var fs = (ishandheld == true || ishandheld == 'true') ? 'panos_handheld' : 'panos';
div.innerHTML = args[1].replace(/class="panos"/g, 'class='+fs);

(100% inspired (almost copied) in solution of indexofrefraction user *thumbsup* ) Thanks!

Best regards,

Fernando

This post has been edited 1 times, last edit by "Fernando" (Nov 7th 2018, 1:16am)


Fernando

Intermediate

Posts: 202

Location: Habana, Cuba

Occupation: Architect, Photographer, Programmer.

  • Send private message

23

Tuesday, March 26th 2019, 10:00am

[solved] ...get the current scroll position

Hi. if you need to known the current scroll position:

1) set id to the div element:


Source code

1
2
3
4
5
6
7
8
9
10
11
12
<action name="add_html_code" type="Javascript"><![CDATA[

		var div = document.createElement("div");
		
		// basic styles to fit into the layer size and allow scrolling:
		
		div.id = "mylist";
		div.style.width = "100%";
		div.style.height = "100%";
		div.style.overflow = "auto";
		div.style.boxSizing = "border-box";
		div.style.padding = args[2] ? (args[2] + "px") : "0";



(...) continued with original klaus code

2. Create js action:

Source code

1
2
3
4
5
6
7
8
9
<action name="show_scroll" type="Javascript">
<![CDATA[

var name = "list_scroll";
list_scroll=document.getElementById('mylist').scrollTop
krpano.set("myscroll", list_scroll);krpano.showlog();krpano.trace(get(myscroll));

]]>
</action>



3. Create layer for show scroll position:

Source code

1
2
3
4
5
6
7
<layer name="show_scroll"
type="text"
x="10"
y="10"
html="click to show scroll position"
onclick="show_scroll();"
/>



Finish, now you can see the current scroll position for coding.

Best regards,
Fernando

This post has been edited 3 times, last edit by "Fernando" (Apr 4th 2019, 2:35pm) with the following reason: solved


Tuur

Sage

Posts: 3,115

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

24

Thursday, May 2nd 2019, 3:21pm

edited

...never mind...

Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

ramirox3

Intermediate

Posts: 197

Location: La Ceja, Colombia

Occupation: photographer

  • Send private message

25

Thursday, May 2nd 2019, 11:07pm

ERROR: show_scroll - TypeError: krpano.showlog is not a function

Fernando

Intermediate

Posts: 202

Location: Habana, Cuba

Occupation: Architect, Photographer, Programmer.

  • Send private message

26

Friday, May 3rd 2019, 3:49pm

working example

This is the full example. To use:Change the scroll position, then Press first button to copy this position, change again the scroll position, press the second button to restore the saved position.
Best regards,
Fernando
PD.
How to post examples as this without to remove license or encrypt xml?
Fernando has attached the following file:

27

Saturday, May 25th 2019, 4:28pm

Hi,

This line: onloaded="add_html_code(get(data[html_example_code].content), 10);"

How can I make this an onclick event on a hotspot? I've tried to add the add_html_code to set(layer[html_div]....). But I cant figure out how to make it work.

Example:

<hotspot onclick="Too here --> "/>
<layer name="html_div" onloaded="Move this --> add_html_code(get(data[html_example_code].content), 10);" />
<data name="html_example_code">
<![CDATA[ ... ] ]>
</data>

This post has been edited 3 times, last edit by "klaea" (May 29th 2019, 2:51pm)


Red

Trainee

Posts: 95

Location: Australia

Occupation: Virtual tour creator, VR app developer

  • Send private message

28

Monday, July 8th 2019, 9:44am

Hi,
I'm also trying to call the action in a hotspot onclick like so but the data doesn't populate the div.

js(add_html_code(get(data[html_example_code].content), 10));



Is there anything else I need to add to be able to get data to populate the div onclick?
It currently only seems to work in the onloaded attribute of the html_div layer. I know I can have multiple html_div layers with separate data applied to each onloaded.


But is there a way to use just the one html_div layer and add different divs to the layer?


Thanks for any help
Red

This post has been edited 1 times, last edit by "Red" (Jul 8th 2019, 3:27pm)