From 210c5e451e11a77b934d800ea0b75ee42651890b Mon Sep 17 00:00:00 2001 From: Loxos Date: Mon, 17 Aug 2015 17:13:34 +0200 Subject: [PATCH 1/2] implemented sticky functionality manually to respect fixed topbar --- Stand-alone-scripts/stickyVoteButtons | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Stand-alone-scripts/stickyVoteButtons b/Stand-alone-scripts/stickyVoteButtons index 07dc713..b6cbb10 100644 --- a/Stand-alone-scripts/stickyVoteButtons +++ b/Stand-alone-scripts/stickyVoteButtons @@ -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}); + } + }); + }); }); From b2fe107ccf71fde02d9b39d4997561b7c497d865 Mon Sep 17 00:00:00 2001 From: Loxos Date: Mon, 17 Aug 2015 17:15:29 +0200 Subject: [PATCH 2/2] implemented sticky functionality manually to respect fixed topbar --- features.user.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/features.user.js b/features.user.js index be3d6b7..1692fcc 100644 --- a/features.user.js +++ b/features.user.js @@ -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