Jump to content
Search Community

MotionPathHelper error in Canvas

InchinnGuy test
Moderator Tag

Recommended Posts

Hi 
Am trying to get the new MotionPathHelper plugin to work within a canvas when animating a sprite placed on the stage
using the Pixi.js Renderer.CreateSprite method  but get this error whenever I attempt to use it:

Javascript error: Uncaught TypeError: t.getBoundingClientRect is not a function on line 10 for ......../MotionPathHelper.min.js

If Anyone have any ideas it would be much appreciated.

Here is my code:

gsap.to(this.ButtonSprite, { motionPath:{path:[{x:100, y:100}, {x:300, y:-100}, {x:-300, y:0}]},duration: 2, delay:1.5, onUpdate:UpdateStage});

MotionPathHelper.create( this.ButtonSprite );

 

 

Link to comment
Share on other sites

Hey InchinnGuy and welcome to the GreenSock forums! Thanks for being a Club GreenSock member, we couldn't do what we do without people like you.

 

As Jack said, MotionPathHelper only works with DOM elements. However, depending on your use case you may be able to use MotionPathHelper on the <canvas> element itself or a container of it (using multiple canvases if needed).

Link to comment
Share on other sites

@InchinnGuy you can totally use MotionPathHelper to create/finesse your motion paths - maybe just drop a <div> into the DOM and use that as a dummy object of sorts - it doesn't mean you actually have to use that <div> as the target of your real tweens later on. MotionPathHelper just needs something to animate along the path it's building in the browser. Once you've got your path built, copy it and paste it into your "real" tween(s). Does that help at all? 

 

If you still need some assistance, I'd strongly recommend creating a reduced test case in codepen or something and share it here so we can see what you're trying to do in context. 

  • 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...