Created
May 20, 2014 14:14
-
-
Save norcross/bdcc26041ddf35e01beb to your computer and use it in GitHub Desktop.
set publish box to float down side of editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$( 'div#postbox-container-1' ).each(function() { | |
// set the float box | |
var pubBox = $( this ).find( 'div#submitdiv' ); | |
// get our sizes and offsets | |
var pubWth = ( pubBox ).width(); | |
var offTop = $( 'div#postbox-container-1' ).offset().top; | |
var offRgt = ( $( window ).width() - ( pubBox.offset().left + pubBox.outerWidth() ) ); | |
console.log( offRgt ); | |
// add our floater | |
$( pubBox ).before( '<span class="float-block"></span>' ).addClass( 'box-floater' ); | |
// set our two items to check and compare | |
var catcher = $( 'span.float-block' ); | |
var sticky = $( 'div.box-floater' ); | |
// start the scrolling | |
$( window ).scroll( function() { | |
if( isScrolledTo( sticky ) ) { | |
sticky.css({ | |
'width' : pubWth + 'px', | |
'position' : 'fixed', | |
'top' : offTop + 'px', | |
'right' : offRgt + 'px', | |
'z-index' : '9999', | |
}); | |
} | |
if ( ( offTop + 10 ) > sticky.offset().top ) { | |
sticky.removeAttr( 'style' ); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment