Using Jquery Scroll Follow plugin with Cookie plugin?

Sorry, forgot about this post. I tried working with the ordering of the cookies and think I found a workable solution. Seems to work for me at least.

Hope this helps anybody. Download and compare to original ( function( jQuery ) { jQuery. ScrollFollow = function ( box, options ) { // Convert box into a jQuery object box = jQuery( box ); // 'box' is the object to be animated var position = box.

Css( 'position' ); function ani() { // The script runs on every scroll which really means many times during a scroll. // We don't want multiple slides to queue up. Box.

Queue( ); // A bunch of values we need to determine where to animate to var viewportHeight = parseInt( jQuery( window ).height() ); var pageScroll = parseInt( jQuery( document ).scrollTop() ); var parentTop = parseInt( box.cont.offset(). Top ); var parentHeight = parseInt( box.cont. Attr( 'offsetHeight' ) ); var boxHeight = parseInt( box.

Attr( 'offsetHeight' ) + ( parseInt( box. Css( 'marginTop' ) ) || 0 ) + ( parseInt( box. Css( 'marginBottom' ) ) || 0 ) ); var aniTop; // Make sure the user wants the animation to happen if ( isActive ) { // If the box should animate relative to the top of the window if ( options.

RelativeTo == 'top' ) { // Don't animate until the top of the window is close enough to the top of the box if ( box. InitialOffsetTop >= ( pageScroll + options. Offset ) ) { aniTop = box.

InitialTop; } else { aniTop = Math. Min( ( Math. Max( ( -parentTop ), ( pageScroll - box.

InitialOffsetTop + box. InitialTop ) ) + options. Offset ), ( parentHeight - boxHeight - box.

PaddingAdjustment ) ); } } // If the box should animate relative to the bottom of the window else if ( options. RelativeTo == 'bottom' ) { // Don't animate until the bottom of the window is close enough to the bottom of the box if ( ( box. InitialOffsetTop + boxHeight ) >= ( pageScroll + options.

Offset + viewportHeight ) ) { aniTop = box. InitialTop; } else { aniTop = Math. Min( ( pageScroll + viewportHeight - boxHeight - options.

Offset ), ( parentHeight - boxHeight ) ); } } // Checks to see if the relevant scroll was the last one // "-20" is to account for inaccuracy in the timeout if ( ( new Date().getTime() - box. LastScroll ) >= ( options. Delay - 20 ) ) { box.

Animate( { top: aniTop }, options. Speed, options. Easing ); } } }; // For user-initiated stopping of the slide var isActive = false; if ( jQuery.

Cookie! = undefined ) { if( jQuery. Cookie( 'scrollFollowSetting' + box.

Attr( 'id' ) ) == 'true' ) { var isActive = true; jQuery( '#' + options. KillSwitch ). Text( options.

OnText ) . Toggle( function () { isActive = false; jQuery( this ). Text( options.

OffText ); box. Animate( { top: box. InitialTop }, options.

Speed, options. Easing ); jQuery. Cookie( 'scrollFollowSetting' + box.

Attr( 'id' ), false, { expires: 365, path: '/'} ); }, function () { isActive = true; jQuery( this ). Text( options. OnText ); jQuery.

Cookie( 'scrollFollowSetting' + box. Attr( 'id' ), true, { expires: 365, path: '/'} ); ani(); } ); } else { jQuery( '#' + options. KillSwitch ).

Text( options. OffText ) . Toggle( function () { isActive = true; jQuery( this ).

Text( options. OnText ); jQuery. Cookie( 'scrollFollowSetting' + box.

Attr( 'id' ), true, { expires: 365, path: '/'} ); ani(); }, function () { isActive = false; jQuery( this ). Text( options. OffText ); box.

Animate( { top: box. InitialTop }, 0 ); jQuery. Cookie( 'scrollFollowSetting' + box.

Attr( 'id' ), false, { expires: 365, path: '/'} ); } ); } } // If no parent ID was specified, and the immediate parent does not have an ID // options. Container will be undefined. So we need to figure out the parent element.

If ( options. Container == '') { box. Cont = box.parent(); } else { box.

Cont = jQuery( '#' + options. Container ); } // Finds the default positioning of the box. Box.

InitialOffsetTop = parseInt( box.offset(). Top ); box. InitialTop = parseInt( box.

Css( 'top' ) ) || 0; // Hack to fix different treatment of boxes positioned 'absolute' and 'relative' if ( box. Css( 'position' ) == 'relative' ) { box. PaddingAdjustment = parseInt( box.cont.

Css( 'paddingTop' ) ) + parseInt( box.cont. Css( 'paddingBottom' ) ); } else { box. PaddingAdjustment = 0; } // Animate the box when the page is scrolled jQuery( window ).

Scroll( function () { // Sets up the delay of the animation jQuery.fn.scrollFollow. Interval = setTimeout( function(){ ani();} , options. Delay ); // To check against right before setting the animation box.

LastScroll = new Date().getTime(); } ); // Animate the box when the page is resized jQuery( window ). Resize( function () { // Sets up the delay of the animation jQuery.fn.scrollFollow. Interval = setTimeout( function(){ ani();} , options.

Delay ); // To check against right before setting the animation box. LastScroll = new Date().getTime(); } ); // Run an initial animation on page load box. LastScroll = 0; ani(); }; jQuery.fn.

ScrollFollow = function ( options ) { options = options || {}; options. RelativeTo = options. RelativeTo || 'top'; options.

Speed = options. Speed || 500; options. Offset = options.

Offset || 0; options. Easing = options. Easing || 'swing'; options.

Container = options. Container || this.parent(). Attr( 'id' ); options.

KillSwitch = options. KillSwitch || 'killSwitch'; options. OnText = options.

OnText || 'Turn Slide Off'; options. OffText = options. OffText || 'Turn Slide On'; options.

Delay = options. Delay || 0; this. Each( function() { new jQuery.

ScrollFollow( this, options ); } ); return this; } })( jQuery ).

Sorry, forgot about this post. I tried working with the ordering of the cookies and think I found a workable solution. Seems to work for me at least.

Hope this helps anybody. Download and compare to original. ( function( jQuery ) { jQuery.

ScrollFollow = function ( box, options ) { // Convert box into a jQuery object box = jQuery( box ); // 'box' is the object to be animated var position = box. Css( 'position' ); function ani() { // The script runs on every scroll which really means many times during a scroll. // We don't want multiple slides to queue up.Box.

Queue( ); // A bunch of values we need to determine where to animate to var viewportHeight = parseInt( jQuery( window ).height() ); var pageScroll = parseInt( jQuery( document ).scrollTop() ); var parentTop = parseInt( box.cont.offset(). Top ); var parentHeight = parseInt( box.cont. Attr( 'offsetHeight' ) ); var boxHeight = parseInt( box.

Attr( 'offsetHeight' ) + ( parseInt( box. Css( 'marginTop' ) ) || 0 ) + ( parseInt( box. Css( 'marginBottom' ) ) || 0 ) ); var aniTop; // Make sure the user wants the animation to happen if ( isActive ) { // If the box should animate relative to the top of the window if ( options.

RelativeTo == 'top' ) { // Don't animate until the top of the window is close enough to the top of the box if ( box. InitialOffsetTop >= ( pageScroll + options. Offset ) ) { aniTop = box.

InitialTop; } else { aniTop = Math. Min( ( Math. Max( ( -parentTop ), ( pageScroll - box.

InitialOffsetTop + box. InitialTop ) ) + options. Offset ), ( parentHeight - boxHeight - box.

PaddingAdjustment ) ); } } // If the box should animate relative to the bottom of the window else if ( options. RelativeTo == 'bottom' ) { // Don't animate until the bottom of the window is close enough to the bottom of the box if ( ( box. InitialOffsetTop + boxHeight ) >= ( pageScroll + options.

Offset + viewportHeight ) ) { aniTop = box. InitialTop; } else { aniTop = Math. Min( ( pageScroll + viewportHeight - boxHeight - options.

Offset ), ( parentHeight - boxHeight ) ); } } // Checks to see if the relevant scroll was the last one // "-20" is to account for inaccuracy in the timeout if ( ( new Date().getTime() - box. LastScroll ) >= ( options. Delay - 20 ) ) { box.

Animate( { top: aniTop }, options. Speed, options. Easing ); } } }; // For user-initiated stopping of the slide var isActive = false; if ( jQuery.

Cookie! = undefined ) { if( jQuery. Cookie( 'scrollFollowSetting' + box.

Attr( 'id' ) ) == 'true' ) { var isActive = true; jQuery( '#' + options. KillSwitch ). Text( options.

OnText ) . Toggle( function () { isActive = false; jQuery( this ). Text( options.

OffText ); box. Animate( { top: box. InitialTop }, options.

Speed, options. Easing ); jQuery. Cookie( 'scrollFollowSetting' + box.

Attr( 'id' ), false, { expires: 365, path: '/'} ); }, function () { isActive = true; jQuery( this ). Text( options. OnText ); jQuery.

Cookie( 'scrollFollowSetting' + box. Attr( 'id' ), true, { expires: 365, path: '/'} ); ani(); } ); } else { jQuery( '#' + options. KillSwitch ).

Text( options. OffText ) . Toggle( function () { isActive = true; jQuery( this ).

Text( options. OnText ); jQuery. Cookie( 'scrollFollowSetting' + box.

Attr( 'id' ), true, { expires: 365, path: '/'} ); ani(); }, function () { isActive = false; jQuery( this ). Text( options. OffText ); box.

Animate( { top: box. InitialTop }, 0 ); jQuery. Cookie( 'scrollFollowSetting' + box.

Attr( 'id' ), false, { expires: 365, path: '/'} ); } ); } } // If no parent ID was specified, and the immediate parent does not have an ID // options. Container will be undefined. So we need to figure out the parent element.

If ( options. Container == '') { box. Cont = box.parent(); } else { box.

Cont = jQuery( '#' + options. Container ); } // Finds the default positioning of the box.Box. InitialOffsetTop = parseInt( box.offset().

Top ); box. InitialTop = parseInt( box. Css( 'top' ) ) || 0; // Hack to fix different treatment of boxes positioned 'absolute' and 'relative' if ( box.

Css( 'position' ) == 'relative' ) { box. PaddingAdjustment = parseInt( box.cont. Css( 'paddingTop' ) ) + parseInt( box.cont.

Css( 'paddingBottom' ) ); } else { box. PaddingAdjustment = 0; } // Animate the box when the page is scrolled jQuery( window ). Scroll( function () { // Sets up the delay of the animation jQuery.fn.scrollFollow.

Interval = setTimeout( function(){ ani();} , options. Delay ); // To check against right before setting the animation box. LastScroll = new Date().getTime(); } ); // Animate the box when the page is resized jQuery( window ).

Resize( function () { // Sets up the delay of the animation jQuery.fn.scrollFollow. Interval = setTimeout( function(){ ani();} , options. Delay ); // To check against right before setting the animation box.

LastScroll = new Date().getTime(); } ); // Run an initial animation on page load box. LastScroll = 0; ani(); }; jQuery.fn. ScrollFollow = function ( options ) { options = options || {}; options.

RelativeTo = options. RelativeTo || 'top'; options. Speed = options.

Speed || 500; options. Offset = options. Offset || 0; options.

Easing = options. Easing || 'swing'; options. Container = options.

Container || this.parent(). Attr( 'id' ); options. KillSwitch = options.

KillSwitch || 'killSwitch'; options. OnText = options. OnText || 'Turn Slide Off'; options.

OffText = options. OffText || 'Turn Slide On'; options. Delay = options.

Delay || 0; this. Each( function() { new jQuery. ScrollFollow( this, options ); } ); return this; }; })( jQuery ).

I added another flag for default setting in scrollFollow. Js and on the page my scrollFollow function is called I added another option (property) named defaultText var firstSetting = true; if (firstSetting) { isActive = false; $('#' + options. KillSwitch).

Html(options. DefaultText); firstSetting = false; } Its working for me.

I'm using the Jquery Scroll Follow plugin to allow a box to follow along as a user scrolls down the website. Scroll Follow allows users to disable or enable the scrolling feature and uses the cookie plugin to remember the users choice across pages. Scroll Follow works great, but the code enables scrolling right away when a user first accesses the site.

I'd like the default to be disabled when a user first enters the site, thereby giving the user the option to enable scrolling. I've tried playing around with the true/false settings of the cookie, but I can't get this to work properly. I'm including the code below and appreciate any help to change the default to no scrolling.

* @projectDescription jQuery plugin for allowing an element to animate down as the user scrolls the page. Var position = box. // The script runs on every scroll which really means many times during a scroll.

// We don't want multiple slides to queue up. Var parentTop = parseInt( box.cont.offset().

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions