Skip to content

Commit cf5615e

Browse files
committed
New: Implement header scrolling functionality
1 parent 45af94d commit cf5615e

5 files changed

Lines changed: 46 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1717
- Shortcuts for saving images [`05c9b31`](https://github.com/ollm/OpenComic/commit/05c9b315788fec63aee2333b0bfb0588cfcf536a)
1818
- Personalize save images template and save automatically to custom folder [`47e8de7`](https://github.com/ollm/OpenComic/commit/47e8de7b73b1ec354000c1455ff651039abd49e1)
1919
- Multiple poster/folder sizes [`c64222a`](https://github.com/ollm/OpenComic/commit/c64222a1b697f6de3f64f0ed79f1a7f293337bcf)
20+
- Implement header scrolling functionality
2021

2122
##### 🐛 Bug Fixes
2223

‎scripts/dom.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const domPoster = require(p.join(appDir, 'scripts/dom/poster.js')),
33
labels = require(p.join(appDir, 'scripts/dom/labels.js')),
44
fileInfo = require(p.join(appDir, 'scripts/dom/file-info.js')),
55
search = require(p.join(appDir, 'scripts/dom/search.js')),
6+
header = require(p.join(appDir, 'scripts/dom/header.js')),
67
boxes = require(p.join(appDir, 'scripts/dom/boxes.js'));
78

89
/*Page - Index*/
@@ -2629,6 +2630,7 @@ module.exports = {
26292630
labels: labels,
26302631
fileInfo: fileInfo,
26312632
boxes: boxes,
2633+
header: header,
26322634
this: domManager.this,
26332635
query: domManager.query,
26342636
queryAll: domManager.queryAll,

‎scripts/dom/header.js‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
let wheelST = false;
2+
3+
function wheel(event)
4+
{
5+
const self = this;
6+
7+
event.preventDefault();
8+
event.stopPropagation();
9+
10+
let scrollLeft = (+this.dataset.scrollLeft || this.scrollLeft);
11+
12+
console.log(scrollLeft);
13+
14+
if(event.wheelDelta / 120 > 0)
15+
scrollLeft -= 120;
16+
else
17+
scrollLeft += 120;
18+
19+
this.dataset.scrollLeft = scrollLeft;
20+
21+
clearTimeout(wheelST);
22+
wheelST = setTimeout(function(){
23+
24+
self.dataset.scrollLeft = '';
25+
26+
}, 160);
27+
28+
$(this).stop(true).animate({scrollLeft: scrollLeft+'px'}, 160, 'linear');
29+
}
30+
31+
async function event()
32+
{
33+
await app.sleep(100);
34+
35+
app.event('.bar-title, .bar-right-buttons', 'mousewheel', wheel);
36+
}
37+
38+
module.exports = {
39+
event: event,
40+
};

‎scripts/reading.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,9 +1150,6 @@ function goScrollPercent(screenPercent = 50, animation = true)
11501150
const now = Date.now();
11511151
const prevNow = +content.dataset.now;
11521152

1153-
if(now - prevNow < animationDurationMS)
1154-
animationDurationMS = (now - prevNow);
1155-
11561153
const scrollHeight = content.scrollHeight - rect.height;
11571154
let scrollTop = (+content.dataset.scrollTop || content.scrollTop) + (screenPercent / 100 * rect.height);
11581155

@@ -1172,7 +1169,7 @@ function goScrollPercent(screenPercent = 50, animation = true)
11721169

11731170
}, animationDurationMS);
11741171

1175-
$(content).stop(true).animate({scrollTop: scrollTop+'px'}, animationDurationMS);
1172+
$(content).stop(true).animate({scrollTop: scrollTop+'px'}, animationDurationMS, ((now - prevNow) < animationDurationMS ? 'linear' : 'swing'));
11761173
}
11771174
}
11781175

‎scripts/template.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ function changeHeader(html, animation = true)
116116
}, 300, headerZindex);
117117

118118
headerZindex++;
119+
120+
dom.header.event();
119121
}
120122

121123
function loadHeader(template, animation)

0 commit comments

Comments
 (0)