Hey everyone,
I'm attempting to create dynamic snapping to other snappable objects. I thought I could simply assign the liveSnap points to a global variable, and then change that variable. It worked, kinda. I can now dynamically add additional snap points to an array and the remaining snappable objects will have access to these new points.
The problems exists when attempting to remove a snap point from the global variable. I honestly don't think this problem pertains to GreenSock, and is a vanilla javascript issue that I'm having on my own. However, I'm curious to see if there is a way I can snap two snappable objects together, easier than my way. If not, here's the part giving me a problem.
(I think)
// Remove this obj's snap points from the global snap point list
this.removeSnapPoints = () => {
let pointLocations = [
this.snapPoints.tl,
this.snapPoints.tm,
this.snapPoints.tr,
this.snapPoints.ml,
this.snapPoints.mr,
this.snapPoints.bl,
this.snapPoints.bm,
this.snapPoints.br,
];
// for (let val of )
// console.log(this.snapPoints.tl);
console.log(`Before: ${snappablePoints}`);
pointLocations.forEach(pointLoc => {
console.log(`Index of tl: ${snappablePoints.indexOf(pointLoc)}`);
console.log(`Value of tl: ${JSON.stringify(pointLocations)}`);
snappablePoints.forEach(snap => {
if (JSON.stringify(pointLoc) == JSON.stringify(snap)) {
console.log(`pointLoc: ${JSON.stringify(pointLoc)} | snap: ${JSON.stringify(snap)}`);
}
});
// This function is deleting all of the items in the array instead of just the ones I identified (i.e. the points that belong to the panel being moved)
});
};