Вызов метода класса в классе
При вызове метода itemPositioning в методе dragHandle вылезает ошибка:
yList.js:50 Uncaught TypeError: this.itemPositioning is not a function
Не могу понять в чем проблема. Прикладываю код:
export default class yList {
constructor() {
this.isAnimate = true;
this.list = null;
this.shiftX = 0;
this.shiftY = 0;
}
init(container) {
this.list = container;
if(this.list) {
this.list.classList.add('yList');
for(let i = 0; i < this.list.children.length; i++) {
this.list.children[i].classList.add('yList__item');
this.list.children[i].draggable = true;
this.list.children[i].setAttribute('data-item', i);
this.list.children[i].addEventListener('drag', this.dragHandle);
}
} else {
console.error('yList Error: container didn\'t defined.')
}
}
dragHandle(e) {
...
this.itemPositioning(e);
}
itemPositioning(e) {
this.shiftX = e.clientX - node.getBoundingClientRect().left;
this.shiftY = e.clientY - node.getBoundingClientRect().top;
return true;
}
}
Вызов в HTML:
<html>
<head>
<link rel="stylesheet" href="./src/yList.css" type="text/css" />
</head>
<body>
<div class="list">
<div class="list__item" >
POINT 1
</div>
<div class="list__item">
POINT 2
</div>
<div class="list__item">
POINT 3
</div>
<div class="list__item">
POINT 4
</div>
<div class="list__item">
POINT 5
</div>
<div class="list__item">
POINT 6
</div>
</div>
<script type="module">
import yList from './src/yList.js';
const container = document.querySelector('.list');
window.instance = new yList().init(container);
</script>
</body>
</html>