Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Moo.fx javascript - smooth scrolling - anyone know how to use this?
3stripe
✭✭
'ello,
i'm trying to use the moo.fx smooth scroll effect but called from within a flash movie.
usually it is applied to any anchor element automatically, but because the link is inside the flash movie (via getURL), the scroll function can't be applied to easily... it doesn't work basically
so... i'm trying to figure out how to call it from flash:
not knowing much javascript this is puzzling me... need a way to reference the function directly but no idea how...
i'm trying to use the moo.fx smooth scroll effect but called from within a flash movie.
usually it is applied to any anchor element automatically, but because the link is inside the flash movie (via getURL), the scroll function can't be applied to easily... it doesn't work basically
so... i'm trying to figure out how to call it from flash:
butHome.onRelease = function() {
getURL("javascript:StartScrollFunctionHere");
}
not knowing much javascript this is puzzling me... need a way to reference the function directly but no idea how...
0
This discussion has been closed.
Comments
butHome.onRelease = function() { getURL("javascript:ScrollLinks.scroll.scrollTo(home);"); };
but only my first anchor link to 'home' works, the rest give me a javascript error, eg if I click the 'services' link:
Error: services is not defined
(Although I've noticed that in Safari it is only the contact link that works, instead of the home link)
butHome.onRelease = function() { getURL("javascript:ScrollLinks.scroll.scrollTo('home');"); };
Any ideas why #false is appearing at the end of the url whenever I click a link?
butHome.onRelease = function() { getURL("javascript:void(0);ScrollLinks.scroll.scrollTo('home');"); };
Just tried adding the void(0), still the same problem... do I need to end the function somehow...
var ScrollLinks = { currentHash: false, start: function(){ this.scroll = new fx.Scroll({duration: 800, onComplete: function(){ScrollLinks.end();}}); this.allinks = document.getElementsByTagName('a'); for (i=0; i<this.allinks.length; i++){ var lnk = this.allinks[i]; if ((lnk.href && lnk.href.indexOf('#') != -1) && ( (lnk.pathname == location.pathname) || ('/'+lnk.pathname == location.pathname) ) && (lnk.search == location.search)) { lnk.onclick = function(){ ScrollLinks.scroll.clearTimer(); this.initialHref = this.href; this.initialHash = this.hash; this.href = "javascript:void(0)"; setTimeout(function(){this.href = this.initialHref;}.bind(this), 200); ScrollLinks.click(this); } } } }, click: function(link){ this.currentHash = link.initialHash.substr(1); if (this.currentHash) { for (j=0; j<this.allinks.length; j++){ if (this.allinks[j].id == this.currentHash){ if (!window.opera) this.scroll.scrollTo(this.allinks[j]); else this.scroll.scrollTo(this.allinks[j].parentNode); break; } } } }, end: function(){ window.location.href = "#"+this.currentHash; this.currentHash = false; } }
(And I might have broken Opera support as well it looks like)
Though, javascript was one of the first languages I learned. Well, it was worth a shot.
I'll look have a good look at the code when it's not four in the morning to see if I can figure out the problem.
I've made a Vanilla extensions for it!!!
Smooth Page Jump
You'll have to change two links in your theme, because it uses the "id" and not the "name" attribute. This means you'll have to change:
<a name="pgtop"> to <a id="pgtop">
and ofcourse for the bottom link as well.
SO, I wrote some new code for you. If you just want the smooth scrolling, add this to the page header:
<script type="text/javascript"> var scroll = new fx.Scroll({duration: 1500, transition: fx.sineOut}); </script>
And use this in your flash script:
getURL("javascript:scroll.scrollTo('home');");
OR, if you want the achor to be added to the URL (for easy bookmarking of a specific section), put this in a js file, and include it on your page:
var flashScroll = { linkid: false, go: function(linkid) { this.linkid = linkid; this.scroll.scrollTo(linkid); }, scroll: new fx.Scroll({duration: 1500, transition: fx.sineOut, onComplete: function() { var href = String(window.location); if (href.indexOf("#") != -1) href = href.substr(0, href.indexOf("#")); if (flashScroll.linkid) window.location = href + "#" + flashScroll.linkid; } }), };
And use this in your flash script:
getURL("javascript:flashScroll.go('home');");
If you use the second solution, you might want to add name="same-as-the-id" to your anchors.