Jump to content
Search Community

q.com.greensock is undefined

jaumemiralles test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi, great work and thaks in advance

 

In my code i'm just creating a Draggable instance, where 'element', is a div tag that i checked is not null and has an id and a classname.

 

In return i get an strange error message in navigator console as 'TypeError: q.com.greensock is undefined'

 

The odd thing is that i didn't any changes and it was working fine all the time. I'm getting scripts via http, so they are not stored in my machine, maybe something changed?

 

 

function makeElementTouchDraggable(element) {
            console.log("touch-drag id="+element.id);
            var d = Draggable.create(element, {
                type:"y",
                bounds: list_notes_element,

                onPress:function() {                    
                },

                onRelease:function() {
                },

                onClick:function(event) {
                },

                onDragStart:function() {
                    dragStart(this.target);
                },

                onDrag:function(event) {
                    dragging(this);
                },

                onDragEnd:function(e) {
                    endingDrag(this);
                }
            });
            currentDraggable=d[0];
        }

Link to comment
Share on other sites

That error you described indicates you've got something else going on in your environment that's doing some odd things, like maybe messing with the Object prototype or something. It's very difficult to diagnose blind, though. Can you please provide a reduced test case in codepen or jsfiddle that we can look at? If you're not sure how, please take a peek at http://greensock.com/forums/topic/9002-read-this-first-how-to-create-a-codepen-demo/

  • Like 1
Link to comment
Share on other sites

I'll keep checking and prepare a codepen if necessary.

 

By the way i was in FF, now i trieb chrome and the result is:

 

Uncaught TypeError: Cannot read property 'plugins' of undefinedSa @ Draggable.min.js:14Sa.create @ Draggable.min.js:15makeElementTouchDraggable @ mb-i2-draft.jsp?idDraft=27:1004enableDnDBehavior @ mb-i2-draft.jsp?idDraft=27:978setMode @ mb-i2-draft.jsp?idDraft=27:432doubleClick @ mb-i2-draft.jsp?idDraft=27:791g._callback @ TweenMax.min.js:16g.render @ TweenMax.min.js:17g.render @ TweenMax.min.js:16C._updateRoot.F.render @ TweenMax.min.js:17g.dispatchEvent @ TweenMax.min.js:16r @ TweenMax.min.js:16

Link to comment
Share on other sites

Yep, there's definitely something interfering with normal JS operations in your project. Again, I suspect something is messing with Object.prototype or something (which is very dangerous). Tough to troubleshoot blind, but hopefully when you've got a reduced test case in codepen we'll be able to see what's going on. 

Link to comment
Share on other sites

I did.

 

I made the basic codepen, not calling your scripts, and it works:

See the Pen jAvJPq by anon (@anon) on CodePen

 

I made an awful codepen with the whole code, with the call to your scripts, and it gives the error. I prefer not to show that link in public.

 

Can it be any change on the scripts i'm calling?

 

What do you mean with 'Object.prototype' ?

Link to comment
Share on other sites

Well, the codepen won't help much if it's not reproducing the problem. I guess it kinda proves that the problem is with some other script in your project. 

 

Can you just do a search for "Object.prototype" in your entire project and see if there's any JavaScript that references that? 

 

Unfortunately we don't have the resources to troubleshoot problems that aren't GSAP-related; it definitely sounds like you've got some 3rd-party script that's doing something dangerous (or at least overstepping its bounds). I really wish I had time to read through all the code and find the issue for you. Maybe try removing 3rd party scripts one at a time until the problem goes away and that'll at least show you which one is to blame. 

  • Like 2
Link to comment
Share on other sites

You won't believe...

 

at the end i decided to cut code in a savage manner and see what happens in order to trap the problematic line, it took me time.

 

One of my functions was named "com()" and somehow that was interfering with the internal "com" gsap is using in its code. Renaming the function made all to work again smoothly and the messing error just dissapeared.

 

It seems like a bug on scope matters... but you will know better than me

 

Thanks, sir

Link to comment
Share on other sites

Yep, that makes total sense. GSAP stores all of its classes at com.greensock, thus if you had a "com()" method, that'd mess it up. Another solution would be to define a GreenSockGlobals object on your window so that GSAP puts its stuff in there, but typically that's not necessary. Like window.GreenSockGlobals = {}. But that'd also mean that you'd have to make sure all your animation code starts with that too, like GreenSockGlobals.TweenLite.to(...) which could be a pain (though you could easily set a variable at the top, like var TweenLite = GreenSockGlobals.TweenLite). 

 

Glad you figured it out. 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...