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

raster.onLoad event is not firing on PhantomJS #1163

Closed
kdekooter opened this issue Sep 13, 2016 · 6 comments
Closed

raster.onLoad event is not firing on PhantomJS #1163

kdekooter opened this issue Sep 13, 2016 · 6 comments

Comments

@kdekooter
Copy link

kdekooter commented Sep 13, 2016

Not sure if this is the proper place to submit this issue. But kind of at a loss of where to start.

Could this be related to #924?

@lehni
Copy link
Member

lehni commented Sep 14, 2016

What version of the library is this happening with? Could you share a test-case for replication?

@kdekooter
Copy link
Author

The version number is 0.10.2. The code looks like this:

<html>
<head>

  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/paper.js/0.10.2/paper-core.js"></script>
  <script>

    paper.install(window);

    var raster = new Raster({
        source: 'https://en.wikipedia.org/static/images/project-logos/enwiki.png',
        position: [400, 400]
    });

    raster.onLoad = function () {
      console.log('FINISHED');
    }
  </script>

</head>
<body style="margin: 10px">

  <canvas id="canvas" height="900" width="800"></canvas>

</body>
</html>

@sapics
Copy link
Member

sapics commented Sep 15, 2016

From the sketch, it looks working. The tutorial might help you.

@kdekooter
Copy link
Author

Sure, it works in FF and Chrome. But not in PhantomJS. The word "FINISHED" never appears in the console.

@sapics
Copy link
Member

sapics commented Sep 15, 2016

Could you try this?

<html>
<head>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/paper.js/0.10.2/paper-core.js"></script>
  <script>
    paper.install(window);
    window.onload = function() {
      paper.setup('canvas');
      var raster = new Raster({
        source: 'https://en.wikipedia.org/static/images/project-logos/enwiki.png',
        position: [400, 400]
      });
      raster.onLoad = function () {
        console.log('FINISHED');
      }
    }
  </script>
</head>
<body style="margin: 10px">
  <canvas id="canvas" height="900" width="800"></canvas>
</body>
</html>

@kdekooter
Copy link
Author

kdekooter commented Sep 15, 2016

I am sorry, my snippet was incomplete. I wrapped the code in a jQuery document.ready statement ($(function () {).

With window.onload it is working!

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

3 participants