@fonixtree/magic-design 2.0.27 → 2.0.28
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.
|
Binary file
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
|
+
|
|
24
|
+
var __extends = void 0 && (void 0).__extends || function () {
|
|
25
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
26
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
27
|
+
__proto__: []
|
|
28
|
+
} instanceof Array && function (d, b) {
|
|
29
|
+
d.__proto__ = b;
|
|
30
|
+
} || function (d, b) {
|
|
31
|
+
for (var p in b) {
|
|
32
|
+
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return _extendStatics(d, b);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return function (d, b) {
|
|
40
|
+
_extendStatics(d, b);
|
|
41
|
+
|
|
42
|
+
function __() {
|
|
43
|
+
this.constructor = d;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
47
|
+
};
|
|
48
|
+
}();
|
|
49
|
+
|
|
50
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
51
|
+
__assign = Object.assign || function (t) {
|
|
52
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
53
|
+
s = arguments[i];
|
|
54
|
+
|
|
55
|
+
for (var p in s) {
|
|
56
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return t;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return __assign.apply(this, arguments);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
67
|
+
var t = {};
|
|
68
|
+
|
|
69
|
+
for (var p in s) {
|
|
70
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
74
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
75
|
+
}
|
|
76
|
+
return t;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// import styles from './index.less';
|
|
80
|
+
var ImageLazy =
|
|
81
|
+
/** @class */
|
|
82
|
+
function (_super) {
|
|
83
|
+
__extends(ImageLazy, _super);
|
|
84
|
+
|
|
85
|
+
function ImageLazy() {
|
|
86
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
87
|
+
|
|
88
|
+
_this.state = {
|
|
89
|
+
show: false
|
|
90
|
+
};
|
|
91
|
+
_this.imageRef = /*#__PURE__*/_react["default"].createRef();
|
|
92
|
+
_this.intersectionObserver = null;
|
|
93
|
+
return _this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
ImageLazy.prototype.componentDidMount = function () {
|
|
97
|
+
var _this = this;
|
|
98
|
+
|
|
99
|
+
var _a;
|
|
100
|
+
|
|
101
|
+
this.intersectionObserver = new IntersectionObserver(function (entries) {
|
|
102
|
+
if (entries[0].isIntersecting) {
|
|
103
|
+
_this.setState({
|
|
104
|
+
show: true
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
root: (_a = this.props) === null || _a === void 0 ? void 0 : _a.rootContainer(),
|
|
109
|
+
// threshold: 0.8,
|
|
110
|
+
rootMargin: '0px 0px 100px 0px'
|
|
111
|
+
});
|
|
112
|
+
this.intersectionObserver.observe(this.imageRef.current);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
ImageLazy.prototype.componentWillUnmount = function () {
|
|
116
|
+
this.intersectionObserver.disconnect(this.imageRef.current);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
ImageLazy.prototype.render = function () {
|
|
120
|
+
var _this = this;
|
|
121
|
+
|
|
122
|
+
var _a = this.props,
|
|
123
|
+
root = _a.root,
|
|
124
|
+
_b = _a.lazy,
|
|
125
|
+
lazy = _b === void 0 ? true : _b,
|
|
126
|
+
src = _a.src,
|
|
127
|
+
onLoadFunc = _a.onLoadFunc,
|
|
128
|
+
style = _a.style,
|
|
129
|
+
className = _a.className,
|
|
130
|
+
rest = __rest(_a, ["root", "lazy", "src", "onLoadFunc", "style", "className"]);
|
|
131
|
+
|
|
132
|
+
var show = this.state.show;
|
|
133
|
+
var isShow = lazy ? show : true;
|
|
134
|
+
return /*#__PURE__*/_react["default"].createElement("img", _extends({
|
|
135
|
+
ref: this.imageRef,
|
|
136
|
+
alt: "",
|
|
137
|
+
className: (0, _classnames["default"])(className),
|
|
138
|
+
onLoad: function onLoad() {
|
|
139
|
+
if (onLoadFunc) {
|
|
140
|
+
onLoadFunc(_this.imageRef.current.clientWidth);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
src: isShow ? src : '',
|
|
144
|
+
style: __assign({
|
|
145
|
+
opacity: ~~isShow
|
|
146
|
+
}, style)
|
|
147
|
+
}, rest));
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
return ImageLazy;
|
|
151
|
+
}(_react.Component);
|
|
152
|
+
|
|
153
|
+
ImageLazy.propTypes = {
|
|
154
|
+
/** 外层容器 */
|
|
155
|
+
rootContainer: _propTypes["default"].func,
|
|
156
|
+
|
|
157
|
+
/** src */
|
|
158
|
+
src: _propTypes["default"].string,
|
|
159
|
+
|
|
160
|
+
/** 懒加载 */
|
|
161
|
+
lazy: _propTypes["default"].bool
|
|
162
|
+
};
|
|
163
|
+
ImageLazy.defaultProps = {
|
|
164
|
+
rootContainer: function rootContainer() {
|
|
165
|
+
return null;
|
|
166
|
+
},
|
|
167
|
+
lazy: true,
|
|
168
|
+
src: ''
|
|
169
|
+
};
|
|
170
|
+
var _default = ImageLazy;
|
|
171
|
+
exports["default"] = _default;
|
|
Binary file
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
|
+
|
|
24
|
+
var __extends = void 0 && (void 0).__extends || function () {
|
|
25
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
26
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
27
|
+
__proto__: []
|
|
28
|
+
} instanceof Array && function (d, b) {
|
|
29
|
+
d.__proto__ = b;
|
|
30
|
+
} || function (d, b) {
|
|
31
|
+
for (var p in b) {
|
|
32
|
+
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return _extendStatics(d, b);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return function (d, b) {
|
|
40
|
+
_extendStatics(d, b);
|
|
41
|
+
|
|
42
|
+
function __() {
|
|
43
|
+
this.constructor = d;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
47
|
+
};
|
|
48
|
+
}();
|
|
49
|
+
|
|
50
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
51
|
+
__assign = Object.assign || function (t) {
|
|
52
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
53
|
+
s = arguments[i];
|
|
54
|
+
|
|
55
|
+
for (var p in s) {
|
|
56
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return t;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return __assign.apply(this, arguments);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
67
|
+
var t = {};
|
|
68
|
+
|
|
69
|
+
for (var p in s) {
|
|
70
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
74
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
75
|
+
}
|
|
76
|
+
return t;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// import styles from './index.less';
|
|
80
|
+
var ImageLazy =
|
|
81
|
+
/** @class */
|
|
82
|
+
function (_super) {
|
|
83
|
+
__extends(ImageLazy, _super);
|
|
84
|
+
|
|
85
|
+
function ImageLazy() {
|
|
86
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
87
|
+
|
|
88
|
+
_this.state = {
|
|
89
|
+
show: false
|
|
90
|
+
};
|
|
91
|
+
_this.imageRef = /*#__PURE__*/_react["default"].createRef();
|
|
92
|
+
_this.intersectionObserver = null;
|
|
93
|
+
return _this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
ImageLazy.prototype.componentDidMount = function () {
|
|
97
|
+
var _this = this;
|
|
98
|
+
|
|
99
|
+
var _a;
|
|
100
|
+
|
|
101
|
+
this.intersectionObserver = new IntersectionObserver(function (entries) {
|
|
102
|
+
if (entries[0].isIntersecting) {
|
|
103
|
+
_this.setState({
|
|
104
|
+
show: true
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
root: (_a = this.props) === null || _a === void 0 ? void 0 : _a.rootContainer(),
|
|
109
|
+
// threshold: 0.8,
|
|
110
|
+
rootMargin: '0px 0px 100px 0px'
|
|
111
|
+
});
|
|
112
|
+
this.intersectionObserver.observe(this.imageRef.current);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
ImageLazy.prototype.componentWillUnmount = function () {
|
|
116
|
+
this.intersectionObserver.disconnect(this.imageRef.current);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
ImageLazy.prototype.render = function () {
|
|
120
|
+
var _this = this;
|
|
121
|
+
|
|
122
|
+
var _a = this.props,
|
|
123
|
+
root = _a.root,
|
|
124
|
+
_b = _a.lazy,
|
|
125
|
+
lazy = _b === void 0 ? true : _b,
|
|
126
|
+
src = _a.src,
|
|
127
|
+
onLoadFunc = _a.onLoadFunc,
|
|
128
|
+
style = _a.style,
|
|
129
|
+
className = _a.className,
|
|
130
|
+
rest = __rest(_a, ["root", "lazy", "src", "onLoadFunc", "style", "className"]);
|
|
131
|
+
|
|
132
|
+
var show = this.state.show;
|
|
133
|
+
var isShow = lazy ? show : true;
|
|
134
|
+
return /*#__PURE__*/_react["default"].createElement("img", _extends({
|
|
135
|
+
ref: this.imageRef,
|
|
136
|
+
alt: "",
|
|
137
|
+
className: (0, _classnames["default"])(className),
|
|
138
|
+
onLoad: function onLoad() {
|
|
139
|
+
if (onLoadFunc) {
|
|
140
|
+
onLoadFunc(_this.imageRef.current.clientWidth);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
src: isShow ? src : '',
|
|
144
|
+
style: __assign({
|
|
145
|
+
opacity: ~~isShow
|
|
146
|
+
}, style)
|
|
147
|
+
}, rest));
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
return ImageLazy;
|
|
151
|
+
}(_react.Component);
|
|
152
|
+
|
|
153
|
+
ImageLazy.propTypes = {
|
|
154
|
+
/** 外层容器 */
|
|
155
|
+
rootContainer: _propTypes["default"].func,
|
|
156
|
+
|
|
157
|
+
/** src */
|
|
158
|
+
src: _propTypes["default"].string,
|
|
159
|
+
|
|
160
|
+
/** 懒加载 */
|
|
161
|
+
lazy: _propTypes["default"].bool
|
|
162
|
+
};
|
|
163
|
+
ImageLazy.defaultProps = {
|
|
164
|
+
rootContainer: function rootContainer() {
|
|
165
|
+
return null;
|
|
166
|
+
},
|
|
167
|
+
lazy: true,
|
|
168
|
+
src: ''
|
|
169
|
+
};
|
|
170
|
+
var _default = ImageLazy;
|
|
171
|
+
exports["default"] = _default;
|