@micromag/core 0.3.34 → 0.3.35
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/es/hooks.js +14 -9
- package/lib/hooks.js +14 -9
- package/package.json +2 -2
package/es/hooks.js
CHANGED
|
@@ -1125,17 +1125,20 @@ var useScreenSizeFromElement = function useScreenSizeFromElement() {
|
|
|
1125
1125
|
var fullHeight = height !== null ? height : calculatedHeight;
|
|
1126
1126
|
|
|
1127
1127
|
var _ref6 = opts || {},
|
|
1128
|
+
_ref6$screenWidth = _ref6.screenWidth,
|
|
1129
|
+
screenWidth = _ref6$screenWidth === void 0 ? 320 : _ref6$screenWidth,
|
|
1130
|
+
_ref6$screenHeight = _ref6.screenHeight,
|
|
1131
|
+
screenHeight = _ref6$screenHeight === void 0 ? 480 : _ref6$screenHeight,
|
|
1128
1132
|
_ref6$withoutMaxSize = _ref6.withoutMaxSize,
|
|
1129
1133
|
withoutMaxSize = _ref6$withoutMaxSize === void 0 ? false : _ref6$withoutMaxSize,
|
|
1130
1134
|
_ref6$landscapeMinHei = _ref6.landscapeMinHeight,
|
|
1131
1135
|
landscapeMinHeight = _ref6$landscapeMinHei === void 0 ? 600 : _ref6$landscapeMinHei,
|
|
1132
|
-
_ref6$landscapeHeight = _ref6.landscapeHeightRatio,
|
|
1133
|
-
landscapeHeightRatio = _ref6$landscapeHeight === void 0 ? 2 / 3 : _ref6$landscapeHeight,
|
|
1134
|
-
_ref6$screenRatio = _ref6.screenRatio,
|
|
1135
|
-
screenRatio = _ref6$screenRatio === void 0 ? 320 / 480 : _ref6$screenRatio,
|
|
1136
1136
|
_ref6$landscapeMinRat = _ref6.landscapeMinRatio,
|
|
1137
|
-
landscapeMinRatio = _ref6$landscapeMinRat === void 0 ? 2 / 3 : _ref6$landscapeMinRat
|
|
1137
|
+
landscapeMinRatio = _ref6$landscapeMinRat === void 0 ? 2 / 3 : _ref6$landscapeMinRat,
|
|
1138
|
+
_ref6$withoutScale = _ref6.withoutScale,
|
|
1139
|
+
withoutScale = _ref6$withoutScale === void 0 ? false : _ref6$withoutScale;
|
|
1138
1140
|
|
|
1141
|
+
var screenRatio = screenWidth / screenHeight;
|
|
1139
1142
|
var elementRatio = fullWidth / fullHeight;
|
|
1140
1143
|
var landscape = fullHeight > 0 && elementRatio > (landscapeMinRatio || screenRatio);
|
|
1141
1144
|
var landscapeWithMaxSize = landscape && !withoutMaxSize;
|
|
@@ -1147,7 +1150,7 @@ var useScreenSizeFromElement = function useScreenSizeFromElement() {
|
|
|
1147
1150
|
if (fullHeight < landscapeMinHeight) {
|
|
1148
1151
|
menuOverScreen = true;
|
|
1149
1152
|
} else {
|
|
1150
|
-
finalHeight =
|
|
1153
|
+
finalHeight = fullHeight - 100;
|
|
1151
1154
|
}
|
|
1152
1155
|
|
|
1153
1156
|
finalWidth = Math.round(finalHeight * screenRatio);
|
|
@@ -1161,15 +1164,17 @@ var useScreenSizeFromElement = function useScreenSizeFromElement() {
|
|
|
1161
1164
|
finalHeight -= 1;
|
|
1162
1165
|
}
|
|
1163
1166
|
|
|
1167
|
+
var scale = finalWidth / screenWidth;
|
|
1164
1168
|
var screenSize = useScreenSize(_objectSpread({
|
|
1165
|
-
width: finalWidth,
|
|
1166
|
-
height: finalHeight,
|
|
1169
|
+
width: withoutScale ? finalWidth : screenWidth,
|
|
1170
|
+
height: withoutScale ? finalHeight : finalHeight / scale,
|
|
1167
1171
|
landscape: landscape,
|
|
1168
1172
|
menuOverScreen: menuOverScreen
|
|
1169
1173
|
}, opts));
|
|
1170
1174
|
return {
|
|
1171
1175
|
ref: ref,
|
|
1172
|
-
screenSize: screenSize
|
|
1176
|
+
screenSize: screenSize,
|
|
1177
|
+
scale: !withoutScale ? scale : null
|
|
1173
1178
|
};
|
|
1174
1179
|
};
|
|
1175
1180
|
|
package/lib/hooks.js
CHANGED
|
@@ -1161,17 +1161,20 @@ var useScreenSizeFromElement = function useScreenSizeFromElement() {
|
|
|
1161
1161
|
var fullHeight = height !== null ? height : calculatedHeight;
|
|
1162
1162
|
|
|
1163
1163
|
var _ref6 = opts || {},
|
|
1164
|
+
_ref6$screenWidth = _ref6.screenWidth,
|
|
1165
|
+
screenWidth = _ref6$screenWidth === void 0 ? 320 : _ref6$screenWidth,
|
|
1166
|
+
_ref6$screenHeight = _ref6.screenHeight,
|
|
1167
|
+
screenHeight = _ref6$screenHeight === void 0 ? 480 : _ref6$screenHeight,
|
|
1164
1168
|
_ref6$withoutMaxSize = _ref6.withoutMaxSize,
|
|
1165
1169
|
withoutMaxSize = _ref6$withoutMaxSize === void 0 ? false : _ref6$withoutMaxSize,
|
|
1166
1170
|
_ref6$landscapeMinHei = _ref6.landscapeMinHeight,
|
|
1167
1171
|
landscapeMinHeight = _ref6$landscapeMinHei === void 0 ? 600 : _ref6$landscapeMinHei,
|
|
1168
|
-
_ref6$landscapeHeight = _ref6.landscapeHeightRatio,
|
|
1169
|
-
landscapeHeightRatio = _ref6$landscapeHeight === void 0 ? 2 / 3 : _ref6$landscapeHeight,
|
|
1170
|
-
_ref6$screenRatio = _ref6.screenRatio,
|
|
1171
|
-
screenRatio = _ref6$screenRatio === void 0 ? 320 / 480 : _ref6$screenRatio,
|
|
1172
1172
|
_ref6$landscapeMinRat = _ref6.landscapeMinRatio,
|
|
1173
|
-
landscapeMinRatio = _ref6$landscapeMinRat === void 0 ? 2 / 3 : _ref6$landscapeMinRat
|
|
1173
|
+
landscapeMinRatio = _ref6$landscapeMinRat === void 0 ? 2 / 3 : _ref6$landscapeMinRat,
|
|
1174
|
+
_ref6$withoutScale = _ref6.withoutScale,
|
|
1175
|
+
withoutScale = _ref6$withoutScale === void 0 ? false : _ref6$withoutScale;
|
|
1174
1176
|
|
|
1177
|
+
var screenRatio = screenWidth / screenHeight;
|
|
1175
1178
|
var elementRatio = fullWidth / fullHeight;
|
|
1176
1179
|
var landscape = fullHeight > 0 && elementRatio > (landscapeMinRatio || screenRatio);
|
|
1177
1180
|
var landscapeWithMaxSize = landscape && !withoutMaxSize;
|
|
@@ -1183,7 +1186,7 @@ var useScreenSizeFromElement = function useScreenSizeFromElement() {
|
|
|
1183
1186
|
if (fullHeight < landscapeMinHeight) {
|
|
1184
1187
|
menuOverScreen = true;
|
|
1185
1188
|
} else {
|
|
1186
|
-
finalHeight =
|
|
1189
|
+
finalHeight = fullHeight - 100;
|
|
1187
1190
|
}
|
|
1188
1191
|
|
|
1189
1192
|
finalWidth = Math.round(finalHeight * screenRatio);
|
|
@@ -1197,15 +1200,17 @@ var useScreenSizeFromElement = function useScreenSizeFromElement() {
|
|
|
1197
1200
|
finalHeight -= 1;
|
|
1198
1201
|
}
|
|
1199
1202
|
|
|
1203
|
+
var scale = finalWidth / screenWidth;
|
|
1200
1204
|
var screenSize = useScreenSize(_objectSpread__default["default"]({
|
|
1201
|
-
width: finalWidth,
|
|
1202
|
-
height: finalHeight,
|
|
1205
|
+
width: withoutScale ? finalWidth : screenWidth,
|
|
1206
|
+
height: withoutScale ? finalHeight : finalHeight / scale,
|
|
1203
1207
|
landscape: landscape,
|
|
1204
1208
|
menuOverScreen: menuOverScreen
|
|
1205
1209
|
}, opts));
|
|
1206
1210
|
return {
|
|
1207
1211
|
ref: ref,
|
|
1208
|
-
screenSize: screenSize
|
|
1212
|
+
screenSize: screenSize,
|
|
1213
|
+
scale: !withoutScale ? scale : null
|
|
1209
1214
|
};
|
|
1210
1215
|
};
|
|
1211
1216
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.35",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -132,5 +132,5 @@
|
|
|
132
132
|
"publishConfig": {
|
|
133
133
|
"access": "public"
|
|
134
134
|
},
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "4fd919d4dadf04fd8265b6bae91a9c5b77981db0"
|
|
136
136
|
}
|