Fixed bug with missed bbox parameter

master
Dmitry Baranovskiy 2016-12-22 11:33:43 +11:00
parent 2e6a2afa0f
commit 1492b44dac
3 changed files with 51 additions and 48 deletions

File diff suppressed because one or more lines are too long

89
dist/snap.svg.js vendored
View File

@ -14,16 +14,16 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// build: 2016-12-09 // build: 2016-12-14
// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -185,7 +185,7 @@
} }
return out; return out;
}; };
/*\ /*\
* eve.on * eve.on
[ method ] [ method ]
@ -200,7 +200,7 @@
- name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards - name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards
- f (function) event handler function - f (function) event handler function
** **
= (function) returned function accepts a single numeric parameter that represents z-index of the handler. It is an optional feature and only used when you need to ensure that some subset of handlers will be invoked in a given order, despite of the order of assignment. = (function) returned function accepts a single numeric parameter that represents z-index of the handler. It is an optional feature and only used when you need to ensure that some subset of handlers will be invoked in a given order, despite of the order of assignment.
> Example: > Example:
| eve.on("mouse", eatIt)(2); | eve.on("mouse", eatIt)(2);
| eve.on("mouse", scream); | eve.on("mouse", scream);
@ -439,13 +439,13 @@
}(window || this, function (window, eve) { }(window || this, function (window, eve) {
// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -4001,13 +4001,13 @@ Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
}); });
// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -4561,13 +4561,13 @@ Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
}); });
// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -4650,13 +4650,13 @@ Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
})(-10); })(-10);
}); });
// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -6829,13 +6829,13 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
}); });
// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -7182,6 +7182,8 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
} }
} }
function equaliseTransform(t1, t2, getBBox) { function equaliseTransform(t1, t2, getBBox) {
t1 = t1 || new Snap.Matrix;
t2 = t2 || new Snap.Matrix;
t1 = Snap.parseTransformString(t1.toTransformString()) || []; t1 = Snap.parseTransformString(t1.toTransformString()) || [];
t2 = Snap.parseTransformString(t2.toTransformString()) || []; t2 = Snap.parseTransformString(t2.toTransformString()) || [];
var maxlength = Math.max(t1.length, t2.length), var maxlength = Math.max(t1.length, t2.length),
@ -7293,11 +7295,10 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
// b = b.toTransformString(); // b = b.toTransformString();
} }
if (!Snap._.rgTransform.test(b)) { if (!Snap._.rgTransform.test(b)) {
b = Snap._.transform2matrix(Snap._.svgTransform2string(b)); b = Snap._.transform2matrix(Snap._.svgTransform2string(b), this.getBBox());
} else { } else {
b = Snap._.transform2matrix(b); b = Snap._.transform2matrix(b, this.getBBox());
} }
console.log(a, b)
return equaliseTransform(a, b, function () { return equaliseTransform(a, b, function () {
return el.getBBox(1); return el.getBBox(1);
}); });
@ -7345,13 +7346,13 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
}); });
// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -7494,7 +7495,7 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
- handler (function) handler for the event - handler (function) handler for the event
= (object) @Element = (object) @Element
\*/ \*/
/*\ /*\
* Element.dblclick * Element.dblclick
[ method ] [ method ]
@ -7511,7 +7512,7 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
- handler (function) handler for the event - handler (function) handler for the event
= (object) @Element = (object) @Element
\*/ \*/
/*\ /*\
* Element.mousedown * Element.mousedown
[ method ] [ method ]
@ -7528,7 +7529,7 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
- handler (function) handler for the event - handler (function) handler for the event
= (object) @Element = (object) @Element
\*/ \*/
/*\ /*\
* Element.mousemove * Element.mousemove
[ method ] [ method ]
@ -7545,7 +7546,7 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
- handler (function) handler for the event - handler (function) handler for the event
= (object) @Element = (object) @Element
\*/ \*/
/*\ /*\
* Element.mouseout * Element.mouseout
[ method ] [ method ]
@ -7562,7 +7563,7 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
- handler (function) handler for the event - handler (function) handler for the event
= (object) @Element = (object) @Element
\*/ \*/
/*\ /*\
* Element.mouseover * Element.mouseover
[ method ] [ method ]
@ -7579,7 +7580,7 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
- handler (function) handler for the event - handler (function) handler for the event
= (object) @Element = (object) @Element
\*/ \*/
/*\ /*\
* Element.mouseup * Element.mouseup
[ method ] [ method ]
@ -7596,7 +7597,7 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
- handler (function) handler for the event - handler (function) handler for the event
= (object) @Element = (object) @Element
\*/ \*/
/*\ /*\
* Element.touchstart * Element.touchstart
[ method ] [ method ]
@ -7613,7 +7614,7 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
- handler (function) handler for the event - handler (function) handler for the event
= (object) @Element = (object) @Element
\*/ \*/
/*\ /*\
* Element.touchmove * Element.touchmove
[ method ] [ method ]
@ -7630,7 +7631,7 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
- handler (function) handler for the event - handler (function) handler for the event
= (object) @Element = (object) @Element
\*/ \*/
/*\ /*\
* Element.touchend * Element.touchend
[ method ] [ method ]
@ -7647,7 +7648,7 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
- handler (function) handler for the event - handler (function) handler for the event
= (object) @Element = (object) @Element
\*/ \*/
/*\ /*\
* Element.touchcancel * Element.touchcancel
[ method ] [ method ]
@ -7741,8 +7742,8 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
- mcontext (object) #optional context for moving handler - mcontext (object) #optional context for moving handler
- scontext (object) #optional context for drag start handler - scontext (object) #optional context for drag start handler
- econtext (object) #optional context for drag end handler - econtext (object) #optional context for drag end handler
* Additionaly following `drag` events are triggered: `drag.start.<id>` on start, * Additionaly following `drag` events are triggered: `drag.start.<id>` on start,
* `drag.end.<id>` on end and `drag.move.<id>` on every move. When element is dragged over another element * `drag.end.<id>` on end and `drag.move.<id>` on every move. When element is dragged over another element
* `drag.over.<id>` fires as well. * `drag.over.<id>` fires as well.
* *
* Start event and start handler are called in specified context or in context of the element with following parameters: * Start event and start handler are called in specified context or in context of the element with following parameters:
@ -7822,13 +7823,13 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
}); });
// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -7874,7 +7875,7 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
paper.defs.appendChild(filter); paper.defs.appendChild(filter);
return new Element(filter); return new Element(filter);
}; };
eve.on("snap.util.getattr.filter", function () { eve.on("snap.util.getattr.filter", function () {
eve.stop(); eve.stop();
var p = $(this.node, "filter"); var p = $(this.node, "filter");
@ -8242,4 +8243,4 @@ Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
}); });
return Snap; return Snap;
})); }));

View File

@ -36,6 +36,8 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
} }
} }
function equaliseTransform(t1, t2, getBBox) { function equaliseTransform(t1, t2, getBBox) {
t1 = t1 || new Snap.Matrix;
t2 = t2 || new Snap.Matrix;
t1 = Snap.parseTransformString(t1.toTransformString()) || []; t1 = Snap.parseTransformString(t1.toTransformString()) || [];
t2 = Snap.parseTransformString(t2.toTransformString()) || []; t2 = Snap.parseTransformString(t2.toTransformString()) || [];
var maxlength = Math.max(t1.length, t2.length), var maxlength = Math.max(t1.length, t2.length),
@ -147,9 +149,9 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
// b = b.toTransformString(); // b = b.toTransformString();
} }
if (!Snap._.rgTransform.test(b)) { if (!Snap._.rgTransform.test(b)) {
b = Snap._.transform2matrix(Snap._.svgTransform2string(b)); b = Snap._.transform2matrix(Snap._.svgTransform2string(b), this.getBBox());
} else { } else {
b = Snap._.transform2matrix(b); b = Snap._.transform2matrix(b, this.getBBox());
} }
console.log(a, b) console.log(a, b)
return equaliseTransform(a, b, function () { return equaliseTransform(a, b, function () {