y-mxgraph 0.5.3 → 0.5.6
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/helper/throttle.d.ts +2 -0
- package/helper/throttle.d.ts.map +1 -0
- package/package.json +1 -2
- package/y-mxgraph.cjs.js +29 -2
- package/y-mxgraph.cjs.js.map +1 -1
- package/y-mxgraph.es.js +28 -1
- package/y-mxgraph.es.js.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/helper/throttle.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,EAAE,EAAE,CAAC,EACL,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAgCvD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "y-mxgraph",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "Yjs binding for draw.io (mxGraph) documents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yjs",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"colord": "^2.9.3",
|
|
40
|
-
"lodash-es": "^4.17.21",
|
|
41
40
|
"xml-js": "^1.6.11"
|
|
42
41
|
},
|
|
43
42
|
"peerDependencies": {
|
package/y-mxgraph.cjs.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const xmlJs = require("xml-js");
|
|
4
4
|
const Y = require("yjs");
|
|
5
|
-
const lodashEs = require("lodash-es");
|
|
6
5
|
const colord = require("colord");
|
|
7
6
|
function _interopNamespaceDefault(e) {
|
|
8
7
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -1064,6 +1063,34 @@ function hslToHex(h, s, l) {
|
|
|
1064
1063
|
const b = Math.round((b1 + m) * 255);
|
|
1065
1064
|
return "#" + [r, g, b].map((v) => v.toString(16).padStart(2, "0")).join("");
|
|
1066
1065
|
}
|
|
1066
|
+
function throttle(fn, wait) {
|
|
1067
|
+
let lastTime = 0;
|
|
1068
|
+
let timeoutId = null;
|
|
1069
|
+
let lastArgs = null;
|
|
1070
|
+
return (...args) => {
|
|
1071
|
+
const now = Date.now();
|
|
1072
|
+
const remaining = wait - (now - lastTime);
|
|
1073
|
+
lastArgs = args;
|
|
1074
|
+
if (remaining <= 0) {
|
|
1075
|
+
if (timeoutId) {
|
|
1076
|
+
clearTimeout(timeoutId);
|
|
1077
|
+
timeoutId = null;
|
|
1078
|
+
}
|
|
1079
|
+
lastTime = now;
|
|
1080
|
+
return fn(...args);
|
|
1081
|
+
}
|
|
1082
|
+
if (!timeoutId) {
|
|
1083
|
+
timeoutId = setTimeout(() => {
|
|
1084
|
+
lastTime = Date.now();
|
|
1085
|
+
timeoutId = null;
|
|
1086
|
+
if (lastArgs) {
|
|
1087
|
+
fn(...lastArgs);
|
|
1088
|
+
}
|
|
1089
|
+
}, remaining);
|
|
1090
|
+
}
|
|
1091
|
+
return void 0;
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1067
1094
|
function createCursorImage(color) {
|
|
1068
1095
|
const w = 8;
|
|
1069
1096
|
const h = 12;
|
|
@@ -1116,7 +1143,7 @@ function bindCursor(file, options) {
|
|
|
1116
1143
|
},
|
|
1117
1144
|
mouseUp: function() {
|
|
1118
1145
|
},
|
|
1119
|
-
mouseMove:
|
|
1146
|
+
mouseMove: throttle(function(_sender, event) {
|
|
1120
1147
|
var _a;
|
|
1121
1148
|
const containerRect = graph.container.getBoundingClientRect();
|
|
1122
1149
|
const { translate, scale } = graph.view;
|