@micromag/core 0.3.796 → 0.3.797
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/contexts.js +34 -8
- package/lib/contexts.js +34 -8
- package/package.json +2 -2
package/es/contexts.js
CHANGED
|
@@ -1145,19 +1145,45 @@ var usePlaybackMediaRef = function usePlaybackMediaRef() {
|
|
|
1145
1145
|
media = _usePlaybackContext.media;
|
|
1146
1146
|
var mediaRef = useRef(null);
|
|
1147
1147
|
useEffect(function () {
|
|
1148
|
-
|
|
1149
|
-
if (
|
|
1148
|
+
return function () {
|
|
1149
|
+
if (active) {
|
|
1150
1150
|
setMedia(null);
|
|
1151
1151
|
setIsBackground(false);
|
|
1152
1152
|
}
|
|
1153
|
-
|
|
1153
|
+
};
|
|
1154
|
+
}, [active]);
|
|
1155
|
+
useEffect(function () {
|
|
1156
|
+
if (!active || mediaRef.current === null || media !== null) {
|
|
1157
|
+
return;
|
|
1154
1158
|
}
|
|
1155
1159
|
setIsBackground(background);
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1160
|
+
setMedia(mediaRef.current);
|
|
1161
|
+
}, [active, background, media]);
|
|
1162
|
+
|
|
1163
|
+
// const shouldSetMedia = active && media === null && mediaRef.current !== null;
|
|
1164
|
+
// useEffect(
|
|
1165
|
+
// () => () => {
|
|
1166
|
+
// if (active) {
|
|
1167
|
+
// console.log('DESTROY unset media');
|
|
1168
|
+
// setMedia(null);
|
|
1169
|
+
// setIsBackground(false);
|
|
1170
|
+
// }
|
|
1171
|
+
// },
|
|
1172
|
+
// [active],
|
|
1173
|
+
// );
|
|
1174
|
+
|
|
1175
|
+
// useEffect(() => {
|
|
1176
|
+
// if (active && mediaRef.current !== null && media === null) {
|
|
1177
|
+
// console.log('SET media');
|
|
1178
|
+
// setIsBackground(background);
|
|
1179
|
+
// setMedia(mediaRef.current);
|
|
1180
|
+
// } else if (!active && mediaRef.current === media && media !== null) {
|
|
1181
|
+
// console.log('Unset media');
|
|
1182
|
+
// setMedia(null);
|
|
1183
|
+
// setIsBackground(false);
|
|
1184
|
+
// }
|
|
1185
|
+
// }, [active, background, media]);
|
|
1186
|
+
|
|
1161
1187
|
return {
|
|
1162
1188
|
ref: mediaRef,
|
|
1163
1189
|
isCurrent: mediaRef.current === media
|
package/lib/contexts.js
CHANGED
|
@@ -1145,19 +1145,45 @@ var usePlaybackMediaRef = function usePlaybackMediaRef() {
|
|
|
1145
1145
|
media = _usePlaybackContext.media;
|
|
1146
1146
|
var mediaRef = React.useRef(null);
|
|
1147
1147
|
React.useEffect(function () {
|
|
1148
|
-
|
|
1149
|
-
if (
|
|
1148
|
+
return function () {
|
|
1149
|
+
if (active) {
|
|
1150
1150
|
setMedia(null);
|
|
1151
1151
|
setIsBackground(false);
|
|
1152
1152
|
}
|
|
1153
|
-
|
|
1153
|
+
};
|
|
1154
|
+
}, [active]);
|
|
1155
|
+
React.useEffect(function () {
|
|
1156
|
+
if (!active || mediaRef.current === null || media !== null) {
|
|
1157
|
+
return;
|
|
1154
1158
|
}
|
|
1155
1159
|
setIsBackground(background);
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1160
|
+
setMedia(mediaRef.current);
|
|
1161
|
+
}, [active, background, media]);
|
|
1162
|
+
|
|
1163
|
+
// const shouldSetMedia = active && media === null && mediaRef.current !== null;
|
|
1164
|
+
// useEffect(
|
|
1165
|
+
// () => () => {
|
|
1166
|
+
// if (active) {
|
|
1167
|
+
// console.log('DESTROY unset media');
|
|
1168
|
+
// setMedia(null);
|
|
1169
|
+
// setIsBackground(false);
|
|
1170
|
+
// }
|
|
1171
|
+
// },
|
|
1172
|
+
// [active],
|
|
1173
|
+
// );
|
|
1174
|
+
|
|
1175
|
+
// useEffect(() => {
|
|
1176
|
+
// if (active && mediaRef.current !== null && media === null) {
|
|
1177
|
+
// console.log('SET media');
|
|
1178
|
+
// setIsBackground(background);
|
|
1179
|
+
// setMedia(mediaRef.current);
|
|
1180
|
+
// } else if (!active && mediaRef.current === media && media !== null) {
|
|
1181
|
+
// console.log('Unset media');
|
|
1182
|
+
// setMedia(null);
|
|
1183
|
+
// setIsBackground(false);
|
|
1184
|
+
// }
|
|
1185
|
+
// }, [active, background, media]);
|
|
1186
|
+
|
|
1161
1187
|
return {
|
|
1162
1188
|
ref: mediaRef,
|
|
1163
1189
|
isCurrent: mediaRef.current === media
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.797",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -167,5 +167,5 @@
|
|
|
167
167
|
"access": "public",
|
|
168
168
|
"registry": "https://registry.npmjs.org/"
|
|
169
169
|
},
|
|
170
|
-
"gitHead": "
|
|
170
|
+
"gitHead": "6944f2be19e84970e0619c79a7f733433633093c"
|
|
171
171
|
}
|