I am developing something similar to a Gantt-Chart using a Konva wrapper for Vue.js. I basically have a group which contains a rectangle (and some other elements which are irrelevant in this case). The group is draggable and I would like to change the fill color of the rectangle if the group overlaps another group while dragging. I have already implemented the logics for putting a flag which says whether the dragged group is overlapping, but I fail at changing the fill color. The mechanism looks like this:
//--- config object for the group: ---
groupTemplate: {
name: "test",
x: 100,
y: 100,
width: 100,
height: 20,
draggable: true,
dragBoundFunc: function (pos) {
return {
x: getXPos(pos.x),
y: this.getAbsolutePosition().y //prevents vertical dragging
}
}
}
The crucial part is the getXPos function. It basically sets a boolean to "true" if we are overlapping:
function getXPos(posx) {
...
/ *** check if we are overlapping, then: *** /
...
if (overlapping)
myDraggedGroup.rect.fill = "#4b9161"
else
myDraggedGroup.rect.fill = "#f49542"
}
However, this fails to work. The rectangle's color changes only AFTER having dragged the group, not WHILE we are still dragging it. I assume that I have to manually invoke some Konva "redrawing" function, but that's the part where I am stuck. Any ideas? Thanks in advance!