|
5 | 5 | <title>📦 Vanilla JavaScript Example - Mini Canvas Editor</title> |
6 | 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> |
7 | 7 | <link rel="icon" href="./assets/favicon.ico" /> |
| 8 | + <link href="./assets/common.css" rel="stylesheet" /> |
8 | 9 | <style> |
9 | | - html, |
10 | 10 | body { |
11 | | - margin: 0; |
12 | | - padding: 0; |
13 | | - font: 14px/1.5em Arial, Verdana, sans-serif; |
14 | | - min-height: 100%; |
15 | 11 | background: url('./assets/background-pattern.svg'); |
16 | 12 | } |
17 | 13 | #placeholder { |
|
25 | 21 | </style> |
26 | 22 | </head> |
27 | 23 | <body> |
| 24 | + <header class="header bb"> |
| 25 | + <div class="header-title"> |
| 26 | + <h1>📦 Vanilla JavaScript Example</h1> |
| 27 | + </div> |
| 28 | + <div class="header-links"> |
| 29 | + <a href="https://github.com/img-js/mini-canvas-editor" target="_blank">Mini Canvas Editor</a> |
| 30 | + </div> |
| 31 | + </header> |
| 32 | + |
28 | 33 | <div id="placeholder"></div> |
29 | 34 |
|
30 | 35 | <p> |
31 | 36 | <button id="saveButton">Save bitmap</button> |
32 | 37 | </p> |
33 | | - <p> |
34 | | - <a href="https://github.com/img-js/mini-canvas-editor">Mini Canvas Editor</a> |
35 | | - </p> |
| 38 | + <p>This example uses vanilla JavaScript!</p> |
36 | 39 |
|
37 | | - <link href="https://cdn.jsdelivr.net/npm/mini-canvas-editor@0.0.10/css/editor.css" rel="stylesheet"> |
38 | | - <script src="https://cdn.jsdelivr.net/npm/mini-canvas-editor@0.0.10/dist/index.umd.js"></script> |
| 40 | + <link href="https://cdn.jsdelivr.net/npm/mini-canvas-editor@0.1.0/css/editor.css" rel="stylesheet" /> |
| 41 | + <script src="https://cdn.jsdelivr.net/npm/mini-canvas-editor@0.1.0/dist/index.umd.js"></script> |
39 | 42 | <script> |
40 | 43 | const placeholder = document.getElementById('placeholder'); |
41 | 44 | const saveButton = document.getElementById('saveButton'); |
42 | 45 | const editor = miniCanvasEditor.Editor.createBlank(placeholder, 200, 300, {}); |
43 | 46 |
|
44 | | - saveButton.addEventListener('click', () => { |
45 | | - const a = document.createElement('a'); |
46 | | - a.download = 'filename.png'; |
47 | | - a.href = editor.render().toDataURL('image/png'); |
48 | | - a.click(); |
49 | | - }, false); |
| 47 | + saveButton.addEventListener( |
| 48 | + 'click', |
| 49 | + () => { |
| 50 | + const a = document.createElement('a'); |
| 51 | + a.download = 'filename.png'; |
| 52 | + a.href = editor.render().toDataURL('image/png'); |
| 53 | + a.click(); |
| 54 | + }, |
| 55 | + false |
| 56 | + ); |
50 | 57 | </script> |
51 | 58 | </body> |
52 | 59 | </html> |
0 commit comments