Skip to content
This repository has been archived by the owner on Feb 10, 2019. It is now read-only.

Commit

Permalink
Merge pull request #14 from Loxos/develop
Browse files Browse the repository at this point in the history
implemented sticky functionality manually to respect fixed topbar fixes #5
  • Loading branch information
shu8 committed Aug 17, 2015
2 parents ec96c30 + b2fe107 commit 343c4f4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
19 changes: 18 additions & 1 deletion Stand-alone-scripts/stickyVoteButtons
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,22 @@
// ==/UserScript==

$(document).ready(function() {
$('.vote').sticky($('.vote').parent().parent().parent().parent().parent());
$(window).scroll(function(){
$(".votecell").each(function(){
var offset = 0;
if($(".topbar").css("position") == "fixed"){
offset = 34;
}
var vote = $(this).find(".vote");
if($(this).offset().top - $(window).scrollTop() + offset <= 0){
if($(this).offset().top + $(this).height() + offset - $(window).scrollTop() - vote.height() > 0){
vote.css({position:"fixed", left:$(this).offset().left, top:0 + offset});
}else{
vote.css({position:"relative", left:0, top:$(this).height()-vote.height()});
}
}else{
vote.css({position:"relative", left:0, top:0});
}
});
});
});
19 changes: 18 additions & 1 deletion features.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,24 @@ var functionsToCall = { //ALL the functions must go in here
},

stickyVoteButtons: function() { //For making the vote buttons stick to the screen as you scroll through a post
$('.vote').sticky($('.vote').parent().parent().parent().parent().parent());
$(window).scroll(function(){
$(".votecell").each(function(){
var offset = 0;
if($(".topbar").css("position") == "fixed"){
offset = 34;
}
var vote = $(this).find(".vote");
if($(this).offset().top - $(window).scrollTop() + offset <= 0){
if($(this).offset().top + $(this).height() + offset - $(window).scrollTop() - vote.height() > 0){
vote.css({position:"fixed", left:$(this).offset().left, top:0 + offset});
}else{
vote.css({position:"relative", left:0, top:$(this).height()-vote.height()});
}
}else{
vote.css({position:"relative", left:0, top:0});
}
});
});
},

titleEditDiff: function() { //For showing the new version of a title in a diff separately rather than loads of crossing outs in red and additions in green
Expand Down

0 comments on commit 343c4f4

Please sign in to comment.