Sign Up |

Sharebar Bottom Padding

(3 posts) (3 voices)
  1. ti3gib Posted 1 year ago #

    Hello,

    Thanks for all the work on the plugin. It's fantastic and I've been using it for a few days.

    Is there any way to make the sharebar stop scrolling to the bottom of the page after a margin that I can set ?

    I have some content under the posts which I'd like not be covered.

    Thanks.

  2. Monjurul Dolon Posted 1 year ago #

    Thanks! It took a little while but I think I figured it out. The only problem is that this is not part of the core plugin (unless a lot of people request it), so if I release an update and you upgrade automatically through WordPress, it will override the settings.

    Replace your sharebar.js with the following and edit the value var d = 2000; with whatever height from the bottom of the page you want to stop the Sharebar. This isn't automatic as it depends on the size of your footer.

    sharebar.js:

    /*
     *  ShareBar - Creates a dynamic, vertical sharing bar to the left of a WordPress post and hides it if browser window is too small
     *  Copyright 2010 Monjurul Dolon, http://mdolon.com/
     *  Released under the MIT, BSD, and GPL Licenses.
     *  More information: http://devgrow.com/sharebar
     */
    jQuery.fn.sharebar = function(options) {
    	var defaults = {horizontal: true, minwidth: 1000, position: 'left', leftOffset: 20, rightOffset: 10};
    	var opts = jQuery.extend(defaults, options); var o = jQuery.meta ? jQuery.extend({}, opts, jQueryjQuery.data()) : opts;
    
    	var w = jQuery(window).width();
    	var sharebar = jQuery('#sharebar');
    	var sharebarx = jQuery('#sharebarx');
    	var parent = jQuery(sharebar).parent().width();
    	var sw = jQuery(sharebar).width();
    	var start = sharebar_init();
    	var st = jQuery(sharebar).offset().top;
    
    	function sharebar_init(){
    		if (o.position == 'left') jQuery(sharebar).css('marginLeft',(0-sw-o.leftOffset));
    		else {
    			jQuery(sharebar).css('marginLeft',(parent+o.rightOffset));
    		}
    		if(w < o.width && o.horizontal) jQuery(sharebarx).slideDown();
    		else jQuery(sharebar).fadeIn();
    		jQuery.event.add(window, "scroll", sharebar_scroll);
    		jQuery.event.add(window, "resize", sharebar_resize);
    		return jQuery(sharebar).offset().top;
    	}
    	function sharebar_resize() {
    		var w = jQuery(window).width();
    		if(w<o.minwidth){
    			jQuery(sharebar).fadeOut();
    			if(o.horizontal) jQuery(sharebarx).slideDown();
    		}else{
    			jQuery(sharebar).fadeIn();
    			if(o.horizontal) jQuery(sharebarx).slideUp();
    		}
    	}
    	function sharebar_scroll() {
    		var p = jQuery(window).scrollTop();
    		var w = jQuery(window).width();
    		var d = 2000; // Distance from bottom in pixels for when to stop scrolling
    		var tp = p + jQuery(sharebar).height();
    		var h = jQuery(document).height();
    		if(tp < (h-d)){
    			jQuery(sharebar).css('position',((p+10)>start) ? 'fixed' : 'absolute');
    			jQuery(sharebar).css('top',((p+10)>start) ? '10px' : '');
    		}else{
    			jQuery(sharebar).css('position','absolute');
    			jQuery(sharebar).css('top',h-d-st-jQuery(sharebar).height());
    		}
    	}
    
    };
    
  3. nprforu Posted 8 months ago #

    Hello,

    First of all thanks for wonderful plugin. I have installed plugin on my website http://turfdiseases.johnkaminski.me/research/european-turfgrass-society-conference-2/ here. When you scroll you will see it will start working but when either page loads or when it's try to set it's position back to original it's disappearing.

    I tried my best but don't know what's deal to make it work. Would guide me what css changes might need to be done at sharebar file. I also tried to put z-index in UL.sharbar class but that also doesn't work.


Reply

You must log in to post.

© Copyright 2010 DevGrow - Design. Develop. Grow. 20 queries. 0.67 seconds.