forked from Tiny-Giant/myuserscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStickyVoteControls.user.js
25 lines (22 loc) · 998 Bytes
/
StickyVoteControls.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// ==UserScript==
// @name Sticky vote controls
// @namespace http://github.com/TinyGiant/
// @version 1.0.0.1
// @description Brings back the experimental sticky vote controls.
// @author @TinyGiant
// @include /^https?://\w*.?(stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com/questions/(?!tagged|new).*/
// @grant none
// ==/UserScript==
var votes = $('.vote');
var cells = $('.votecell');
votes.css({'position':'absolute'});
cells.css({'width':'46px'});
votes.each(function(i,el){
el = $(el);
var postheight = el.parent().next().find('.post-text').height();
if(el.height() >= postheight) return;
var parent = el.parent();
$(document).scroll(window.requestAnimationFrame.bind(null,function() {
if(document.body.scrollTop > parent.offset().top) document.body.scrollTop < parent.offset().top + parent.height() - el.height() && el.css({'top':document.body.scrollTop}); else el.css({'top':''});
}));
})