Skip to content

Commit c583dc5

Browse files
committed
add scroll project card transform
1 parent 49361dc commit c583dc5

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

blocks/card/card.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Card from './Card.js';
22
import CardMain from './Card--main.js';
33
import CardProjects from './Card--projects.js';
44

5-
65
window.addEventListener('load', () => {
76
const
87
CP = new CardProjects(),
@@ -13,22 +12,36 @@ window.addEventListener('load', () => {
1312
CM.mousemoveEvent();
1413
C.mousemoveEvent();
1514

16-
window.addEventListener('mousemove', (e) => {
17-
CP.doEvent(e);
18-
CM.doEvent(e);
19-
// TODO: do i need this? In which case?
20-
// C.doEvent(e);
21-
});
22-
2315
/**
2416
* flushes all caches that can be flushed
2517
* @returns {void}
2618
*/
27-
const onMove = () => {
19+
function onMove() {
2820
CP.flushRectCaches();
2921
CM.flushRectCaches();
3022
//C.flushRectCaches();
31-
};
23+
}
24+
25+
let lastEvent = null;
26+
function doEvent(event = lastEvent) {
27+
CP.doEvent(event);
28+
CM.doEvent(event);
29+
// TODO: do i need this? In which case?
30+
// C.doEvent(event);
31+
}
32+
33+
window.addEventListener('mousemove', (e) => {
34+
lastEvent = e;
35+
doEvent();
36+
});
37+
38+
/**
39+
* @todo this creates a dependency to the projects block by using
40+
* their classes, resolve somehow?
41+
*/
42+
document.querySelector('.projects__inner').addEventListener('scroll', (e) => {
43+
doEvent();
44+
});
3245

3346
window.addEventListener('pushstate', onMove);
3447
window.addEventListener('popstate', onMove);

0 commit comments

Comments
 (0)