@micromag/core 0.3.33 → 0.3.36
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 +37 -32
- package/lib/hooks.js +37 -32
- package/package.json +2 -2
package/es/hooks.js
CHANGED
|
@@ -549,7 +549,7 @@ var useLoadedFonts = function useLoadedFonts(fonts) {
|
|
|
549
549
|
|
|
550
550
|
if ((type === 'google' || type === 'custom') && !isFontLoading(name) && !isFontActive(name)) {
|
|
551
551
|
return _objectSpread(_objectSpread({}, newConfig), {}, _defineProperty({}, type, {
|
|
552
|
-
families: [].concat(_toConsumableArray(newConfig !== null ? (newConfig[type] || {}).families || [] : []), [name])
|
|
552
|
+
families: [].concat(_toConsumableArray(newConfig !== null ? (newConfig[type] || {}).families || [] : []), [type === 'google' ? "".concat(name, ":400,700") : name])
|
|
553
553
|
}));
|
|
554
554
|
}
|
|
555
555
|
|
|
@@ -838,19 +838,19 @@ var useMediaApi = function useMediaApi() {
|
|
|
838
838
|
|
|
839
839
|
setPlaying(true);
|
|
840
840
|
}, [initialPlay, setPlaying, onPlay]);
|
|
841
|
-
var onCustomPause = useCallback(function () {
|
|
842
|
-
var
|
|
841
|
+
var onCustomPause = useCallback(function (e) {
|
|
842
|
+
var eventMedia = e.currentTarget;
|
|
843
843
|
setPlaying(false);
|
|
844
844
|
|
|
845
845
|
if (onPause !== null) {
|
|
846
846
|
onPause({
|
|
847
|
-
midway:
|
|
847
|
+
midway: eventMedia.currentTime > 0 && eventMedia.currentTime < eventMedia.duration
|
|
848
848
|
});
|
|
849
849
|
}
|
|
850
850
|
}, [setPlaying, onPause]);
|
|
851
|
-
var onCustomEnded = useCallback(function () {
|
|
852
|
-
var
|
|
853
|
-
|
|
851
|
+
var onCustomEnded = useCallback(function (e) {
|
|
852
|
+
var eventMedia = e.currentTarget;
|
|
853
|
+
eventMedia.currentTime = 0;
|
|
854
854
|
|
|
855
855
|
if (onEnded !== null) {
|
|
856
856
|
onEnded();
|
|
@@ -858,15 +858,15 @@ var useMediaApi = function useMediaApi() {
|
|
|
858
858
|
|
|
859
859
|
setInitialPlay(true);
|
|
860
860
|
}, [setInitialPlay, onEnded]);
|
|
861
|
-
var onCustomTimeUpdate = useCallback(function () {
|
|
862
|
-
var
|
|
863
|
-
setCurrentTime(
|
|
861
|
+
var onCustomTimeUpdate = useCallback(function (e) {
|
|
862
|
+
var eventMedia = e.currentTarget;
|
|
863
|
+
setCurrentTime(eventMedia.currentTime);
|
|
864
864
|
|
|
865
865
|
if (onTimeUpdate !== null) {
|
|
866
|
-
onTimeUpdate(
|
|
866
|
+
onTimeUpdate(eventMedia.currentTime);
|
|
867
867
|
}
|
|
868
868
|
|
|
869
|
-
var progress =
|
|
869
|
+
var progress = eventMedia.currentTime / eventMedia.duration;
|
|
870
870
|
var currentSteps = progressStepsReached.current;
|
|
871
871
|
var stepsToTrack = progressSteps.filter(function (step) {
|
|
872
872
|
return progress > step && typeof currentSteps[step] === 'undefined';
|
|
@@ -879,27 +879,27 @@ var useMediaApi = function useMediaApi() {
|
|
|
879
879
|
currentSteps[step] = true;
|
|
880
880
|
});
|
|
881
881
|
}, [setCurrentTime, onTimeUpdate, onProgressStep]);
|
|
882
|
-
var onCustomDurationChange = useCallback(function () {
|
|
883
|
-
var
|
|
884
|
-
setDuration(
|
|
882
|
+
var onCustomDurationChange = useCallback(function (e) {
|
|
883
|
+
var eventMedia = e.currentTarget;
|
|
884
|
+
setDuration(eventMedia.duration);
|
|
885
885
|
|
|
886
886
|
if (onDurationChanged !== null) {
|
|
887
|
-
onDurationChanged(
|
|
887
|
+
onDurationChanged(eventMedia.duration);
|
|
888
888
|
}
|
|
889
889
|
}, [setDuration, onDurationChanged]);
|
|
890
|
-
var onCustomSeeked = useCallback(function () {
|
|
891
|
-
var
|
|
890
|
+
var onCustomSeeked = useCallback(function (e) {
|
|
891
|
+
var eventMedia = e.currentTarget;
|
|
892
892
|
|
|
893
893
|
if (onSeeked !== null) {
|
|
894
|
-
onSeeked(
|
|
894
|
+
onSeeked(eventMedia.currentTime);
|
|
895
895
|
}
|
|
896
896
|
}, [onSeeked]);
|
|
897
|
-
var onCustomVolumeChange = useCallback(function () {
|
|
898
|
-
var
|
|
899
|
-
setMuted(
|
|
897
|
+
var onCustomVolumeChange = useCallback(function (e) {
|
|
898
|
+
var eventMedia = e.currentTarget;
|
|
899
|
+
setMuted(eventMedia.muted);
|
|
900
900
|
|
|
901
901
|
if (onVolumeChanged !== null) {
|
|
902
|
-
onVolumeChanged(
|
|
902
|
+
onVolumeChanged(eventMedia.muted, eventMedia.volume);
|
|
903
903
|
}
|
|
904
904
|
}, [setMuted, onVolumeChanged]);
|
|
905
905
|
var onCustomLoadStart = useCallback(function () {
|
|
@@ -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
|
@@ -585,7 +585,7 @@ var useLoadedFonts = function useLoadedFonts(fonts) {
|
|
|
585
585
|
|
|
586
586
|
if ((type === 'google' || type === 'custom') && !isFontLoading(name) && !isFontActive(name)) {
|
|
587
587
|
return _objectSpread__default["default"](_objectSpread__default["default"]({}, newConfig), {}, _defineProperty__default["default"]({}, type, {
|
|
588
|
-
families: [].concat(_toConsumableArray__default["default"](newConfig !== null ? (newConfig[type] || {}).families || [] : []), [name])
|
|
588
|
+
families: [].concat(_toConsumableArray__default["default"](newConfig !== null ? (newConfig[type] || {}).families || [] : []), [type === 'google' ? "".concat(name, ":400,700") : name])
|
|
589
589
|
}));
|
|
590
590
|
}
|
|
591
591
|
|
|
@@ -874,19 +874,19 @@ var useMediaApi = function useMediaApi() {
|
|
|
874
874
|
|
|
875
875
|
setPlaying(true);
|
|
876
876
|
}, [initialPlay, setPlaying, onPlay]);
|
|
877
|
-
var onCustomPause = react.useCallback(function () {
|
|
878
|
-
var
|
|
877
|
+
var onCustomPause = react.useCallback(function (e) {
|
|
878
|
+
var eventMedia = e.currentTarget;
|
|
879
879
|
setPlaying(false);
|
|
880
880
|
|
|
881
881
|
if (onPause !== null) {
|
|
882
882
|
onPause({
|
|
883
|
-
midway:
|
|
883
|
+
midway: eventMedia.currentTime > 0 && eventMedia.currentTime < eventMedia.duration
|
|
884
884
|
});
|
|
885
885
|
}
|
|
886
886
|
}, [setPlaying, onPause]);
|
|
887
|
-
var onCustomEnded = react.useCallback(function () {
|
|
888
|
-
var
|
|
889
|
-
|
|
887
|
+
var onCustomEnded = react.useCallback(function (e) {
|
|
888
|
+
var eventMedia = e.currentTarget;
|
|
889
|
+
eventMedia.currentTime = 0;
|
|
890
890
|
|
|
891
891
|
if (onEnded !== null) {
|
|
892
892
|
onEnded();
|
|
@@ -894,15 +894,15 @@ var useMediaApi = function useMediaApi() {
|
|
|
894
894
|
|
|
895
895
|
setInitialPlay(true);
|
|
896
896
|
}, [setInitialPlay, onEnded]);
|
|
897
|
-
var onCustomTimeUpdate = react.useCallback(function () {
|
|
898
|
-
var
|
|
899
|
-
setCurrentTime(
|
|
897
|
+
var onCustomTimeUpdate = react.useCallback(function (e) {
|
|
898
|
+
var eventMedia = e.currentTarget;
|
|
899
|
+
setCurrentTime(eventMedia.currentTime);
|
|
900
900
|
|
|
901
901
|
if (onTimeUpdate !== null) {
|
|
902
|
-
onTimeUpdate(
|
|
902
|
+
onTimeUpdate(eventMedia.currentTime);
|
|
903
903
|
}
|
|
904
904
|
|
|
905
|
-
var progress =
|
|
905
|
+
var progress = eventMedia.currentTime / eventMedia.duration;
|
|
906
906
|
var currentSteps = progressStepsReached.current;
|
|
907
907
|
var stepsToTrack = progressSteps.filter(function (step) {
|
|
908
908
|
return progress > step && typeof currentSteps[step] === 'undefined';
|
|
@@ -915,27 +915,27 @@ var useMediaApi = function useMediaApi() {
|
|
|
915
915
|
currentSteps[step] = true;
|
|
916
916
|
});
|
|
917
917
|
}, [setCurrentTime, onTimeUpdate, onProgressStep]);
|
|
918
|
-
var onCustomDurationChange = react.useCallback(function () {
|
|
919
|
-
var
|
|
920
|
-
setDuration(
|
|
918
|
+
var onCustomDurationChange = react.useCallback(function (e) {
|
|
919
|
+
var eventMedia = e.currentTarget;
|
|
920
|
+
setDuration(eventMedia.duration);
|
|
921
921
|
|
|
922
922
|
if (onDurationChanged !== null) {
|
|
923
|
-
onDurationChanged(
|
|
923
|
+
onDurationChanged(eventMedia.duration);
|
|
924
924
|
}
|
|
925
925
|
}, [setDuration, onDurationChanged]);
|
|
926
|
-
var onCustomSeeked = react.useCallback(function () {
|
|
927
|
-
var
|
|
926
|
+
var onCustomSeeked = react.useCallback(function (e) {
|
|
927
|
+
var eventMedia = e.currentTarget;
|
|
928
928
|
|
|
929
929
|
if (onSeeked !== null) {
|
|
930
|
-
onSeeked(
|
|
930
|
+
onSeeked(eventMedia.currentTime);
|
|
931
931
|
}
|
|
932
932
|
}, [onSeeked]);
|
|
933
|
-
var onCustomVolumeChange = react.useCallback(function () {
|
|
934
|
-
var
|
|
935
|
-
setMuted(
|
|
933
|
+
var onCustomVolumeChange = react.useCallback(function (e) {
|
|
934
|
+
var eventMedia = e.currentTarget;
|
|
935
|
+
setMuted(eventMedia.muted);
|
|
936
936
|
|
|
937
937
|
if (onVolumeChanged !== null) {
|
|
938
|
-
onVolumeChanged(
|
|
938
|
+
onVolumeChanged(eventMedia.muted, eventMedia.volume);
|
|
939
939
|
}
|
|
940
940
|
}, [setMuted, onVolumeChanged]);
|
|
941
941
|
var onCustomLoadStart = react.useCallback(function () {
|
|
@@ -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.36",
|
|
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": "3a430d587a82acb0bf94fe7f842c7f96707a98f4"
|
|
136
136
|
}
|