Fix for #122 and added Set.remove() method

master
Dmitry Baranovskiy 2013-11-20 11:42:25 +11:00
parent 4396f201bd
commit 913d1d578b
6 changed files with 124 additions and 8 deletions

File diff suppressed because one or more lines are too long

23
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: 2013-11-19 // build: 2013-11-20
// 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");
@ -4252,6 +4252,21 @@ Snap.getElementByPoint = function (x, y) {
} }
return wrap(target); return wrap(target);
}; };
/*\
* Snap.plugin
[ method ]
**
* Let you write plugins. You pass in a function with four arguments, like this:
| Snap.plugin(function (Snap, Element, Paper, global) {
| Snap.newmethod = function () {};
| Element.prototype.newmethod = function () {};
| Paper.prototype.newmethod = function () {};
| });
* Inside the function you have access to all main objects (and their
* prototypes). This allow you to extend anything you want.
**
- f (function) your plugin body
\*/
Snap.plugin = function (f) { Snap.plugin = function (f) {
f(Snap, Element, Paper, glob); f(Snap, Element, Paper, glob);
}; };
@ -5692,6 +5707,12 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
} }
return this; return this;
}; };
setproto.remove = function () {
while (this.length) {
this.pop().remove();
}
return this;
};
setproto.attr = function (value) { setproto.attr = function (value) {
for (var i = 0, ii = this.items.length; i < ii; i++) { for (var i = 0, ii = this.items.length; i < ii; i++) {
this.items[i].attr(value); this.items[i].attr(value);

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<base href="http://snapsvg.io"> <base href="http://snapsvg.io/docs/">
<title>Snap.svg API Reference</title> <title>Snap.svg API Reference</title>
<link rel="shortcut icon" href="/assets/favicon.ico?v=1"> <link rel="shortcut icon" href="/assets/favicon.ico?v=1">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
@ -639,6 +639,10 @@
<a href="#Snap.path.toRelative" class="dr-method"><span>Snap.path.toRelative()</span></a> <a href="#Snap.path.toRelative" class="dr-method"><span>Snap.path.toRelative()</span></a>
</li> </li>
<li class="dr-lvl1">
<a href="#Snap.plugin" class="dr-method"><span>Snap.plugin()</span></a>
</li>
<li class="dr-lvl1"> <li class="dr-lvl1">
<a href="#Snap.rad" class="dr-method"><span>Snap.rad()</span></a> <a href="#Snap.rad" class="dr-method"><span>Snap.rad()</span></a>
</li> </li>
@ -7522,6 +7526,76 @@ half the width, from black to white:
</div>
</section>
</article>
<article id="Snap.plugin">
<header>
<h3 class="dr-method">Snap.plugin(f)<a href="#Snap.plugin" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 3522 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#3522">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Snap.plugin-extra"></div>
<div class="dr-method">
<p>Let you write plugins. You pass in a function with four arguments, like this:
</p>
<section class="code"><pre class="javascript code"><code data-language="javascript" class="language-javascript">Snap.plugin(function (Snap, Element, Paper, global) {
Snap.newmethod = function () {};
Element.prototype.newmethod = function () {};
Paper.prototype.newmethod = function () {};
});</code></pre></section>
<p>Inside the function you have access to all main objects (and their
prototypes). This allow you to extend anything you want.
</p>
<div class="topcoat-list__container">
<h3 class="topcoat-list__header">Parameters</h3>
<ol class="topcoat-list">
<li class="topcoat-list__item"><span class="dr-param">f</span>
<span class="dr-type"><em class="dr-type-function">function</em> </span>
<span class="dr-description">your plugin body</span></li>
</ol>
</div>
</div> </div>
</section> </section>
</article> </article>
@ -12434,7 +12508,7 @@ Converts path to a new path where all segments are cubic beziér curves
<article id="Set.clear"> <article id="Set.clear">
<header> <header>
<h3 class="dr-method">Set.clear()<a href="#Set.clear" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 96 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#96">&#x27ad;</a></h3> <h3 class="dr-method">Set.clear()<a href="#Set.clear" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 102 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#102">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Set.clear-extra"></div> <div class="extra" id="Set.clear-extra"></div>
@ -12459,7 +12533,7 @@ Converts path to a new path where all segments are cubic beziér curves
<article id="Set.splice"> <article id="Set.splice">
<header> <header>
<h3 class="dr-method">Set.splice(index, count, [insertion…])<a href="#Set.splice" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 112 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#112">&#x27ad;</a></h3> <h3 class="dr-method">Set.splice(index, count, [insertion…])<a href="#Set.splice" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 118 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#118">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Set.splice-extra"></div> <div class="extra" id="Set.splice-extra"></div>
@ -12525,7 +12599,7 @@ Converts path to a new path where all segments are cubic beziér curves
<article id="Set.exclude"> <article id="Set.exclude">
<header> <header>
<h3 class="dr-method">Set.exclude(element)<a href="#Set.exclude" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 147 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#147">&#x27ad;</a></h3> <h3 class="dr-method">Set.exclude(element)<a href="#Set.exclude" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 153 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#153">&#x27ad;</a></h3>
</header> </header>
<section> <section>
<div class="extra" id="Set.exclude-extra"></div> <div class="extra" id="Set.exclude-extra"></div>

View File

@ -81,6 +81,12 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
} }
return this; return this;
}; };
setproto.remove = function () {
while (this.length) {
this.pop().remove();
}
return this;
};
setproto.attr = function (value) { setproto.attr = function (value) {
for (var i = 0, ii = this.items.length; i < ii; i++) { for (var i = 0, ii = this.items.length; i < ii; i++) {
this.items[i].attr(value); this.items[i].attr(value);

View File

@ -3504,6 +3504,21 @@ Snap.getElementByPoint = function (x, y) {
} }
return wrap(target); return wrap(target);
}; };
/*\
* Snap.plugin
[ method ]
**
* Let you write plugins. You pass in a function with four arguments, like this:
| Snap.plugin(function (Snap, Element, Paper, global) {
| Snap.newmethod = function () {};
| Element.prototype.newmethod = function () {};
| Paper.prototype.newmethod = function () {};
| });
* Inside the function you have access to all main objects (and their
* prototypes). This allow you to extend anything you want.
**
- f (function) your plugin body
\*/
Snap.plugin = function (f) { Snap.plugin = function (f) {
f(Snap, Element, Paper, glob); f(Snap, Element, Paper, glob);
}; };

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<base href="http://snapsvg.io"> <base href="http://snapsvg.io/docs/">
<title>Snap.svg API Reference</title> <title>Snap.svg API Reference</title>
<link rel="shortcut icon" href="/assets/favicon.ico?v=1"> <link rel="shortcut icon" href="/assets/favicon.ico?v=1">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">