diff options
author | wout <wout@impinc.co.uk> | 2014-02-03 15:14:47 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-02-03 15:14:47 +0100 |
commit | e2304534e0cfb6f6f4ab8c37ea5275ae26cd455a (patch) | |
tree | 2386e9f361d9c5fa1308387aeeaf33f00241b3c5 /src/clip.js | |
parent | 7a29817ffd764cf7ab6906250b57f234801c94e0 (diff) | |
download | svg.js-e2304534e0cfb6f6f4ab8c37ea5275ae26cd455a.tar.gz svg.js-e2304534e0cfb6f6f4ab8c37ea5275ae26cd455a.zip |
Implemented SVG.invent function and bumped to v1.0rc3
Diffstat (limited to 'src/clip.js')
-rwxr-xr-x | src/clip.js | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/src/clip.js b/src/clip.js index 54f9d37..e8a5e35 100755 --- a/src/clip.js +++ b/src/clip.js @@ -1,27 +1,38 @@ -SVG.Clip = function() { - this.constructor.call(this, SVG.create('clipPath')) +SVG.Clip = SVG.invent({ + // Initialize node + create: function() { + this.constructor.call(this, SVG.create('clipPath')) - /* keep references to clipped elements */ - this.targets = [] -} - -// Inherit from SVG.Container -SVG.Clip.prototype = new SVG.Container - -// -SVG.extend(SVG.Clip, { - // Unclip all clipped elements and remove itself - remove: function() { - /* unclip all targets */ - for (var i = this.targets.length - 1; i >= 0; i--) - if (this.targets[i]) - this.targets[i].unclip() - delete this.targets + /* keep references to clipped elements */ + this.targets = [] + } - /* remove clipPath from parent */ - this.parent.removeElement(this) - - return this + // Inherit from +, inherit: SVG.Container + + // Add class methods +, extend: { + // Unclip all clipped elements and remove itself + remove: function() { + /* unclip all targets */ + for (var i = this.targets.length - 1; i >= 0; i--) + if (this.targets[i]) + this.targets[i].unclip() + delete this.targets + + /* remove clipPath from parent */ + this.parent.removeElement(this) + + return this + } + } + + // Add parent method +, construct: { + // Create clipping element + clip: function() { + return this.defs().put(new SVG.Clip) + } } }) @@ -44,13 +55,4 @@ SVG.extend(SVG.Element, { return this.attr('clip-path', null) } -}) - -// -SVG.extend(SVG.Container, { - // Create clipping element - clip: function() { - return this.defs().put(new SVG.Clip) - } - })
\ No newline at end of file |