Skip to content

Commit

Permalink
fix issue #19 so evtlisteners applied after moving spanned actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Gazook89 committed Jan 16, 2022
1 parent c2c59f2 commit dbc1608
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ const action = {
type: '',
color: '',
turn: [], // row, column
duration: [], // both turn counter integer (1 turn, 2 turns, etc) and action pixel width
duration: [], // both turn counter integer (1 turn, 2 turns, etc) and action pixel width [turns, pixels]
namePlaceholder() {
switch(this.type){
case 'emit':
Expand Down Expand Up @@ -746,6 +746,7 @@ function initMove(evt) {
evt.preventDefault();

const action = evt.target.closest('.action');
const actionObj = actions.find(x=>x.uid === action.id);
const actionWidth = action.clientWidth;
action.style.width = actionWidth + 'px';

Expand Down Expand Up @@ -799,9 +800,19 @@ function initMove(evt) {
} else {
currentDroppable.append(action);
currentDroppable.removeAttribute('style');
currentDroppable.removeEventListener('mouseover', showActionButton);
currentDroppable.removeEventListener('mouseleave', removeChild)
startCell.addEventListener('mouseover', showActionButton);
console.log(typeof actionObj.duration[0]);
console.log(typeof currentDroppable.cellIndex);
for(let x=0;x<actionObj.duration[0]; x++){
console.log(currentDroppable.parentNode.children[currentDroppable.cellIndex + x]);
currentDroppable.parentNode.children[currentDroppable.cellIndex + x].removeEventListener('mouseover', showActionButton);
currentDroppable.parentNode.children[currentDroppable.cellIndex + x].removeEventListener('mouseleave', removeChild);
};
// currentDroppable.removeEventListener('mouseover', showActionButton);
// currentDroppable.removeEventListener('mouseleave', removeChild)
for(let x=0;x<actionObj.duration[0]; x++){
startCell.parentNode.children[actionObj.turn[1] + x].addEventListener('mouseover', showActionButton);
}
// startCell.addEventListener('mouseover', showActionButton);
actions.find(x=>x.uid === action.id).turn = [currentDroppable.parentElement.rowIndex, currentDroppable.cellIndex];
}
action.style.position = null;
Expand Down

0 comments on commit dbc1608

Please sign in to comment.