Merge branch 'master' of github.com:scriptographer/paper.js

This commit is contained in:
Jonathan Puckey 2011-06-14 12:24:34 +02:00
commit b55bb1b942
5 changed files with 28 additions and 12 deletions

View file

@ -26,5 +26,9 @@ cd jsdoc-toolkit
java -jar jsrun.jar app/run.js -c=conf/$MODE.conf -D="renderMode:$MODE" java -jar jsrun.jar app/run.js -c=conf/$MODE.conf -D="renderMode:$MODE"
cd .. cd ..
#build paper.js library for documentation if [ $MODE == "docs" ]
./preprocess.sh ../src/paper.js ../dist/docs/resources/js/paper.js "-DBROWSER" stripped then
# Build paper.js library for documentation
./preprocess.sh ../src/paper.js ../dist/docs/resources/js/paper.js \
"-DBROWSER" stripped
fi

@ -1 +1 @@
Subproject commit 4d1f37f9e2ea64ba0055d044c65921bc21dcb7b3 Subproject commit a3ad75a0629428accb0e940849069bedb253a89c

View file

@ -57,7 +57,16 @@ var DomElement = new function() {
); );
}, },
// Checks if element is visibile in current viewport /**
* Checks if element is invisibile (display: none, ...)
*/
isInvisible: function(el) {
return DomElement.getSize(el).equals([0, 0]);
},
/**
* Checks if element is visibile in current viewport
*/
isVisible: function(el) { isVisible: function(el) {
// See if the scrolled bounds intersect with the windows rectangle // See if the scrolled bounds intersect with the windows rectangle
// which always starts at 0, 0 // which always starts at 0, 0

View file

@ -1014,7 +1014,7 @@ var Path = this.Path = PathItem.extend({
var loc = this.getLocationAt(offset, isParameter); var loc = this.getLocationAt(offset, isParameter);
return loc && loc.getPoint(); return loc && loc.getPoint();
}, },
/** /**
* Get the tangent to the path at the given offset as a vector * Get the tangent to the path at the given offset as a vector
* point. * point.
@ -1083,7 +1083,7 @@ var Path = this.Path = PathItem.extend({
var loc = this.getLocationAt(offset, isParameter); var loc = this.getLocationAt(offset, isParameter);
return loc && loc.getTangent(); return loc && loc.getTangent();
}, },
/** /**
* Get the normal to the path at the given offset as a vector point. * Get the normal to the path at the given offset as a vector point.
* *
@ -1189,7 +1189,7 @@ var Path = this.Path = PathItem.extend({
} }
} }
} }
function drawHandle(ctx, point, handle) { function drawHandle(ctx, point, handle) {
if (!handle.isZero()) { if (!handle.isZero()) {
var handleX = point._x + handle._x, var handleX = point._x + handle._x,
@ -2188,7 +2188,7 @@ var Path = this.Path = PathItem.extend({
getControlBounds: function() { getControlBounds: function() {
// TODO: Implement! // TODO: Implement!
} }
// TODO: intersects(item) // TODO: intersects(item)
// TODO: contains(item) // TODO: contains(item)
// TODO: contains(point) // TODO: contains(point)

View file

@ -49,9 +49,9 @@ var View = this.View = Base.extend({
var that = this; var that = this;
DomEvent.add(window, { DomEvent.add(window, {
resize: function(event) { resize: function(event) {
// Only get canvas offset if it's not invisible (size is // Only get canvas offset if it's not invisible, as
// 0, 0), as otherwise the offset would be wrong. // otherwise the offset would be wrong.
if (!DomElement.getSize(canvas).equals([0, 0])) if (!DomElement.isInvisible(canvas))
offset = DomElement.getOffset(canvas); offset = DomElement.getOffset(canvas);
// Set the size now, which internally calls onResize // Set the size now, which internally calls onResize
that.setViewSize( that.setViewSize(
@ -66,7 +66,10 @@ var View = this.View = Base.extend({
} }
}); });
} else { } else {
size = Size.create(canvas.offsetWidth, canvas.offsetHeight); size = DomElement.isInvisible(canvas)
? Size.create(parseInt(canvas.getAttribute('width')),
parseInt(canvas.getAttribute('height')))
: DomElement.getSize(canvas);
} }
// TODO: Test this on IE: // TODO: Test this on IE:
if (canvas.attributes.stats) { if (canvas.attributes.stats) {