konva 10.3.1 → 10.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -43
- package/konva.js +382 -122
- package/konva.min.js +4 -4
- package/lib/Canvas.d.ts +1 -0
- package/lib/Canvas.js +6 -0
- package/lib/Container.js +2 -2
- package/lib/DragAndDrop.d.ts +13 -10
- package/lib/DragAndDrop.js +18 -13
- package/lib/Global.js +1 -1
- package/lib/Layer.d.ts +1 -0
- package/lib/Layer.js +16 -5
- package/lib/Node.d.ts +3 -2
- package/lib/Node.js +31 -14
- package/lib/PointerEvents.js +12 -2
- package/lib/Shape.js +5 -5
- package/lib/Stage.d.ts +2 -0
- package/lib/Stage.js +34 -19
- package/lib/Util.d.ts +1 -1
- package/lib/Util.js +22 -16
- package/lib/_CoreInternals.d.ts +4 -3
- package/lib/_FullInternals.d.ts +4 -3
- package/lib/shapes/Text.d.ts +2 -0
- package/lib/shapes/Text.js +18 -0
- package/lib/shapes/Transformer.d.ts +3 -2
- package/lib/shapes/Transformer.js +47 -34
- package/package.json +13 -6
package/README.md
CHANGED
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
<p align="center"><strong>Build interactive graphics, editors, and diagrams for the web.</strong></p>
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/konva)
|
|
10
|
-
[](
|
|
10
|
+
[](https://badge.fury.io/js/konva)
|
|
11
11
|
[](https://opencollective.com/konva)
|
|
12
12
|
[](https://github.com/konvajs/konva/actions/workflows/test-browser.yml)
|
|
13
13
|
[](https://github.com/konvajs/konva/actions/workflows/test-node.yml)
|
|
14
14
|
[](https://cdnjs.com/libraries/konva)
|
|
15
15
|
|
|
16
|
-
Konva is an
|
|
16
|
+
Konva is an open-source 2D canvas framework for interactive graphics. Its scene graph gives each shape its own events, drag behavior, transforms, animation, cache, and export controls.
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Use Konva for design editors, whiteboards, diagrams, annotations, maps, and other visual tools. Konva is MIT licensed and does not require a license key.
|
|
19
19
|
|
|
20
20
|
This repository began as a GitHub fork of [ericdrowell/KineticJS](https://github.com/ericdrowell/KineticJS).
|
|
21
21
|
|
|
@@ -24,51 +24,43 @@ This repository began as a GitHub fork of [ericdrowell/KineticJS](https://github
|
|
|
24
24
|
- **Try it:** [Canvas Editor](https://konvajs.org/docs/sandbox/Canvas_Editor.html), [Free Drawing](https://konvajs.org/docs/sandbox/Free_Drawing.html), [Image Crop](https://konvajs.org/docs/sandbox/Canvas_Crop_Image.html), [Window Frame Designer](https://konvajs.org/docs/sandbox/Window_Frame_Designer.html), and [more demos](https://konvajs.org/docs/sandbox.html)
|
|
25
25
|
- **Used by:** [Polotno](https://polotno.com/?utm_source=konvajs) (design editor SDK) and many others — see the full showcase on the [home page](https://konvajs.org/)
|
|
26
26
|
- **Help:** [StackOverflow](https://stackoverflow.com/questions/tagged/konvajs), [Discord Chat](https://discord.gg/8FqZwVT)
|
|
27
|
+
- **Support the project:** [Star Konva on GitHub](https://github.com/konvajs/konva)
|
|
28
|
+
|
|
29
|
+
[](https://konvajs.org/docs/select_and_transform/Basic_demo.html)
|
|
30
|
+
|
|
31
|
+
## Framework integrations
|
|
32
|
+
|
|
33
|
+
| Framework | Package | Documentation |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| React | [`react-konva`](https://www.npmjs.com/package/react-konva) | [React guide](https://konvajs.org/docs/react/index.html) |
|
|
36
|
+
| Vue | [`vue-konva`](https://www.npmjs.com/package/vue-konva) | [Vue guide](https://konvajs.org/docs/vue/index.html) |
|
|
37
|
+
| Svelte | [`svelte-konva`](https://www.npmjs.com/package/svelte-konva) | [Svelte guide](https://konvajs.org/docs/svelte/index.html) |
|
|
38
|
+
| Angular | [`ng2-konva`](https://www.npmjs.com/package/ng2-konva) | [Angular guide](https://konvajs.org/docs/angular/index.html) |
|
|
27
39
|
|
|
28
40
|
# Quick Look
|
|
29
41
|
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var box = new Konva.Rect({
|
|
46
|
-
x: 50,
|
|
47
|
-
y: 50,
|
|
48
|
-
width: 100,
|
|
49
|
-
height: 50,
|
|
50
|
-
fill: '#00D2FF',
|
|
51
|
-
stroke: 'black',
|
|
52
|
-
strokeWidth: 4,
|
|
53
|
-
draggable: true,
|
|
54
|
-
});
|
|
55
|
-
layer.add(box);
|
|
56
|
-
|
|
57
|
-
// add cursor styling
|
|
58
|
-
box.on('mouseover', function () {
|
|
59
|
-
document.body.style.cursor = 'pointer';
|
|
60
|
-
});
|
|
61
|
-
box.on('mouseout', function () {
|
|
62
|
-
document.body.style.cursor = 'default';
|
|
63
|
-
});
|
|
64
|
-
</script>
|
|
42
|
+
```javascript
|
|
43
|
+
import Konva from 'konva';
|
|
44
|
+
|
|
45
|
+
const container = document.createElement('div');
|
|
46
|
+
document.body.appendChild(container);
|
|
47
|
+
|
|
48
|
+
const stage = new Konva.Stage({ container, width: 600, height: 400 });
|
|
49
|
+
const layer = new Konva.Layer();
|
|
50
|
+
const box = new Konva.Rect({
|
|
51
|
+
x: 50, y: 50, width: 120, height: 80,
|
|
52
|
+
fill: '#00a8e8', draggable: true,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
layer.add(box);
|
|
56
|
+
stage.add(layer);
|
|
65
57
|
```
|
|
66
58
|
|
|
67
|
-
|
|
59
|
+
> **Building a full design editor?** [Polotno](https://polotno.com/?utm_source=konvajs&utm_medium=readme&utm_content=konva) is a commercial design editor SDK built on Konva by the Konva maintainers. It ships templates, text editing, and export, so you integrate an editor instead of building one: `npm install polotno`.
|
|
68
60
|
|
|
69
|
-
|
|
61
|
+
# Browsers support
|
|
70
62
|
|
|
71
|
-
|
|
63
|
+
Konva works in modern mobile and desktop browsers that support ES2015.
|
|
72
64
|
|
|
73
65
|
# Debugging
|
|
74
66
|
|
|
@@ -81,13 +73,13 @@ Konva supports UMD loading. So you can use all possible variants to load the fra
|
|
|
81
73
|
### Load Konva via classical `<script>` tag from CDN:
|
|
82
74
|
|
|
83
75
|
```html
|
|
84
|
-
<script src="https://unpkg.com/konva@10
|
|
76
|
+
<script src="https://unpkg.com/konva@10/konva.min.js"></script>
|
|
85
77
|
```
|
|
86
78
|
|
|
87
79
|
### Install with npm:
|
|
88
80
|
|
|
89
81
|
```bash
|
|
90
|
-
npm install konva
|
|
82
|
+
npm install konva
|
|
91
83
|
```
|
|
92
84
|
|
|
93
85
|
```javascript
|
|
@@ -156,6 +148,8 @@ const stage = new Konva.Stage({
|
|
|
156
148
|
|
|
157
149
|
# Backers
|
|
158
150
|
|
|
151
|
+
Konva is maintained by the team behind [Polotno](https://polotno.com/?utm_source=konvajs&utm_medium=readme&utm_content=konva-backers), a commercial design editor SDK built on Konva, which sponsors ongoing development.
|
|
152
|
+
|
|
159
153
|

|
|
160
154
|

|
|
161
155
|
|