Fixed shadows’ tests

master
Dmitry Baranovskiy 2017-02-02 12:51:35 +11:00
parent a63c1e6127
commit e02f17aebe
6 changed files with 55 additions and 45 deletions

File diff suppressed because one or more lines are too long

24
dist/snap.svg.js vendored
View File

@ -14,7 +14,7 @@
// 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: 2017-02-01 // build: 2017-02-02
// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
// //
@ -505,8 +505,10 @@ var mina = (function (eve) {
window.oRequestAnimationFrame || window.oRequestAnimationFrame ||
window.msRequestAnimationFrame || window.msRequestAnimationFrame ||
function (callback) { function (callback) {
setTimeout(callback, 16); setTimeout(callback, 16, new Date().getTime());
return true;
}, },
requestID,
isArray = Array.isArray || function (a) { isArray = Array.isArray || function (a) {
return a instanceof Array || return a instanceof Array ||
Object.prototype.toString.call(a) == "[object Array]"; Object.prototype.toString.call(a) == "[object Array]";
@ -580,6 +582,7 @@ var mina = (function (eve) {
a.b = a.get() - a.pdif; a.b = a.get() - a.pdif;
delete a.pdif; delete a.pdif;
animations[a.id] = a; animations[a.id] = a;
frame();
}, },
update = function () { update = function () {
var a = this, var a = this,
@ -595,7 +598,16 @@ var mina = (function (eve) {
} }
a.set(res); a.set(res);
}, },
frame = function () { frame = function (timeStamp) {
// Manual invokation?
if (!timeStamp) {
// Frame loop stopped?
if (!requestID) {
// Start frame loop...
requestID = requestAnimFrame(frame);
}
return;
}
var len = 0; var len = 0;
for (var i in animations) if (animations.hasOwnProperty(i)) { for (var i in animations) if (animations.hasOwnProperty(i)) {
var a = animations[i], var a = animations[i],
@ -615,7 +627,7 @@ var mina = (function (eve) {
} }
a.update(); a.update();
} }
len && requestAnimFrame(frame); requestID = len ? requestAnimFrame(frame) : false;
}, },
/*\ /*\
* mina * mina
@ -679,7 +691,7 @@ var mina = (function (eve) {
break; break;
} }
} }
len == 1 && requestAnimFrame(frame); len == 1 && frame();
return anim; return anim;
}; };
/*\ /*\
@ -8135,8 +8147,8 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
blur = 4; blur = 4;
color = "#000"; color = "#000";
} else { } else {
color = blur;
opacity = color; opacity = color;
color = blur;
blur = 4; blur = 4;
} }
} }

View File

@ -9886,7 +9886,7 @@ the classs presence or the value of the <code>flag</code> argument.
<article id="mina"> <article id="mina">
<header> <header>
<h3 class="dr-method">mina(a, A, b, B, get, set, [easing])<a href="#mina" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 168 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L168">&#x27ad;</a></h3> <h3 class="dr-method">mina(a, A, b, B, get, set, [easing])<a href="#mina" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 180 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L180">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="mina-extra"></div> <div class="extra" id="mina-extra"></div>
@ -10120,7 +10120,7 @@ the classs presence or the value of the <code>flag</code> argument.
<article id="mina.time"> <article id="mina.time">
<header> <header>
<h3 class="dr-method">mina.time()<a href="#mina.time" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 208 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L208">&#x27ad;</a></h3> <h3 class="dr-method">mina.time()<a href="#mina.time" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 220 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L220">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="mina.time-extra"></div> <div class="extra" id="mina.time-extra"></div>
@ -10158,7 +10158,7 @@ the classs presence or the value of the <code>flag</code> argument.
<article id="mina.getById"> <article id="mina.getById">
<header> <header>
<h3 class="dr-method">mina.getById(id)<a href="#mina.getById" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 217 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L217">&#x27ad;</a></h3> <h3 class="dr-method">mina.getById(id)<a href="#mina.getById" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 229 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L229">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="mina.getById-extra"></div> <div class="extra" id="mina.getById-extra"></div>
@ -10218,7 +10218,7 @@ the classs presence or the value of the <code>flag</code> argument.
<article id="mina.linear"> <article id="mina.linear">
<header> <header>
<h3 class="dr-method">mina.linear(n)<a href="#mina.linear" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 229 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L229">&#x27ad;</a></h3> <h3 class="dr-method">mina.linear(n)<a href="#mina.linear" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 241 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L241">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="mina.linear-extra"></div> <div class="extra" id="mina.linear-extra"></div>
@ -10278,7 +10278,7 @@ the classs presence or the value of the <code>flag</code> argument.
<article id="mina.easeout"> <article id="mina.easeout">
<header> <header>
<h3 class="dr-method">mina.easeout(n)<a href="#mina.easeout" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 240 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L240">&#x27ad;</a></h3> <h3 class="dr-method">mina.easeout(n)<a href="#mina.easeout" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 252 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L252">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="mina.easeout-extra"></div> <div class="extra" id="mina.easeout-extra"></div>
@ -10338,7 +10338,7 @@ the classs presence or the value of the <code>flag</code> argument.
<article id="mina.easein"> <article id="mina.easein">
<header> <header>
<h3 class="dr-method">mina.easein(n)<a href="#mina.easein" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 251 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L251">&#x27ad;</a></h3> <h3 class="dr-method">mina.easein(n)<a href="#mina.easein" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 263 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L263">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="mina.easein-extra"></div> <div class="extra" id="mina.easein-extra"></div>
@ -10398,7 +10398,7 @@ the classs presence or the value of the <code>flag</code> argument.
<article id="mina.easeinout"> <article id="mina.easeinout">
<header> <header>
<h3 class="dr-method">mina.easeinout(n)<a href="#mina.easeinout" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 262 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L262">&#x27ad;</a></h3> <h3 class="dr-method">mina.easeinout(n)<a href="#mina.easeinout" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 274 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L274">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="mina.easeinout-extra"></div> <div class="extra" id="mina.easeinout-extra"></div>
@ -10458,7 +10458,7 @@ the classs presence or the value of the <code>flag</code> argument.
<article id="mina.backin"> <article id="mina.backin">
<header> <header>
<h3 class="dr-method">mina.backin(n)<a href="#mina.backin" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 286 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L286">&#x27ad;</a></h3> <h3 class="dr-method">mina.backin(n)<a href="#mina.backin" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 298 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L298">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="mina.backin-extra"></div> <div class="extra" id="mina.backin-extra"></div>
@ -10518,7 +10518,7 @@ the classs presence or the value of the <code>flag</code> argument.
<article id="mina.backout"> <article id="mina.backout">
<header> <header>
<h3 class="dr-method">mina.backout(n)<a href="#mina.backout" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 301 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L301">&#x27ad;</a></h3> <h3 class="dr-method">mina.backout(n)<a href="#mina.backout" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 313 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L313">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="mina.backout-extra"></div> <div class="extra" id="mina.backout-extra"></div>
@ -10578,7 +10578,7 @@ the classs presence or the value of the <code>flag</code> argument.
<article id="mina.elastic"> <article id="mina.elastic">
<header> <header>
<h3 class="dr-method">mina.elastic(n)<a href="#mina.elastic" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 317 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L317">&#x27ad;</a></h3> <h3 class="dr-method">mina.elastic(n)<a href="#mina.elastic" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 329 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L329">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="mina.elastic-extra"></div> <div class="extra" id="mina.elastic-extra"></div>
@ -10638,7 +10638,7 @@ the classs presence or the value of the <code>flag</code> argument.
<article id="mina.bounce"> <article id="mina.bounce">
<header> <header>
<h3 class="dr-method">mina.bounce(n)<a href="#mina.bounce" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 332 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L332">&#x27ad;</a></h3> <h3 class="dr-method">mina.bounce(n)<a href="#mina.bounce" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 344 in the source" href="https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js#L344">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="mina.bounce-extra"></div> <div class="extra" id="mina.bounce-extra"></div>

View File

@ -138,8 +138,8 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
blur = 4; blur = 4;
color = "#000"; color = "#000";
} else { } else {
color = blur;
opacity = color; opacity = color;
color = blur;
blur = 4; blur = 4;
} }
} }

View File

@ -59,24 +59,24 @@ describe("Filter methods", function () {
str = Snap.filter.shadow(-1, 3); str = Snap.filter.shadow(-1, 3);
expect(str).to.be('<feGaussianBlur in="SourceAlpha" stdDeviation="4"/><feOffset dx="-1" dy="3" result="offsetblur"/><feFlood flood-color="#000000"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="1"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>'); expect(str).to.be('<feGaussianBlur in="SourceAlpha" stdDeviation="4"/><feOffset dx="-1" dy="3" result="offsetblur"/><feFlood flood-color="#000000"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="1"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>');
}); });
it("Snap.filter.shadow - dx & dy, blur", function() { it("Snap.filter.shadow - dx & dy, opacity", function() {
var str = Snap.filter.shadow(5, 5, 5); var str = Snap.filter.shadow(5, 5, 5);
expect(str).to.be('<feGaussianBlur in="SourceAlpha" stdDeviation="5"/><feOffset dx="5" dy="5" result="offsetblur"/><feFlood flood-color="#000000"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="1"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>'); expect(str).to.be('<feGaussianBlur in="SourceAlpha" stdDeviation="4"/><feOffset dx="5" dy="5" result="offsetblur"/><feFlood flood-color="#000000"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="5"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>');
str = Snap.filter.shadow(-1, 3, 10); str = Snap.filter.shadow(-1, 3, 10);
expect(str).to.be('<feGaussianBlur in="SourceAlpha" stdDeviation="10"/><feOffset dx="-1" dy="3" result="offsetblur"/><feFlood flood-color="#000000"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="1"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>'); expect(str).to.be('<feGaussianBlur in="SourceAlpha" stdDeviation="4"/><feOffset dx="-1" dy="3" result="offsetblur"/><feFlood flood-color="#000000"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="10"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>');
}); });
it("Snap.filter.shadow - dx & dy, color", function() { it("Snap.filter.shadow - dx & dy, color, opacity", function() {
var str = Snap.filter.shadow(5, 5, '#F00'); var str = Snap.filter.shadow(5, 5, '#F00', 1);
expect(str).to.be('<feGaussianBlur in="SourceAlpha" stdDeviation="4"/><feOffset dx="5" dy="5" result="offsetblur"/><feFlood flood-color="#ff0000"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="#F00"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>'); expect(str).to.be('<feGaussianBlur in="SourceAlpha" stdDeviation="4"/><feOffset dx="5" dy="5" result="offsetblur"/><feFlood flood-color="#ff0000"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="1"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>');
str = Snap.filter.shadow(-1, 3, 'hsla(128deg, 50%, 50%, 0.8)'); str = Snap.filter.shadow(-1, 3, 'hsla(128deg, 50%, 50%, 0.8)', .5);
expect(str).to.be('<feGaussianBlur in="SourceAlpha" stdDeviation="4"/><feOffset dx="-1" dy="3" result="offsetblur"/><feFlood flood-color="rgba(64,191,81,0.8)"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="hsla(128deg, 50%, 50%, 0.8)"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>'); expect(str).to.be('<feGaussianBlur in="SourceAlpha" stdDeviation="4"/><feOffset dx="-1" dy="3" result="offsetblur"/><feFlood flood-color="rgba(64,191,81,0.8)"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="0.5"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>');
}); });
it("Snap.filter.shadow - dx & dy, blur & color", function() { it("Snap.filter.shadow - dx & dy, blur, color, opacity", function() {
var str = Snap.filter.shadow(5, 5, 5, '#F00'); var str = Snap.filter.shadow(5, 5, 5, '#F00', 1);
expect(str).to.be('<feGaussianBlur in="SourceAlpha" stdDeviation="5"/><feOffset dx="5" dy="5" result="offsetblur"/><feFlood flood-color="#ff0000"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="1"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>'); expect(str).to.be('<feGaussianBlur in="SourceAlpha" stdDeviation="5"/><feOffset dx="5" dy="5" result="offsetblur"/><feFlood flood-color="#ff0000"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="1"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>');
str = Snap.filter.shadow(-1, 3, 10, 'hsla(128deg, 50%, 50%, 0.8)'); str = Snap.filter.shadow(-1, 3, 10, 'hsla(128deg, 50%, 50%, 0.8)', .5);
expect(str).to.be('<feGaussianBlur in="SourceAlpha" stdDeviation="10"/><feOffset dx="-1" dy="3" result="offsetblur"/><feFlood flood-color="rgba(64,191,81,0.8)"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="1"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>'); expect(str).to.be('<feGaussianBlur in="SourceAlpha" stdDeviation="10"/><feOffset dx="-1" dy="3" result="offsetblur"/><feFlood flood-color="rgba(64,191,81,0.8)"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="0.5"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>');
}); });

View File

@ -45,12 +45,10 @@
<script src="filter.js"></script> <script src="filter.js"></script>
<script src="matrix.js"></script> <script src="matrix.js"></script>
<script src="mina.js"></script> <script src="mina.js"></script>
<svg id="svgroot"></svg>
<script> <script>
mocha.checkLeaks(); mocha.checkLeaks();
window.onload = function () {
mocha.run(); mocha.run();
};
</script> </script>
<svg id="svgroot"></svg>
</body> </body>
</html> </html>