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

Canvas option error on Reactjs #18

Closed
rainstormza opened this issue May 25, 2018 · 4 comments
Closed

Canvas option error on Reactjs #18

rainstormza opened this issue May 25, 2018 · 4 comments

Comments

@rainstormza
Copy link

rainstormza commented May 25, 2018

image

  componentDidMount() {
    window.bubbly({
      colorStart: "#fff4e6",
      colorStop: "#ffe9e4",
      blur: 1,
      compose: "source-over",
      bubbleFunc: () => `hsla(${Math.random() * 50}, 100%, 50%, .3)`,
      canvas: document.getElementById("background") // error this line
    });
  }

I've tried to use your lib like this, it work fine until I added option canvase and then it throw an error.

Any help ? thanks :)

@tipsy
Copy link
Owner

tipsy commented May 25, 2018

Did you read through https://reactjs.org/docs/cross-origin-errors.html ?

Seems weird that it only happens if you specify a canvas. How does the HTML for your canvas look?

@rainstormza
Copy link
Author

rainstormza commented May 26, 2018

Yes, I did.
I've tried

image

but it does not work.

this is my test component

image

I'm just curious that what canvas option exactly mean.
If I want background to show only inside this div (id = "background") so I have to use this option.
Am i right ?

you can try my repo. https://github.com/rainstormza/react-bubble

@tipsy
Copy link
Owner

tipsy commented May 26, 2018

You're right, but it has to be a <canvas> element (docs), not a <div>.

Here is an example: https://tipsy.github.io/bubbly-bg/custom-canvas-example.html

Using a div shouldn't really give you the error you're seeing, but let me know if using a canvas fixes it.

@rainstormza
Copy link
Author

it works, my bad
thanks for your help :)

image

image

This was referenced May 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants