Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"rand" in className property throwing errors #138

Open
SudoCat opened this issue May 18, 2017 · 3 comments
Open

"rand" in className property throwing errors #138

SudoCat opened this issue May 18, 2017 · 3 comments
Labels
bug bug to fix
Projects

Comments

@SudoCat
Copy link
Contributor

SudoCat commented May 18, 2017

I'm attempting to create a mojs.Shape tween for my current project. Here are the options I'm using:

new mojs.Shape({
  className: 'Brands-burst',
  fill: colour,
  strokeWidth: 0,
  scale: { 0 : 1 },
  easing:'quad.in'
});

Unfortunately, this throws the following error in the console:
image

I did some testing, and it seems it happens if the className property contains the letters "rand" - anything else works fine, but if that string is found anywhere in the property, the error is thrown.

@legomushroom legomushroom added the bug bug to fix label May 18, 2017
@legomushroom
Copy link
Member

legomushroom commented May 18, 2017

Hey Robin,

Thanks for the issue. The problem is that rand is a special word for properties, for instance:

new mojs.Shape({
  className: 'Brands-burst',
  fill: colour,
  strokeWidth: 'rand(0, 5)',
  scale: { 0 : 1 },
  easing:'quad.in'
});

This is totally a bug since we need to do the smarter job with Regexp that parses the properties.

As a solution, for now, you can use el property to set the class name for the module:

const shape = new mojs.Shape({
  fill: colour,
  strokeWidth: 'rand(0, 5)',
  scale: { 0 : 1 },
  easing:'quad.in'
});

shape.el.className += ' Brands-burst';

Cheers~

@SudoCat
Copy link
Contributor Author

SudoCat commented May 18, 2017

Thanks for the speedy reply! Good shout, somehow didn't think of that one.
I had a feeling that was probably the cause, just wanted to make sure I reported it before I forgot! Maybe the regexp should just include the opening bracket too? I would presume the keyword wouldn't work without it anyway.

@legomushroom
Copy link
Member

Thanks for taking time for reporting it, great catch! Yeah, the Regexp makes weak assumptions and needs to be revamped.

@xavierfoucrier xavierfoucrier added this to Bugs in mojs@next Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bug to fix
Projects
No open projects
Development

No branches or pull requests

2 participants