1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 | Object.defineProperty(exports, "__esModule", {
|
5 | value: true
|
6 | });
|
7 | exports.default = getFixScaleEleTransPosition;
|
8 | var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
9 | var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
10 | var _css = require("rc-util/lib/Dom/css");
|
11 | function fixPoint(key, start, width, clientWidth) {
|
12 | var startAddWidth = start + width;
|
13 | var offsetStart = (width - clientWidth) / 2;
|
14 | if (width > clientWidth) {
|
15 | if (start > 0) {
|
16 | return (0, _defineProperty2.default)({}, key, offsetStart);
|
17 | }
|
18 | if (start < 0 && startAddWidth < clientWidth) {
|
19 | return (0, _defineProperty2.default)({}, key, -offsetStart);
|
20 | }
|
21 | } else if (start < 0 || startAddWidth > clientWidth) {
|
22 | return (0, _defineProperty2.default)({}, key, start < 0 ? offsetStart : -offsetStart);
|
23 | }
|
24 | return {};
|
25 | }
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | function getFixScaleEleTransPosition(width, height, left, top) {
|
40 | var _getClientSize = (0, _css.getClientSize)(),
|
41 | clientWidth = _getClientSize.width,
|
42 | clientHeight = _getClientSize.height;
|
43 | var fixPos = null;
|
44 | if (width <= clientWidth && height <= clientHeight) {
|
45 | fixPos = {
|
46 | x: 0,
|
47 | y: 0
|
48 | };
|
49 | } else if (width > clientWidth || height > clientHeight) {
|
50 | fixPos = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, fixPoint('x', left, width, clientWidth)), fixPoint('y', top, height, clientHeight));
|
51 | }
|
52 | return fixPos;
|
53 | } |
\ | No newline at end of file |