First off, you’re not one for conventions are you Growly
The convention for classes is to use a label/name starting with a capital letter. You have a mix of upper and lowercase labels throughout your code, which is confusing.
For instance
function ForOwner(a) {
a.style.backgroundImage = "url(Images/Dealer.jpg)";
...
a.style.margin = "20px";
}
That looks like a constructor function to me.
I’m not an expert on OOP, but did have a go at a bit of refactoring.
class DealerAnimation {
constructor (target) {
this.animation = gsap.from(
target,
{
opacity: 0,
duration: 3,
onComplete: this.deal
}
)
this.message = 'Greetings!'
}
deal () {
console.log(this.message)
}
}
class ChatAnimation {
constructor (target) {
this.animation = gsap.to(
target,
{
x: '300px',
y: '-50px',
onComplete: this.card
}
)
this.message = 'Welcome'
}
// functions/methods should have a name that is
// a doing word. displayCard, getCard, displayMessage?
card () {
console.log(this.message)
}
}
const dealerAnim = new DealerAnimation('.Owner')
const chatAnim = new ChatAnimation('.Image')
It’s good to learn about Classes, but to an extent I am with dennisjn here — I’m certainly not a fan of the ‘this’ keyword.
Without a better look at all of your code, I can’t see any reason not to just use gsap without the class wrapper.
const dealerAnimation = gsap.from(
'.Owner',
{
opacity: 0,
duration: 3,
onComplete() {
console.log('Greetings')
}
}
)
I realise that this doesn’t answer your question, but sorting out your code to follow established conventions would be a good start. It would certainly make your code more understable to anyone who might want to help you.