@tuya-sat/micro-dev-component 1.0.2 → 1.0.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.
Files changed (2) hide show
  1. package/dist/index.js +26 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -231,7 +231,7 @@ function styleInject(css, ref) {
231
231
  }
232
232
  }
233
233
 
234
- var css_248z$1 = ".ruleModal-module_cover__dkT6q {\n display: none;\n position: fixed;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n background-color: rgba(0, 0, 0, 0.5);\n z-index: 10000;\n}\n.ruleModal-module_modal__I0Xxp {\n position: fixed;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -68%);\n width: 438px;\n max-height: 400px;\n background-color: #fff;\n background-clip: padding-box;\n border: 0;\n border-radius: 2px;\n box-shadow: 0 3px 6px -4px #0000001f, 0 6px 16px #00000014, 0 9px 28px 8px #0000000d;\n pointer-events: auto;\n}\n.ruleModal-module_modal__I0Xxp .ruleModal-module_header__omUo2 {\n height: 53px;\n padding-left: 20px;\n line-height: 53px;\n border-bottom: 1px solid #f0f0f0;\n}\n.ruleModal-module_modal__I0Xxp .ruleModal-module_footer__yuYWv {\n border-top: 1px solid #f0f0f0;\n padding: 10px 10px 10px 0px;\n text-align: right;\n}\n.ruleModal-module_modal__I0Xxp .ruleModal-module_footer__yuYWv .ruleModal-module_cancel__O3x0P {\n display: inline-block;\n padding: 4px 14px;\n background: #fff;\n color: #333;\n border-radius: 4px;\n margin-right: 10px;\n cursor: pointer;\n border: 1px solid #d9d9d9;\n}\n.ruleModal-module_modal__I0Xxp .ruleModal-module_footer__yuYWv .ruleModal-module_ok__KQc0K {\n display: inline-block;\n padding: 5px 15px;\n background: #1890ff;\n color: #fff;\n border-radius: 4px;\n cursor: pointer;\n}\n";
234
+ var css_248z$1 = ".ruleModal-module_cover__dkT6q {\n display: none;\n position: fixed;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n background-color: rgba(0, 0, 0, 0.5);\n z-index: 10000;\n}\n.ruleModal-module_modal__I0Xxp {\n position: fixed;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -68%);\n width: 438px;\n max-height: 400px;\n background-color: #fff;\n background-clip: padding-box;\n border: 0;\n border-radius: 2px;\n box-shadow: 0 3px 6px -4px #0000001f, 0 6px 16px #00000014, 0 9px 28px 8px #0000000d;\n pointer-events: auto;\n}\n.ruleModal-module_modal__I0Xxp .ruleModal-module_header__omUo2 {\n height: 53px;\n padding-left: 20px;\n line-height: 53px;\n border-bottom: 1px solid #f0f0f0;\n}\n.ruleModal-module_modal__I0Xxp .ruleModal-module_footer__yuYWv {\n border-top: 1px solid #f0f0f0;\n padding: 10px 10px 10px 0px;\n text-align: right;\n}\n.ruleModal-module_modal__I0Xxp .ruleModal-module_footer__yuYWv .ruleModal-module_cancel__O3x0P {\n display: inline-block;\n padding: 4px 14px;\n background: #fff;\n color: #333;\n border-radius: 4px;\n margin-right: 10px;\n cursor: pointer;\n border: 1px solid #d9d9d9;\n}\n.ruleModal-module_modal__I0Xxp .ruleModal-module_footer__yuYWv .ruleModal-module_ok__KQc0K {\n display: inline-block;\n padding: 5px 15px;\n background: #1890ff;\n color: #fff;\n border-radius: 4px;\n cursor: pointer;\n}\n@media (max-width: 488px) {\n .ruleModal-module_modal__I0Xxp {\n width: 80%;\n }\n}\n";
235
235
  var styles$1 = {"cover":"ruleModal-module_cover__dkT6q","modal":"ruleModal-module_modal__I0Xxp","header":"ruleModal-module_header__omUo2","footer":"ruleModal-module_footer__yuYWv","cancel":"ruleModal-module_cancel__O3x0P","ok":"ruleModal-module_ok__KQc0K"};
236
236
  styleInject(css_248z$1);
237
237
 
@@ -320,20 +320,22 @@ class Fixed {
320
320
  }
321
321
  init() {
322
322
  const { right, bottom } = this.proxyData.position;
323
+ const start = () => {
324
+ this.isMove = true;
325
+ this.dowmTime = new Date().valueOf();
326
+ };
327
+ const end = () => {
328
+ const upTime = new Date().valueOf();
329
+ const leftTime = upTime - this.dowmTime;
330
+ if (leftTime > 238) {
331
+ return;
332
+ }
333
+ this.proxyData.visible = !this.proxyData.visible;
334
+ };
323
335
  const fixedDom = (React.createElement("div", { className: styles.container, style: {
324
336
  right: right,
325
337
  bottom: bottom,
326
- }, onMouseDown: () => {
327
- this.isMove = true;
328
- this.dowmTime = new Date().valueOf();
329
- }, onMouseUp: () => {
330
- const upTime = new Date().valueOf();
331
- const leftTime = upTime - this.dowmTime;
332
- if (leftTime > 238) {
333
- return;
334
- }
335
- this.proxyData.visible = !this.proxyData.visible;
336
- } },
338
+ }, onTouchStart: start, onTouchEnd: end, onMouseDown: start, onMouseUp: end },
337
339
  React.createElement("div", { className: styles.mainIcon },
338
340
  React.createElement("svg", { viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", "p-id": "2748", width: "27", height: "27" },
339
341
  React.createElement("path", { d: "M951.4 797.5L563.8 409.9c10.2-11 9.9-28.1-0.8-38.8l-32.4-32.4c12.1-74.4-11.9-149.4-65.6-203.1C420.8 91.4 362 67 299.4 67c-29.3 0-57.9 5.4-85.1 15.9-8.8 3.4-15.3 11.1-17.3 20.3-1.9 9.3 0.9 18.9 7.6 25.6l126.7 126.7-74.4 74.4-128.1-128.1c-6.6-6.6-16-9.5-25.2-7.7-9.2 1.8-16.8 8.1-20.4 16.7-37 88.1-17.2 188.8 50.4 256.3 44.2 44.3 103.1 68.6 165.7 68.6 14.2 0 28.5-1.3 42.4-3.8l30.3 30.3c10.7 10.7 27.8 10.9 38.8 0.8l387.6 387.6c5.5 5.5 12.6 8.2 19.8 8.2 7.2 0 14.3-2.7 19.8-8.2l113.4-113.4c10.9-11 10.9-28.8 0-39.7z m-133.2 93.6L435.9 508.9l37.6-37.6c7.3-7.3 7.3-19.1 0-26.4-7.3-7.3-19.1-7.3-26.4 0l-56.6 56.6-20-20c-7-7-17.2-9.8-26.7-7.3-14.5 3.7-29.5 5.6-44.5 5.6-47.6 0-92.4-18.5-126.1-52.2-40.8-40.8-58.7-97.4-50.4-152.5l114.3 114.3c10.9 11 28.6 11 39.6 0L390.2 276l0.7-0.7c10.8-10.9 10.7-28.6-0.2-39.4L279.2 124.2c6.7-0.7 13.4-1.1 20.2-1.1 47.6 0 92.4 18.5 126.1 52.2 43.8 43.8 61.5 106 47.6 166.5-2.1 9.4 0.7 19.3 7.5 26.1l23.2 23.1c-10.2 11-9.9 28.1 0.8 38.8L892 817.3 868.3 841 565.8 538.5c-7.3-7.3-19.1-7.3-26.4 0-7.3 7.3-7.3 19.1 0 26.4l302.5 302.5-23.7 23.7z", fill: "#4F4F4F", "p-id": "2749" }),
@@ -366,19 +368,26 @@ class Fixed {
366
368
  }
367
369
  addGlobalListener() {
368
370
  const bodyDom = document.querySelector("body");
369
- bodyDom.addEventListener("mouseup", () => {
371
+ const moveup = () => {
370
372
  this.isMove = false;
371
- });
372
- bodyDom.addEventListener("mousemove", (e) => {
373
+ };
374
+ const move = (e) => {
373
375
  if (this.isMove) {
374
- const { clientX, clientY } = e;
376
+ let { clientX, clientY } = e;
377
+ if (clientX === undefined || clientY === undefined) {
378
+ ({ clientX, clientY } = e.changedTouches[0]);
379
+ }
375
380
  const { width, height } = this.windowSize;
376
381
  this.proxyData.position = {
377
382
  right: width - clientX,
378
383
  bottom: height - clientY,
379
384
  };
380
385
  }
381
- });
386
+ };
387
+ bodyDom.addEventListener("mouseup", moveup);
388
+ bodyDom.addEventListener("touchend", moveup);
389
+ bodyDom.addEventListener("mousemove", move);
390
+ bodyDom.addEventListener("touchmove", move);
382
391
  }
383
392
  render() {
384
393
  this.container.appendChild(this.element);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-dev-component",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {