paperjs / paper.js

The Swiss Army Knife of Vector Graphics Scripting – Scriptographer ported to JavaScript and the browser, using HTML5 Canvas. Created by @lehni & @puckey
http://paperjs.org
Other
14.45k stars 1.22k forks source link

Part of canvas not visible at load not usable #598

Closed alexkurtz closed 9 years ago

alexkurtz commented 9 years ago

I have a problem when using paper.js whith areas of the canvas that are not visible at load-time. Depending on the user device, screen is not always the same size, and sometimes the canvas gets hidden on the scrolling down area. If that is the case when loading, nothing can be plotted there (tested both in chrome and firefox). If the page is reloaded with that area scrolled so it becames visible, the area can be used, no matter if it gets hidden again.

Is this some issue with the library?

georeith commented 9 years ago

@alexkurtz

Are you using the resize option, e.g., <canvas resize="true"></canvas>?

If you don't set the canvas to be resizable then paperJS explicitly sets it's width and height and doesn't change this value unless explicitly told to.

Can you reproduce this in a jsfiddle or your favourite online editor?

alexkurtz commented 9 years ago

I've done a jsfiddle that reproduces the problem. If the "buffer" height is set so the canvas drops below the scroll line (depends on the screen), part of it is not updated. I've linked the version of the library I'm using in the project.

http://jsfiddle.net/alexkurtz/4r39a3kp/4/#&togetherjs=GGgM4BsP0u

I hope this helps clarify why this is happening, because it's weird. last 50px are not being rendered when not visible...

georeith commented 9 years ago

This is same issue as #580 and can be fixed by #586

See: http://jsfiddle.net/6dstfe1u/1/

alexkurtz commented 9 years ago

Great! Works perfectly. I assume this fix will be in the next release? Thanks a lot!

georeith commented 9 years ago

@alexkurtz Not for me to say. I think @lehni is working on a different version, but whether it makes it in the next release I'm not sure.

I'm using this in production at the moment just with a build off my fork. If it's a deal breaker you can do that, but I'm not merging updates in for the time being (not maintaining it as a fork just a required fix until an official one is implemented or it gets merged).

alexkurtz commented 9 years ago

I see... Let's hope it makes into the main branch, since it's a fix many people would need and seems easy to fix.

Thanks @georeith for your answers and help!

dtracers commented 9 years ago

+1 to merging this in as it is affecting me right now! Well a similar one. I am resizing the canvas and explicitly setting the new view port but anything outside of the original size is not actually clearing so everything drawn just stays drawn. (really annoying).

lehni commented 9 years ago

It's merged in!