Thanks a lot to you both. I had hoped i could explain myself properly without creating a demo, but not understanding all the terms, make such an endeavour difficult...
I did make it work, but as i wrote, properly not correctly.
If i use your example Blake, this.close is simply not being called, nothing happens.
If i type it like this:
this.close()
i get a Runtime Error
this.close is not a function
If i however type this at the beginning of my function, a function which creates the Draggable, and then uses Tween to animate, then it works:
let mainComponent:MainComponent = this;
The whole function is here below, this actually works (trial and error), but i would love to make my code even better. This definately feels slightly hacky!
updateZone(zone:number, e:any) {
let selectedElement = undefined;
let sensor = this.zcon.assignedSensorId[zone];
if(sensor && !this.dragNdropModeActive) {
this.dragNdropModeActive = true;
this.dragFromThisZone = zone;
if (e.target.nearestViewportElement.classList.contains('draggable')) {
selectedElement = e.target.nearestViewportElement;
this.getRect(selectedElement, e);
this.renderer.addClass(selectedElement, 'dragging');
let options = false;
let scale = 0;
let x = 0;
let y = 0;
let mainObject:ZoneControlMain = this; // THIS IS THE WAY I CAN ACCESS MY FUNCTIONS IN TWEEN CALLBACKS
this.draggableZ = Draggable.create(".dragging .z-component", {
onPress: function() {
if(!options) {
options = true;
scale = this.target._gsTransform.scaleX;
x = this.target._gsTransform.x;
y = this.target._gsTransform.y;
}
},
onDragStart: function() {
console.log("Drag start...");
},
onDrag: function() {
const trashCanDropArea = document.getElementsByClassName("trashcan");
if (this.hitTest(".trashcan", "10%")) {
if(!trashCanDropArea[0].classList.contains('highlight')) {
trashCanDropArea[0].classList.add('highlight');
}
} else {
if(trashCanDropArea[0].classList.contains('highlight')) {
trashCanDropArea[0].classList.remove('highlight');
}
}
if (this.hitTest(".draggable", "70%")) {
console.log("SWAP");
}
},
onDragEnd: function() {
if (this.hitTest(".trashcan", "10%")) {
TweenMax.to(this.target, 0.2, {
opacity:0, scale:0,
onComplete: function() {
mainObject.closeDragMode(); // USING THIS ANGULAR COMPONENT TO ACCESS FUNCTIONS OTHERWISE NOT KNOWN TO GREENSOCK
}
});
}
if (this.hitTest(".draggable", "70%")) {
console.log("SWAPPED");
}
var tl = new TimelineLite();
tl.to(this.target, 0.2, {delay: 0.2, x:x, y:y, scale:scale}).to(this.target, 1, {delay: 0.2,opacity:1, ease:Power2.easeInOut});
}
});
}
} else {
this.closeDragMode();
}
}