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

implemented sticky functionality manually to respect fixed topbar #14

Merged
merged 2 commits into from
Aug 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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