I have this code below that works well on the demo
site: http://jsfiddle.net/Lhg914dc/
{{extend 'layout.html'}}
<html>
<head>
<script src=
"//ajax.googleapis.com/ajax/libs/jqueryui/3.4.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href=
"//ajax.googleapis.com/ajax/libs/jqueryui/3.4.1/themes/base/jquery-ui.css"
type="text/css">
<style>
/*QuickReset*/
*{margin:0;box-sizing:border-box;} html,body{height:100%;font:14px/1.4 sans
-serif;}
article {
height: 150vh;
}
</style>
</head>
<!--button onclick="goTo(selector, timeout, cb)">Click me</button-->
<body>
<article style="background:#0bf;" id="top">WELCOME (waits 3 sec)</article>
<article style="background:#f0b;" id="about">{{=me}}</article>
<article style="background:#b0f;" id="work">{{=work}}</article>
<article style="background:#0fb;" id="testimonials">{{=love}}</article>
<article style="background:#fb0;" id="contact">
CONTACT <a href="#top">TO TOP</a>
</article>
<script type="text/javascript" src="https://code.jquery-3.4.1.min.js">
function goTo(selector, timeout, cb) {
var $el = $(selector);
if (!$el[0]) return;
var $par = $el.parent();
if ($par.is("body")) $par = $("html, body");
setTimeout(() => {
$par.stop().animate({scrollTop: $el.offset().top}, 1000, cb && cb.call($el[
0]));
}, timeout || 0);
}
// USE LIKE:
goTo("#testimonials", 3000, function() {
// You can use `this` to reference #testimonials! yey
$(this).append("<br>Going to #contact in 3sec!");
goTo("#contact", 3000);
});
// Alternatively, without using callbacks you can do
//goTo("#testimonials", 3000);
//goTo("#contact", 6000);
// Reuse function for elements click!
$("[href^='#']").on("click", function(e) {
e.preventDefault();
goTo($(this).attr("href"));
});
</script>
</body>
</html>
When I try it on web2py I don't see any js/jQuery effects.
I want to see the page scroll in stages down to specific DIVs, how can I
do this? where could the error be?
Kind regards
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/d4f3a374-998b-4d46-b01e-d9755c3b0e4b%40googlegroups.com.