Utilizing a third-party component requires creating an object for configuration, such as itemMovementOptions
in the given code sample.
export class AppComponent implements OnInit {
readonly itemMovementOptions = {
threshold: {
horizontal: 25,
vertical: 25,
},
events: {
onMove({ items }) {
for (let i = 0, len = items.after.length; i < len; i++) {
const item = items.after[i];
if (!this.canMove(item)) return items.before;
}
return items.after;
},
},
};
public canMove(item) {
// ...
}
readonly config = {
ItemResizing(this.itemResizeOptions),
ItemMovement(this.itemMovementOptions),
}
ngOnInit(): void {
GSTC.api.stateFromConfig(this.config);
}
}
The issue arises when the code is executed and 'this' does not reference AppComponent, causing it to fail to find the method canMove().
I need help overcoming this problem. I must use canMove at multiple places without duplicating code or putting it into the callback.