javascript - One script causes another to stop working -
i have problem vertical scroll page i'm using (intending to, is) 2 nested quickscroll functions.
this how it's supposed look: - remove scrollbar in mind. i'm using
overflow:scroll
here manually check on things.
since js isn't forte (i have basic knowledge of it), got piece of code worked similarly, reverse engineered removing as html , css until left bare function, , plugged own page in terms of needed html , css code. i'm not using proprietary , i'm including author links, hoping i'm on safe side there (?)
so, main scroll vertical 1 , inside 1 of vertical sections i'm using 'reverse engineered' horizontal quickscroll code.
the new (nested) script cancels out main one. ideas how fix this?
the main (vertical scroll) following:
<script> $(document).ready(function() { $('a.panel').click(function () { $('a.panel').removeclass('selected'); $(this).addclass('selected'); /* added hide menu during scroll , i'm mighty proud of myself! :) */ $('.menu').addclass('hide'); $('.book_arrow').addclass('hide'); current = $(this); $('body').scrollto($(this).attr('href'), 2600, function(){ $('.menu').removeclass('hide'); $('.book_arrow').removeclass('hide'); }); return false; }); }); </script>
it comes these 2 linked files:
<script type="text/javascript" src="js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="js/jquery.scrollto.js"></script>
the conflicting code bit longer:
<script> // initialize scrollable , return programming api var api = $("#scroll").scrollable({ items: '#tools' // use navigator plugin }).navigator().data("scrollable"); // callback special handling of our "intro page" api.onbeforeseek(function(e, i) { // when on first item: hide intro if (i) { $("#intro").fadeout("slow"); // dirty hack ie7-. cannot explain if ($.browser.msie && $.browser.version < 8) { $("#intro").hide(); } // otherwise show intro } else { $("#intro").fadein(1000); } // toggle activity intro thumbnail $("#t0").toggleclass("active", == 0); }); // dedicated click event intro thumbnail $("#t0").click(function() { // seek beginning (the hidden first item) $("#scroll").scrollable().begin(); }); </script>
...and links file:
<script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
does matter in html place these chunks? in isolation, both scripts working.
i've read seemingly similar case here , i'm thinking maybe in case i'm dealing variables 'occupied' 1 of functions, i'm not sure change , where.
i'm absolutely positively looking forward learning major lesson problem! :)
hoping doesn't cause stack overflow, i'll add more (my solution) journey. maybe helps posterity follow learning curve...
i able nested quick scroll (as call it) work properly. still rookie in js, played around bit of script had gotten , modified - 1 worked vertically - , stuffed other, similar, script (inner) horizontal scroll first script! yay! worked. here's how final script looks:
<script> $(document).ready(function() { $('a.panel').click(function () { $('.book_arrow').fadeout(); ## prevents vertical page flying past lot of nav during scroll down ## $('.fluid_centerbox').addclass('hide'); $('.fluid_centerbox').fadeout(); ## makes scroll smooth cause what's {display:none;} isn't going recalculated , lets viewer appreciate background images during scroll. 'hide' instant , .fadeout animated. don't ask me why worked best in order! ## current = $(this); $('body').scrollto($(this).attr('href'), 2600, function(){ $('.book_arrow').fadein(); $('.fluid_centerbox').fadein(), 40000; }); return false; }); $('a.panell').click(function () { current = $(this); $('.long_wrap').scrollto($(this).attr('href'), 2600, function(){ }); return false; }); ## panell not typo way distinguish both scroll button types ## }); </script>
and while i'm posting this, see in inner quick scroll, there's empty
function(){});
maybe later i'll try rid of it, if possible.
Comments
Post a Comment