Comparing version
@@ -7,2 +7,7 @@ # Change Log | ||
## [0.15.0][2016-06-18] | ||
## Added | ||
- Custom clip function | ||
## [0.14.0][2016-06-17] | ||
@@ -9,0 +14,0 @@ |
@@ -286,2 +286,4 @@ declare module Konva { | ||
clipY(clipY: number) : Container; | ||
clipFunct(): number; | ||
clipFunct(clipFunc: Function) : Container; | ||
destroyChildren() : void; | ||
@@ -288,0 +290,0 @@ find(selector? : string): Collection; |
{ | ||
"name": "konva", | ||
"version": "0.14.0", | ||
"version": "0.15.0", | ||
"author": "Anton Lavrenov", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -23,3 +23,3 @@  | ||
```html | ||
<script src="https://cdn.rawgit.com/konvajs/konva/0.14.0/konva.min.js"></script> | ||
<script src="https://cdn.rawgit.com/konvajs/konva/0.15.0/konva.min.js"></script> | ||
<div id="container"></div> | ||
@@ -69,6 +69,6 @@ <script> | ||
```html | ||
<script src="https://cdn.rawgit.com/konvajs/konva/0.14.0/konva.min.js"></script> | ||
<script src="https://cdn.rawgit.com/konvajs/konva/0.15.0/konva.min.js"></script> | ||
``` | ||
You can use CDN: [https://cdn.rawgit.com/konvajs/konva/0.14.0/konva.min.js](https://cdn.rawgit.com/konvajs/konva/0.14.0/konva.min.js) | ||
You can use CDN: [https://cdn.rawgit.com/konvajs/konva/0.15.0/konva.min.js](https://cdn.rawgit.com/konvajs/konva/0.15.0/konva.min.js) | ||
@@ -75,0 +75,0 @@ ###2 Load via AMD (requirejs): |
@@ -371,13 +371,17 @@ (function() { | ||
clipHeight = this.getClipHeight(), | ||
hasClip = clipWidth && clipHeight, | ||
clipFunc = this.getClipFunc(), | ||
hasClip = clipWidth && clipHeight || clipFunc, | ||
clipX, clipY; | ||
if (hasClip && layer) { | ||
clipX = this.getClipX(); | ||
clipY = this.getClipY(); | ||
context.save(); | ||
layer._applyTransform(this, context); | ||
context.beginPath(); | ||
context.rect(clipX, clipY, clipWidth, clipHeight); | ||
if (clipFunc) { | ||
clipFunc.call(this, context, this); | ||
} else { | ||
clipX = this.getClipX(); | ||
clipY = this.getClipY(); | ||
context.rect(clipX, clipY, clipWidth, clipHeight); | ||
} | ||
context.clip(); | ||
@@ -543,3 +547,21 @@ context.reset(); | ||
Konva.Factory.addGetterSetter(Konva.Container, 'clipFunc'); | ||
/** | ||
* get/set clip function | ||
* @name clipFunc | ||
* @method | ||
* @memberof Konva.Container.prototype | ||
* @param {Function} function | ||
* @returns {Function} | ||
* @example | ||
* // get clip function | ||
* var clipFunction = container.clipFunc(); | ||
* | ||
* // set clip height | ||
* container.clipFunc(function(ctx) { | ||
* ctx.rect(0, 0, 100, 100); | ||
* }); | ||
*/ | ||
Konva.Collection.mapMethods(Konva.Container); | ||
})(); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1241104
0.15%30084
0.17%