Remove need for all special arguments in minification, and restructure code to avoid warnings.

This commit is contained in:
Jürg Lehni 2013-06-24 10:15:54 -07:00
parent 1279e8017d
commit 1866e4ff15
22 changed files with 103 additions and 98 deletions

View file

@ -10,7 +10,5 @@
# #
# All rights reserved. # All rights reserved.
# We need to keep dead_code around for now, since the very odd JavaScriptCore uglifyjs ../dist/paper.js -o ../dist/paper-min.js -c unsafe=true -m -b ascii_only=true,beautify=false --comments /^!/
# scope bug fix (nop().nop()) requires it. uglifyjs ../dist/paper-core.js -o ../dist/paper-core-min.js -c unsafe=true -m --comments /^!/
uglifyjs ../dist/paper.js -o ../dist/paper-min.js -c unsafe=true,unused=false -m -b ascii_only=true,beautify=false --comments /^!/
uglifyjs ../dist/paper-core.js -o ../dist/paper-core-min.js -c unsafe=true,unused=false -m --comments /^!/

View file

@ -228,7 +228,7 @@ var Base = new function() {
return this; return this;
}, },
extend: function(src/* , ... */) { extend: function(/* src, ... */) {
var base = this, var base = this,
ctor; ctor;
// Look for an initialize function in all injection objects and use // Look for an initialize function in all injection objects and use

View file

@ -158,19 +158,19 @@ var Matrix = Base.extend(/** @lends Matrix# */{
* @param {Point} [center] The center for the scaling transformation * @param {Point} [center] The center for the scaling transformation
* @return {Matrix} This affine transform * @return {Matrix} This affine transform
*/ */
scale: function(scale, center) { scale: function(/* scale, center */) {
// Do not modify scale, center, since that would arguments of which // Do not modify scale, center, since that would arguments of which
// we're reading from! // we're reading from!
var _scale = Point.read(arguments), var scale = Point.read(arguments),
_center = Point.read(arguments, 0, 0, true); // readNull center = Point.read(arguments, 0, 0, true); // readNull
if (_center) if (center)
this.translate(_center); this.translate(center);
this._a *= _scale.x; this._a *= scale.x;
this._c *= _scale.x; this._c *= scale.x;
this._b *= _scale.y; this._b *= scale.y;
this._d *= _scale.y; this._d *= scale.y;
if (_center) if (center)
this.translate(_center.negate()); this.translate(center.negate());
return this; return this;
}, },
@ -263,21 +263,21 @@ var Matrix = Base.extend(/** @lends Matrix# */{
* @param {Point} [center] The center for the shear transformation * @param {Point} [center] The center for the shear transformation
* @return {Matrix} This affine transform * @return {Matrix} This affine transform
*/ */
shear: function(point, center) { shear: function(/* point, center */) {
// Do not modify point, center, since that would arguments of which // Do not modify point, center, since that would arguments of which
// we're reading from! // we're reading from!
var _point = Point.read(arguments), var point = Point.read(arguments),
_center = Point.read(arguments, 0, 0, true); // readNull center = Point.read(arguments, 0, 0, true); // readNull
if (_center) if (center)
this.translate(_center); this.translate(center);
var a = this._a, var a = this._a,
c = this._c; c = this._c;
this._a += _point.y * this._b; this._a += point.y * this._b;
this._c += _point.y * this._d; this._c += point.y * this._d;
this._b += _point.x * a; this._b += point.x * a;
this._d += _point.x * c; this._d += point.x * c;
if (_center) if (center)
this.translate(_center.negate()); this.translate(center.negate());
return this; return this;
}, },
@ -447,7 +447,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{
* *
* @param {Point} point The point to be transformed * @param {Point} point The point to be transformed
*/ */
inverseTransform: function(point) { inverseTransform: function(/* point */) {
return this._inverseTransform(Point.read(arguments)); return this._inverseTransform(Point.read(arguments));
}, },

View file

@ -792,12 +792,12 @@ var Point = Base.extend(/** @lends Point# */{
* var minPoint = Point.min(point1, point2); * var minPoint = Point.min(point1, point2);
* console.log(minPoint); // {x: 10, y: 5} * console.log(minPoint); // {x: 10, y: 5}
*/ */
min: function(point1, point2) { min: function(/* point1, point2 */) {
var _point1 = Point.read(arguments); var point1 = Point.read(arguments);
_point2 = Point.read(arguments); point2 = Point.read(arguments);
return new Point( return new Point(
Math.min(_point1.x, _point2.x), Math.min(point1.x, point2.x),
Math.min(_point1.y, _point2.y) Math.min(point1.y, point2.y)
); );
}, },
@ -816,12 +816,12 @@ var Point = Base.extend(/** @lends Point# */{
* var maxPoint = Point.max(point1, point2); * var maxPoint = Point.max(point1, point2);
* console.log(maxPoint); // {x: 200, y: 100} * console.log(maxPoint); // {x: 200, y: 100}
*/ */
max: function(point1, point2) { max: function(/* point1, point2 */) {
var _point1 = Point.read(arguments); var point1 = Point.read(arguments);
_point2 = Point.read(arguments); point2 = Point.read(arguments);
return new Point( return new Point(
Math.max(_point1.x, _point2.x), Math.max(point1.x, point2.x),
Math.max(_point1.y, _point2.y) Math.max(point1.y, point2.y)
); );
}, },

View file

@ -872,7 +872,7 @@ var LinkedRectangle = Rectangle.extend({
'LeftCenter', 'TopCenter', 'RightCenter', 'BottomCenter'], 'LeftCenter', 'TopCenter', 'RightCenter', 'BottomCenter'],
function(key) { function(key) {
var name = 'set' + key; var name = 'set' + key;
this[name] = function(value) { this[name] = function(/* value */) {
// Make sure the above setters of x, y, width, height do not // Make sure the above setters of x, y, width, height do not
// each notify the owner, as we're going to take care of this // each notify the owner, as we're going to take care of this
// afterwards here, only once per change. // afterwards here, only once per change.

View file

@ -83,7 +83,7 @@ Base.inject(/** @lends Base# */{
// Keep track of all named classes for serialization and exporting. // Keep track of all named classes for serialization and exporting.
exports: {}, exports: {},
extend: function extend(src) { extend: function extend() {
// Override Base.extend() to register named classes in Base.exports, // Override Base.extend() to register named classes in Base.exports,
// for deserialization and injection into PaperScope. // for deserialization and injection into PaperScope.
var res = extend.base.apply(this, arguments), var res = extend.base.apply(this, arguments),

View file

@ -101,7 +101,6 @@ paper.PaperScope.prototype.PaperScript = new function() {
// Converts an original offset to the one in the current state of the // Converts an original offset to the one in the current state of the
// modified code. // modified code.
function getOffset(offset) { function getOffset(offset) {
var start = offset;
// Add all insertions before this location together to calculate // Add all insertions before this location together to calculate
// the current offset // the current offset
for (var i = 0, l = insertions.length; i < l; i++) { for (var i = 0, l = insertions.length; i < l; i++) {

View file

@ -723,7 +723,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
: LinkedPoint.create(this, 'setPosition', pos.x, pos.y); : LinkedPoint.create(this, 'setPosition', pos.x, pos.y);
}, },
setPosition: function(point) { setPosition: function(/* point */) {
// Calculate the distance to the current position, by which to // Calculate the distance to the current position, by which to
// translate the item. Pass true for dontLink, as we do not need a // translate the item. Pass true for dontLink, as we do not need a
// LinkedPoint to simply calculate this distance. // LinkedPoint to simply calculate this distance.
@ -1315,7 +1315,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
* *
* @param {Point} point The point to check for. * @param {Point} point The point to check for.
*/ */
contains: function(point) { contains: function(/* point */) {
// See CompoundPath#_contains() for the reason for !! // See CompoundPath#_contains() for the reason for !!
return !!this._contains( return !!this._contains(
this._matrix._inverseTransform(Point.read(arguments))); this._matrix._inverseTransform(Point.read(arguments)));
@ -2124,7 +2124,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
* *
* @param {Point} delta the offset to translate the item by * @param {Point} delta the offset to translate the item by
*/ */
translate: function(delta) { translate: function(/* delta */) {
var mx = new Matrix(); var mx = new Matrix();
return this.transform(mx.translate.apply(mx, arguments)); return this.transform(mx.translate.apply(mx, arguments));
}, },
@ -2896,7 +2896,6 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// opacity by themselves (they also don't call _setStyles) // opacity by themselves (they also don't call _setStyles)
var blendMode = this._blendMode, var blendMode = this._blendMode,
opacity = this._opacity, opacity = this._opacity,
type = this._type,
nativeBlend = BlendMode.nativeModes[blendMode], nativeBlend = BlendMode.nativeModes[blendMode],
// Determine if we can draw directly, or if we need to draw into a // Determine if we can draw directly, or if we need to draw into a
// separate canvas and then composite onto the main canvas. // separate canvas and then composite onto the main canvas.

View file

@ -58,7 +58,7 @@ var Layer = Group.extend(/** @lends Layer# */{
* position: view.center * position: view.center
* }); * });
*/ */
initialize: function Layer(items) { initialize: function Layer(/* items */) {
this._project = paper.project; this._project = paper.project;
// Push it onto project.layers and set index: // Push it onto project.layers and set index:
this._index = this._project.layers.push(this) - 1; this._index = this._project.layers.push(this) - 1;

View file

@ -483,11 +483,11 @@ var Raster = Item.extend(/** @lends Raster# */{
* @param point the offset of the pixel as a point in pixel coordinates * @param point the offset of the pixel as a point in pixel coordinates
* @param color the color that the pixel will be set to * @param color the color that the pixel will be set to
*/ */
setPixel: function(point, color) { setPixel: function(/* point, color */) {
var _point = Point.read(arguments), var point = Point.read(arguments),
_color = Color.read(arguments), color = Color.read(arguments),
components = _color._convert('rgb'), components = color._convert('rgb'),
alpha = _color._alpha, alpha = color._alpha,
ctx = this.getContext(true), ctx = this.getContext(true),
imageData = ctx.createImageData(1, 1), imageData = ctx.createImageData(1, 1),
data = imageData.data; data = imageData.data;
@ -495,7 +495,7 @@ var Raster = Item.extend(/** @lends Raster# */{
data[1] = components[1] * 255; data[1] = components[1] * 255;
data[2] = components[2] * 255; data[2] = components[2] * 255;
data[3] = alpha != null ? alpha * 255 : 255; data[3] = alpha != null ? alpha * 255 : 255;
ctx.putImageData(imageData, _point.x, _point.y); ctx.putImageData(imageData, point.x, point.y);
}, },
// DOCS: document Raster#createImageData // DOCS: document Raster#createImageData
@ -538,7 +538,7 @@ var Raster = Item.extend(/** @lends Raster# */{
return matrix ? matrix._transformBounds(rect) : rect; return matrix ? matrix._transformBounds(rect) : rect;
}, },
_hitTest: function(point, options) { _hitTest: function(point) {
if (this._contains(point)) { if (this._contains(point)) {
var that = this; var that = this;
return new HitResult('pixel', that, { return new HitResult('pixel', that, {

View file

@ -91,7 +91,7 @@ var Shape = Item.extend(/** @lends Shape# */{
} }
}, },
_hitTest: function _hitTest(point, options) { _hitTest: function _hitTest(point) {
if (this.hasStroke()) { if (this.hasStroke()) {
var type = this._type, var type = this._type,
strokeWidth = this.getStrokeWidth(); strokeWidth = this.getStrokeWidth();

View file

@ -268,13 +268,13 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
// Note: Documentation for these methods is found in PathItem, as they // Note: Documentation for these methods is found in PathItem, as they
// are considered abstract methods of PathItem and need to be defined in // are considered abstract methods of PathItem and need to be defined in
// all implementing classes. // all implementing classes.
moveTo: function(point) { moveTo: function(/* point */) {
var path = new Path(); var path = new Path();
this.addChild(path); this.addChild(path);
path.moveTo.apply(path, arguments); path.moveTo.apply(path, arguments);
}, },
moveBy: function(point) { moveBy: function(/* point */) {
this.moveTo(getCurrentPath(this).getLastSegment()._point.add( this.moveTo(getCurrentPath(this).getLastSegment()._point.add(
Point.read(arguments))); Point.read(arguments)));
}, },

View file

@ -840,7 +840,10 @@ statics: {
* @return {CurveLocation} the curve location of the specified point. * @return {CurveLocation} the curve location of the specified point.
*/ */
getLocationOf: function(point) { getLocationOf: function(point) {
var t = this.getParameterOf.apply(this, arguments); // We need to use point to avoid minification issues and prevent method
// from turning into a bean (by removal of the point argument).
point = Point.read(arguments);
var t = this.getParameterOf(point);
return t != null ? new CurveLocation(this, t) : null; return t != null ? new CurveLocation(this, t) : null;
}, },
@ -850,8 +853,7 @@ statics: {
count = 100, count = 100,
tolerance = Numerical.TOLERANCE, tolerance = Numerical.TOLERANCE,
minDist = Infinity, minDist = Infinity,
minT = 0, minT = 0;
max = 1 + tolerance; // Accomodate imprecision in comparisson
function refine(t) { function refine(t) {
if (t >= 0 && t <= 1) { if (t >= 0 && t <= 1) {
@ -880,7 +882,10 @@ statics: {
}, },
getNearestPoint: function(point) { getNearestPoint: function(point) {
return this.getNearestLocation.apply(this, arguments).getPoint(); // We need to use point to avoid minification issues and prevent method
// from turning into a bean (by removal of the point argument).
point = Point.read(arguments);
return this.getNearestLocation(point).getPoint();
} }
/** /**
@ -1339,7 +1344,6 @@ new function() { // Scope for methods that require numerical integration
cos = Math.cos(angle), cos = Math.cos(angle),
// (rl1x, rl1y) = (0, 0) // (rl1x, rl1y) = (0, 0)
rl2x = lvx * cos - lvy * sin, rl2x = lvx * cos - lvy * sin,
rl2y = lvy * cos + lvx * sin,
vcr = []; vcr = [];
for(var i = 0; i < 8; i += 2) { for(var i = 0; i < 8; i += 2) {

View file

@ -524,11 +524,11 @@ var Path = PathItem.extend(/** @lends Path# */{
: this._add([ Segment.read(arguments, 1) ], index)[0]; : this._add([ Segment.read(arguments, 1) ], index)[0];
}, },
addSegment: function(segment) { addSegment: function(/* segment */) {
return this._add([ Segment.read(arguments) ])[0]; return this._add([ Segment.read(arguments) ])[0];
}, },
insertSegment: function(index, segment) { insertSegment: function(index /*, segment */) {
return this._add([ Segment.read(arguments, 1) ], index)[0]; return this._add([ Segment.read(arguments, 1) ], index)[0];
}, },
@ -1582,6 +1582,9 @@ var Path = PathItem.extend(/** @lends Path# */{
* } * }
*/ */
getNearestPoint: function(point) { getNearestPoint: function(point) {
// We need to use point to avoid minification issues and prevent method
// from turning into a bean (by removal of the point argument).
point = Point.read(arguments);
return this.getNearestLocation(point).getPoint(); return this.getNearestLocation(point).getPoint();
}, },
@ -2102,7 +2105,7 @@ var Path = PathItem.extend(/** @lends Path# */{
// Note: Documentation for these methods is found in PathItem, as they // Note: Documentation for these methods is found in PathItem, as they
// are considered abstract methods of PathItem and need to be defined in // are considered abstract methods of PathItem and need to be defined in
// all implementing classes. // all implementing classes.
moveTo: function(point) { moveTo: function(/* point */) {
// moveTo should only be called at the beginning of paths. But it // moveTo should only be called at the beginning of paths. But it
// can ce called again if there is nothing drawn yet, in which case // can ce called again if there is nothing drawn yet, in which case
// the first segment gets readjusted. // the first segment gets readjusted.
@ -2114,29 +2117,29 @@ var Path = PathItem.extend(/** @lends Path# */{
this._add([ new Segment(Point.read(arguments)) ]); this._add([ new Segment(Point.read(arguments)) ]);
}, },
moveBy: function(point) { moveBy: function(/* point */) {
throw new Error('moveBy() is unsupported on Path items.'); throw new Error('moveBy() is unsupported on Path items.');
}, },
lineTo: function(point) { lineTo: function(/* point */) {
// Let's not be picky about calling moveTo() first: // Let's not be picky about calling moveTo() first:
this._add([ new Segment(Point.read(arguments)) ]); this._add([ new Segment(Point.read(arguments)) ]);
}, },
cubicCurveTo: function(handle1, handle2, to) { cubicCurveTo: function(/* handle1, handle2, to */) {
var _handle1 = Point.read(arguments), var handle1 = Point.read(arguments),
_handle2 = Point.read(arguments), handle2 = Point.read(arguments),
_to = Point.read(arguments); to = Point.read(arguments);
// First modify the current segment: // First modify the current segment:
var current = getCurrentSegment(this); var current = getCurrentSegment(this);
// Convert to relative values: // Convert to relative values:
current.setHandleOut(_handle1.subtract(current._point)); current.setHandleOut(handle1.subtract(current._point));
// And add the new segment, with handleIn set to c2 // And add the new segment, with handleIn set to c2
this._add([ new Segment(_to, _handle2.subtract(to)) ]); this._add([ new Segment(to, handle2.subtract(to)) ]);
}, },
quadraticCurveTo: function(handle, to) { quadraticCurveTo: function(/* handle, to */) {
var _handle = Point.read(arguments), var handle = Point.read(arguments),
to = Point.read(arguments); to = Point.read(arguments);
// This is exact: // This is exact:
// If we have the three quad points: A E D, // If we have the three quad points: A E D,
@ -2145,26 +2148,26 @@ var Path = PathItem.extend(/** @lends Path# */{
// C = E + 1/3 (D - E) // C = E + 1/3 (D - E)
var current = getCurrentSegment(this)._point; var current = getCurrentSegment(this)._point;
this.cubicCurveTo( this.cubicCurveTo(
_handle.add(current.subtract(_handle).multiply(1 / 3)), handle.add(current.subtract(handle).multiply(1 / 3)),
_handle.add(to.subtract(_handle).multiply(1 / 3)), handle.add(to.subtract(handle).multiply(1 / 3)),
to to
); );
}, },
curveTo: function(through, to, parameter) { curveTo: function(/* through, to, parameter */) {
var _through = Point.read(arguments), var through = Point.read(arguments),
_to = Point.read(arguments), to = Point.read(arguments),
t = Base.pick(Base.read(arguments), 0.5), t = Base.pick(Base.read(arguments), 0.5),
t1 = 1 - t, t1 = 1 - t,
current = getCurrentSegment(this)._point, current = getCurrentSegment(this)._point,
// handle = (through - (1 - t)^2 * current - t^2 * to) / // handle = (through - (1 - t)^2 * current - t^2 * to) /
// (2 * (1 - t) * t) // (2 * (1 - t) * t)
handle = _through.subtract(current.multiply(t1 * t1)) handle = through.subtract(current.multiply(t1 * t1))
.subtract(_to.multiply(t * t)).divide(2 * t * t1); .subtract(to.multiply(t * t)).divide(2 * t * t1);
if (handle.isNaN()) if (handle.isNaN())
throw new Error( throw new Error(
'Cannot put a curve through points with parameter = ' + t); 'Cannot put a curve through points with parameter = ' + t);
this.quadraticCurveTo(handle, _to); this.quadraticCurveTo(handle, to);
}, },
arcTo: function(to, clockwise /* | through, to */) { arcTo: function(to, clockwise /* | through, to */) {
@ -2209,7 +2212,6 @@ var Path = PathItem.extend(/** @lends Path# */{
+ [from, through, to]); + [from, through, to]);
} }
var vector = from.subtract(center), var vector = from.subtract(center),
radius = vector.getLength(),
extent = vector.getDirectedAngle(to.subtract(center)), extent = vector.getDirectedAngle(to.subtract(center)),
centerSide = line.getSide(center); centerSide = line.getSide(center);
if (centerSide == 0) { if (centerSide == 0) {

View file

@ -58,7 +58,6 @@ var PathFitter = Base.extend({
// Parameterize points, and attempt to fit curve // Parameterize points, and attempt to fit curve
var uPrime = this.chordLengthParameterize(first, last), var uPrime = this.chordLengthParameterize(first, last),
maxError = Math.max(this.error, this.error * this.error), maxError = Math.max(this.error, this.error * this.error),
error,
split; split;
// Try 4 iterations // Try 4 iterations
for (var i = 0; i <= 4; i++) { for (var i = 0; i <= 4; i++) {

View file

@ -222,6 +222,8 @@ var Segment = Base.extend(/** @lends Segment# */{
}, },
setHandleOut: function(point) { setHandleOut: function(point) {
// We need to use point to avoid minification issues and prevent method
// from turning into a bean (by removal of the point argument).
point = Point.read(arguments); point = Point.read(arguments);
// See #setPoint: // See #setPoint:
this._handleOut.set(point.x, point.y); this._handleOut.set(point.x, point.y);

View file

@ -195,12 +195,12 @@ var Color = Base.extend(new function() {
return [0, 0, g]; return [0, 0, g];
}, },
'gradient-rgb': function(gradient) { 'gradient-rgb': function(/* gradient */) {
// TODO: Implement // TODO: Implement
return []; return [];
}, },
'rgb-gradient': function(r, g, b) { 'rgb-gradient': function(/* r, g, b */) {
// TODO: Implement // TODO: Implement
return []; return [];
} }
@ -243,7 +243,7 @@ var Color = Base.extend(new function() {
: ((value % 360) + 360) % 360; : ((value % 360) + 360) % 360;
} }
: type === 'gradient' : type === 'gradient'
? function(value) { ? function(/* value */) {
// ..., readNull, clone); // ..., readNull, clone);
return Point.read(arguments, 0, 0, return Point.read(arguments, 0, 0,
name === 'highlight', true); name === 'highlight', true);

View file

@ -474,7 +474,6 @@ new function() {
// #exportSVG() on an item rather than a whole project) // #exportSVG() on an item rather than a whole project)
// jsdom in Node.js uses uppercase values for nodeName... // jsdom in Node.js uses uppercase values for nodeName...
var svg = node.nodeName.toLowerCase() === 'svg' && node, var svg = node.nodeName.toLowerCase() === 'svg' && node,
firstChild = svg ? svg.firstChild : node,
defs = null; defs = null;
for (var i in definitions.svgs) { for (var i in definitions.svgs) {
// This code is inside the loop so we only create a container if we // This code is inside the loop so we only create a container if we

View file

@ -211,7 +211,7 @@ new function() {
defs: importGroup, defs: importGroup,
// http://www.w3.org/TR/SVG/struct.html#UseElement // http://www.w3.org/TR/SVG/struct.html#UseElement
use: function(node, type) { use: function(node) {
// Note the namespaced xlink:href attribute is just called href // Note the namespaced xlink:href attribute is just called href
// as a property on node. // as a property on node.
// TODO: Support overflow and width, height, in combination with // TODO: Support overflow and width, height, in combination with
@ -336,7 +336,7 @@ new function() {
// since transform needs to be applied after fill color, as transformations // since transform needs to be applied after fill color, as transformations
// can affect gradient fills. // can affect gradient fills.
var attributes = Base.merge(Base.each(SVGStyles, function(entry) { var attributes = Base.merge(Base.each(SVGStyles, function(entry) {
this[entry.attribute] = function(item, value, name, node) { this[entry.attribute] = function(item, value) {
item[entry.set]( item[entry.set](
convertValue(value, entry.type, entry.fromSVG)); convertValue(value, entry.type, entry.fromSVG));
}; };

View file

@ -65,8 +65,8 @@ var PointText = TextItem.extend(/** @lends PointText# */{
}, },
setPoint: function(point) { setPoint: function(point) {
this.translate(Point.read(arguments).subtract( point = Point.read(arguments);
this._matrix.getTranslation())); this.translate(point.subtract(this._matrix.getTranslation()));
}, },
_draw: function(ctx) { _draw: function(ctx) {

View file

@ -14,7 +14,7 @@
* @name Palette * @name Palette
* @class * @class
*/ */
var Palette = Base.extend(Callback, /** @lends Palette# */{ /* var Palette = */ Base.extend(Callback, /** @lends Palette# */{
_class: 'Palette', _class: 'Palette',
_events: [ 'onChange' ], _events: [ 'onChange' ],

View file

@ -46,7 +46,7 @@ var View = Base.extend(Callback, /** @lends View# */{
size = DomElement.getViewportBounds(element) size = DomElement.getViewportBounds(element)
.getSize().subtract(offset); .getSize().subtract(offset);
this._windowHandlers = { this._windowHandlers = {
resize: function(event) { resize: function() {
// Only update element offset if it's not invisible, as // Only update element offset if it's not invisible, as
// otherwise the offset would be wrong. // otherwise the offset would be wrong.
if (!DomElement.isInvisible(element)) if (!DomElement.isInvisible(element))
@ -332,7 +332,10 @@ var View = Base.extend(Callback, /** @lends View# */{
}, },
setCenter: function(center) { setCenter: function(center) {
this.scrollBy(Point.read(arguments).subtract(this.getCenter())); // We need to use center to avoid minification issues and prevent method
// from turning into a bean (by removal of the center argument).
center = Point.read(arguments);
this.scrollBy(center.subtract(this.getCenter()));
}, },
/** /**
@ -367,7 +370,7 @@ var View = Base.extend(Callback, /** @lends View# */{
* *
* @param {Point} point * @param {Point} point
*/ */
scrollBy: function(point) { scrollBy: function(/* point */) {
this._transform(new Matrix().translate(Point.read(arguments).negate())); this._transform(new Matrix().translate(Point.read(arguments).negate()));
}, },
@ -389,11 +392,11 @@ var View = Base.extend(Callback, /** @lends View# */{
// TODO: getMousePoint // TODO: getMousePoint
// TODO: projectToView(rect) // TODO: projectToView(rect)
projectToView: function(point) { projectToView: function(/* point */) {
return this._matrix._transformPoint(Point.read(arguments)); return this._matrix._transformPoint(Point.read(arguments));
}, },
viewToProject: function(point) { viewToProject: function(/* point */) {
return this._getInverse()._transformPoint(Point.read(arguments)); return this._getInverse()._transformPoint(Point.read(arguments));
}, },