SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 31 of 31

Thread: jquery enigma

  1. #26
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,213
    Mentioned
    457 Post(s)
    Tagged
    8 Thread(s)
    I'm not sure what you are looking at, but this is what's in the init.js file (linked near the bottom of your page):

    Code:
    // Easing equation, borrowed from jQuery easing plugin
    // http://gsgd.co.uk/sandbox/jquery/easing/
    jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
    	return -c * ((t=t/d-1)*t*t*t - 1) + b;
    };
    
    if (jQuery("#slider-nav").length != 0) {
    
    	
    	jQuery(function( $ ){
    	
    		$('#wrapper2').serialScroll({
    			target:'#sections',
    			items:'li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
    			prev:'div.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
    			next:'div.next',// Selector to the 'next' button (absolute too)
    			axis:'xy',// The default is 'y' scroll on both ways
    			navigation:'#slider-nav a',
    			duration:300,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
    			force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
    			onBefore:function( e, elem, $pane, $items, pos ){
    				e.preventDefault();
    				if( this.blur )
    					this.blur();
    			},
    			onAfter:function( elem ){
    			}
    		});
    		
    	});	
    
    	jQuery(function( $ ){
    	
    		$('#wrapper2').serialScroll({
    			target:'.recent-scroll',
    			items:'li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
    			prev:'div.prev2',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
    			next:'div.next2',// Selector to the 'next' button (absolute too)
    			axis:'xy',// The default is 'y' scroll on both ways
    			duration:200,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
    			force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
    			onBefore:function( e, elem, $pane, $items, pos ){
    				e.preventDefault();
    				if( this.blur )
    					this.blur();
    			},
    			onAfter:function( elem ){
    			}
    		});
    		
    	});	
    	
    };
    You need to change it to this (eliminating the red code above):

    Code:
    // Easing equation, borrowed from jQuery easing plugin
    // http://gsgd.co.uk/sandbox/jquery/easing/
    jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
    	return -c * ((t=t/d-1)*t*t*t - 1) + b;
    };
    
    if (jQuery("#slider-nav").length != 0) {
    
    	
    	jQuery(function( $ ){
    	
    		$('#wrapper2').serialScroll({
    			target:'#sections',
    			items:'li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
    			prev:'div.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
    			next:'div.next',// Selector to the 'next' button (absolute too)
    			axis:'xy',// The default is 'y' scroll on both ways
    			navigation:'#slider-nav a',
    			duration:300,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
    			force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
    			onBefore:function( e, elem, $pane, $items, pos ){
    				e.preventDefault();
    				if( this.blur )
    					this.blur();
    			},
    			onAfter:function( elem ){
    			}
    		});
    		
    	});	
    
    };

  2. #27
    SitePoint Evangelist hantaah's Avatar
    Join Date
    Jul 2011
    Location
    Birmingham, Uk
    Posts
    562
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    oops - I edited init2.js should there be 2 init files?

  3. #28
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,213
    Mentioned
    457 Post(s)
    Tagged
    8 Thread(s)
    There's no init2.js file linked to the page you posted at the top of this thread.

  4. #29
    SitePoint Evangelist hantaah's Avatar
    Join Date
    Jul 2011
    Location
    Birmingham, Uk
    Posts
    562
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    whooo hoooo, it's working now. I will delete the init2 file then.. Thank you all for your help and time on the issue

    I have a few more questions though

    - why did it go like this when I added to the content and what should I do to prevent it?
    - will it go like it again if I add the <p> tag to the content and if so how will I make the second paragraph of the content seperrate from the first paragraph?

  5. #30
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,213
    Mentioned
    457 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by hantaah View Post
    why did it go like this when I added to the content and what should I do to prevent it?
    To be honest, I'd say that had nothing to do with it. It's all to do with that JS file.

    will it go like it again if I add the <p> tag to the content and if so how will I make the second paragraph of the content seperrate from the first paragraph?
    The <p> thing was just my ignorant hunch, but had nothing to do with it. Really, you should have <p> tags around that content. Text straight inside a <div> is poor coding. Use elements like <p> and <h2> etc. give proper meaning to your code.

  6. #31
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,716
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by hantaah View Post
    do I need to remove this also as it was inbetween the code you said to delete but I left it there as It wasn't mentioned in the code you said to delete?

    if (!($("#wrapper2").length === 0)) {
    You can leave that there. It's there just as a safety precaution in case that wrapper is not there on the page.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •