-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeckScroll.js
More file actions
54 lines (53 loc) · 1.43 KB
/
deckScroll.js
File metadata and controls
54 lines (53 loc) · 1.43 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
settings.register({
name: 'Disable Deck Scroll',
key: 'underscript.disable.deckScroll',
refresh: () => onPage('Decks'),
});
onPage('Decks', function () {
if (settings.value('underscript.disable.deckScroll')) return;
const oLoad = window.onload;
window.onload = () => {
oLoad();
const cardList = $('#yourCardList');
cardList.css({
'position': 'absolute',
'max-width': '180px',
});
const oOffset = cardList.offset().top - 5;
const oOffsetDeck = $('#deckCardsKINDNESS').offset().top - 5;
$(window).on('scroll.script', () => {
// Calculated here because cardList can change height
const maxHeight = 5 + cardList.height() + $('body > footer').height();
if (window.innerHeight < maxHeight) {
// Lock to the deck offset instead
if (window.pageYOffset > oOffsetDeck) {
$('.deckCardsList').css({
position: 'fixed',
width: '180px',
top: 5,
});
} else {
$('.deckCardsList').css({
position: '',
width: '',
top: '',
});
}
cardList.css({
position: '',
top: '',
});
} else if (window.pageYOffset > oOffset) {
cardList.css({
position: 'fixed',
top: 5,
});
} else {
cardList.css({
position: 'absolute',
top: '',
});
}
});
};
});