/    Sign up×
Community /Pin to ProfileBookmark

Panorama viewer: Automatical scrolling

Hallo,
I found this panorama viewer:
[url]https://github.com/peachananr/panorama_viewer[/url]
I want to add automatical scrolling and tried this simple approach:

[CODE] $(document).ready(function () {
$(“.panorama”).panorama_viewer({
repeat: true
});
var pos = 0;
window.setInterval(function () {
//var pos = $(“.pv-inner”).css(“background-position”);
$(“.pv-inner”).css(“background-position”, pos++ + “px 0%”);
}, 10);
});[/CODE]

This doesn’t work as desired: Automatic scrolling only works when the mouse is moved. One had to integrate the automatic scrolling in the plugin but I don’t understand it’s code. Any help is appreciated. I would like to have a button for left, right and stop automatic scrolling.
Best regards – Ulrich

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumauthorMay 23.2016 — Problem solved. I succeed in integrating the timer in the plugin without completely understanding the code:[CODE] function scroll() {
start.x += step;
$bg.css('background-position', start.x + 'px ' + start.y + 'px');
}
if (settings.left) {
$(settings.left).on("click", function () {
step = settings.step;
timer = window.setInterval(scroll, 100);
});
}
if (settings.right) {
$(settings.right).on("click", function () {
step = -settings.step;
timer = window.setInterval(scroll, 100);
});
}
if (settings.stop) {
$(settings.stop).on("click", function () {
window.clearInterval(timer);
});
}
if (settings.autoScroll) {
step = settings.step;
window.setInterval(scroll, 100)
};[/CODE]
×

Success!

Help @Sempervivum spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...