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

this is undefined error in last releases #43

Closed
revoltek-daniel opened this issue Nov 14, 2022 · 6 comments
Closed

this is undefined error in last releases #43

revoltek-daniel opened this issue Nov 14, 2022 · 6 comments

Comments

@revoltek-daniel
Copy link

Hello,

since 1.0.5 i get the error message "this is undefined" it looks like it is caused by this commit
c4b4aef

@tholman
Copy link
Owner

tholman commented Nov 14, 2022

Could you send over your code in a little demo plz, looking to debug.

@revoltek-daniel
Copy link
Author

revoltek-daniel commented Nov 14, 2022

import {fairyDustCursor} from 'cursor-effects'

fairyDustCursor({colors: ["#ff0000", "#00ff00", "#0000ff"]});

compile this with webpack and you get the undefined error on "this.destroy"

<html>
<head>
    <title>test</title>
    <script src="https://unpkg.com/cursor-effects@latest/dist/browser.js"></script>
<script>
    new cursoreffects.fairyDustCursor({colors: ["#ff0000", "#00ff00", "#0000ff"]});
</script>
</head>
<body></body>
</html>

leads to another "Uncaught TypeError: n is null" errorin browser.js:1:9861

pushed my demo code also to this repo: https://github.com/revoltek-daniel/cursor-test

@tholman
Copy link
Owner

tholman commented Nov 15, 2022

Ahh, it looks like in test 2 the function needs to be in a window.onload (or in the body) to run after the body exists, I should be able to make a fix for that where there is some kind of wait/check

As for 1, im not quite sure why it won't allow an assignment to this in the compiled version but should be able to figure it out this week/weekend

@tholman
Copy link
Owner

tholman commented Nov 15, 2022

(the import bug is now fixed), using an onLoad, or calling the create after the body is rendered will fix the rendering for now, until I do something better there.

@tholman
Copy link
Owner

tholman commented Nov 15, 2022

Feels like the main bug is covered. I will add some documentation to ensure that the function is called when a body exists if its working correctly for you

@tholman
Copy link
Owner

tholman commented Nov 28, 2022

Fixes out, and docs updated

@tholman tholman closed this as completed Nov 28, 2022
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