@kep-platform/basic-component 0.0.42 → 0.0.43

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.
@@ -30,6 +30,13 @@ export declare class ViewPortStore {
30
30
  move(transform: Transform): void;
31
31
  endMove(): void;
32
32
  get contentStyle(): CSSProperties;
33
+ get viewPortRect(): {
34
+ left: number;
35
+ top: number;
36
+ width: number;
37
+ height: number;
38
+ scale: number;
39
+ };
33
40
  get containerStyle(): CSSProperties;
34
41
  get info(): string;
35
42
  }
@@ -136,6 +136,18 @@ export var ViewPortStore = /*#__PURE__*/function () {
136
136
  cursor: this.isMoving ? 'grab' : 'default'
137
137
  };
138
138
  }
139
+ /* 计算得到实际显示区域的偏移量 */
140
+ }, {
141
+ key: "viewPortRect",
142
+ get: function get() {
143
+ return {
144
+ left: -this.transform.left + this.offsetLeft,
145
+ top: -this.transform.top + this.offsetTop,
146
+ width: this.width,
147
+ height: this.height,
148
+ scale: this.scale
149
+ };
150
+ }
139
151
  }, {
140
152
  key: "containerStyle",
141
153
  get: function get() {
@@ -143,16 +143,17 @@ export var ViewPortWindow = observer(function ViewPortWindow(props) {
143
143
  rest = _objectWithoutProperties(props, _excluded);
144
144
  useEffect(function () {
145
145
  runInAction(function () {
146
- window.fullscreenPos.left = -viewPortStore.transform.left + viewPortStore.offsetLeft;
147
- window.fullscreenPos.top = -viewPortStore.transform.top + viewPortStore.offsetTop;
148
- window.fullscreenPos.width = viewPortStore.width;
149
- window.fullscreenPos.height = viewPortStore.height;
150
- window.scale = viewPortStore.scale;
146
+ var rect = viewPortStore.viewPortRect;
147
+ window.fullscreenPos = rect;
148
+ window.scale = rect.scale;
151
149
  });
152
- }, [viewPortStore.transform.left, viewPortStore.transform.top, viewPortStore.scale, viewPortStore.ratio, viewPortStore.width, viewPortStore.height]);
150
+ }, [viewPortStore.viewPortRect]);
153
151
  useEffect(function () {
154
- window.left = (viewPortStore.width * viewPortStore.ratio - viewPortStore.width) / 2;
155
- window.top = (viewPortStore.width * viewPortStore.ratio - viewPortStore.width) / 2;
152
+ var rect = viewPortStore.viewPortRect;
153
+ /* rect.width/rect.scale就是实际上显示区域内容区的宽度 */
154
+ window.left = rect.left + Math.max(0, rect.width / rect.scale - window.width) / 2;
155
+ window.top = rect.top + Math.max(0, rect.height / rect.scale - window.height) / 2;
156
+ window.zIndex = ++viewPortStore.maxZIndex;
156
157
  }, []);
157
158
  return /*#__PURE__*/React.createElement(Window, _extends({
158
159
  window: window
@@ -9,7 +9,7 @@ import { makeAutoObservable, runInAction } from 'mobx';
9
9
  import { observer, useLocalObservable } from 'mobx-react-lite';
10
10
  import React, { useEffect } from 'react';
11
11
  import styled from 'styled-components';
12
- import { GlobalStyles } from '..';
12
+ import { Button, GlobalStyles } from '..';
13
13
  import ViewPort from "./ViewPort";
14
14
  import { ViewPortStore } from "./ViewPortStore";
15
15
  import { ViewPortWindowStore } from "./ViewPortWindow";
@@ -20,6 +20,11 @@ var WindowManager = /*#__PURE__*/function () {
20
20
  makeAutoObservable(this);
21
21
  }
22
22
  _createClass(WindowManager, [{
23
+ key: "createWindow",
24
+ value: function createWindow() {
25
+ this.windows.push(new ViewPortWindowStore('jss' + Math.random(), this.closeWindowHanlder.bind(this)));
26
+ }
27
+ }, {
23
28
  key: "closeWindowHanlder",
24
29
  value: function closeWindowHanlder(id) {
25
30
  this.windows = this.windows.filter(function (window) {
@@ -60,7 +65,11 @@ export default observer(function Test() {
60
65
  }, []);
61
66
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GlobalStyles, {
62
67
  $css: []
63
- }), /*#__PURE__*/React.createElement(StyledViewPort, {
68
+ }), /*#__PURE__*/React.createElement(Button, {
69
+ onClick: function onClick() {
70
+ windowManager.createWindow();
71
+ }
72
+ }, "\u65B0\u589E"), /*#__PURE__*/React.createElement(StyledViewPort, {
64
73
  viewPortStore: viewPortStore
65
74
  }, windowManager.windows.map(function (windowStore) {
66
75
  return /*#__PURE__*/React.createElement(ViewPort.Window, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kep-platform/basic-component",
3
- "version": "0.0.42",
3
+ "version": "0.0.43",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@ant-design/icons": "^5.3.7",
50
- "@kep-platform/hooks": "^0.0.42",
50
+ "@kep-platform/hooks": "^0.0.43",
51
51
  "color": "^4.2.3",
52
52
  "rc-pagination": "^4.1.0",
53
53
  "styled-components": "^6.1.11"
@@ -87,5 +87,5 @@
87
87
  "authors": [
88
88
  "lee-step-jss 1599925910@qq.com"
89
89
  ],
90
- "gitHead": "345a676c9d5748fb2a93d5423e7517cbda956876"
90
+ "gitHead": "a23a9722867510175523db19c5a352c3fa9f5f21"
91
91
  }