-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (24 loc) · 918 Bytes
/
index.js
File metadata and controls
32 lines (24 loc) · 918 Bytes
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
// Import stylesheets
import './style.css';
const containerDiv = document.querySelector('.container');
const containerDivItem = document.querySelector('.container > div');
function moveToIndex() {
containerDiv.scrollTo({top: 20*containerDivItem.clientHeight, behavior: 'smooth'});
}
window.addEventListener('resize', reportWindowSize);
containerDiv.addEventListener('mousedown', initDrag, false);
moveToIndex()
function reportWindowSize() {
moveToIndex()
}
function reportElementSize() {
moveToIndex()
}
function initDrag(e) {
document.documentElement.addEventListener('mousemove', reportElementSize, false);
document.documentElement.addEventListener('mouseup', stopDrag, false);
}
function stopDrag(e) {
document.documentElement.removeEventListener('mousemove', reportElementSize, false);
document.documentElement.removeEventListener('mouseup', stopDrag, false);
}