graphico 1.1.0 → 1.1.2
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/dist/canvas.js +11 -4
- package/package.json +1 -1
- package/types/types.d.ts +4 -0
package/dist/canvas.js
CHANGED
|
@@ -70,6 +70,7 @@ var Canvas = /** @class */ (function () {
|
|
|
70
70
|
main.style.height = "".concat(this.config.height * this.config.scale, "px");
|
|
71
71
|
main.style.border = "".concat(this.config.scale, "px solid ").concat(this.config.border);
|
|
72
72
|
main.style.cursor = this.config.showMouse ? 'default' : 'none';
|
|
73
|
+
main.style.boxSizing = 'content-box';
|
|
73
74
|
this.config.parent.appendChild(main);
|
|
74
75
|
// Create main canvas graphics object
|
|
75
76
|
var graphics = main.getContext('2d');
|
|
@@ -164,10 +165,15 @@ var Canvas = /** @class */ (function () {
|
|
|
164
165
|
_this.animation = requestAnimationFrame(function (time) { return _this.startAnimate(time); });
|
|
165
166
|
});
|
|
166
167
|
main.addEventListener('focusout', function (e) {
|
|
167
|
-
_this.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
if (_this.config.keepFocused) {
|
|
169
|
+
main.focus();
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
_this.focused = false;
|
|
173
|
+
main.style.borderColor = _this.config.borderBlur;
|
|
174
|
+
_this.log(e.type, _this.focused);
|
|
175
|
+
cancelAnimationFrame(_this.animation);
|
|
176
|
+
}
|
|
171
177
|
});
|
|
172
178
|
window.addEventListener('blur', function (e) {
|
|
173
179
|
_this.log(e.type);
|
|
@@ -441,6 +447,7 @@ var Canvas = /** @class */ (function () {
|
|
|
441
447
|
border: 'transparent',
|
|
442
448
|
borderBlur: 'transparent',
|
|
443
449
|
showMouse: true,
|
|
450
|
+
keepFocused: false,
|
|
444
451
|
numLayers: 1,
|
|
445
452
|
numTracks: 1,
|
|
446
453
|
keydown: function () { return; },
|
package/package.json
CHANGED
package/types/types.d.ts
CHANGED
|
@@ -38,6 +38,10 @@ export interface Options {
|
|
|
38
38
|
* Optionally show or hide the mouse when hovering over the canvas
|
|
39
39
|
*/
|
|
40
40
|
readonly showMouse: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Refocus the canvas when it loses focus
|
|
43
|
+
*/
|
|
44
|
+
readonly keepFocused: boolean;
|
|
41
45
|
/**
|
|
42
46
|
* The number of layers in this canvas
|
|
43
47
|
*/
|