Has anyone controlled the rotation of a 360 in Object2vr with an external javascript, and then changed the rotation based on scrolling of the page.
IE As the page scrolls down, scroll left on the 360, as the page scrolls up, scroll right?
control scrolling with position on the page
-
- Posts: 314
- Joined: Wed Oct 22, 2008 9:45 pm
- Location: Beech Grove
- Contact:
-
- Posts: 314
- Joined: Wed Oct 22, 2008 9:45 pm
- Location: Beech Grove
- Contact:
I did not get an answer so I went to work. You will need jquery on the page, then add the following code below the container that show the 360 view. I have built it only for the html5 display. It is not perfect, but it seems to be close. If I was changing it, I would find a better way to get the number of frames and divide 100 by the number of frames better. The st/2.5 gets me to 40 frames in the 360.
Code: Select all
<script>
$(window).scroll(function() {
var lastScrollTop = 0;
var st = 0;
var top_of_element = $("#container").offset().top;
var bottom_of_element = $("#container").offset().top + $("#container").outerHeight();
var bottom_of_screen = $(window).scrollTop() + window.innerHeight;
var top_of_screen = $(window).scrollTop();
if((bottom_of_screen > top_of_element) && (top_of_screen < bottom_of_element)){
// The element is visible, do something
var st = Math.round((100 * ($(this).scrollTop() / top_of_element) - 50)/1);
if (st > lastScrollTop){
// downscroll code
obj.moveTo(st/2.5,0,0,3);
} else {
// upscroll code
obj.moveTo(st/2.5,0,0,3);
}
lastScrollTop = st;
}
});
</script>
- Hopki
- Gnome
- Posts: 13029
- Joined: Thu Jan 10, 2008 3:16 pm
- Location: Layer de la Haye, Essex UK
- Contact:
Hi Matt,
Sorry I did not get to this but good work.
Regards,
Hopki
Sorry I did not get to this but good work.
Regards,
Hopki
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/