@micromag/screen-game-sort 0.3.737 → 0.3.738
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/index.js +21 -12
- package/package.json +2 -2
package/es/index.js
CHANGED
|
@@ -197,18 +197,25 @@ var zzzz = function zzzz(_ref) {
|
|
|
197
197
|
var refs = currentItems.map(function (it) {
|
|
198
198
|
return elementsRef.current[it.id] || null;
|
|
199
199
|
});
|
|
200
|
-
var
|
|
200
|
+
var initialRefs = (items || []).map(function (it) {
|
|
201
|
+
return elementsRef.current[it.id] || null;
|
|
202
|
+
});
|
|
203
|
+
var initialHeights = initialRefs.map(function (it) {
|
|
201
204
|
var _it$getBoundingClient;
|
|
202
205
|
return (it === null || it === void 0 || (_it$getBoundingClient = it.getBoundingClientRect()) === null || _it$getBoundingClient === void 0 ? void 0 : _it$getBoundingClient.height) || 0;
|
|
203
206
|
});
|
|
207
|
+
var heights = refs.map(function (it) {
|
|
208
|
+
var _it$getBoundingClient2;
|
|
209
|
+
return (it === null || it === void 0 || (_it$getBoundingClient2 = it.getBoundingClientRect()) === null || _it$getBoundingClient2 === void 0 ? void 0 : _it$getBoundingClient2.height) || 0;
|
|
210
|
+
});
|
|
204
211
|
// console.log('heights', heights);
|
|
205
212
|
api.start(function (itemIndex) {
|
|
206
213
|
var item = (items || [])[itemIndex] || null;
|
|
207
214
|
var sortedIndex = currentItems.findIndex(function (it) {
|
|
208
215
|
return it.id === item.id;
|
|
209
216
|
});
|
|
210
|
-
var currentHeight =
|
|
211
|
-
var currentY =
|
|
217
|
+
var currentHeight = initialHeights[itemIndex] || 0;
|
|
218
|
+
var currentY = initialHeights.slice(0, itemIndex).reduce(function (acc, itemHeight) {
|
|
212
219
|
return acc + itemHeight;
|
|
213
220
|
}, 0);
|
|
214
221
|
|
|
@@ -221,13 +228,15 @@ var zzzz = function zzzz(_ref) {
|
|
|
221
228
|
immediate: true
|
|
222
229
|
};
|
|
223
230
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
+
|
|
232
|
+
// if (itemIndex === sortedIndex) {
|
|
233
|
+
// return {
|
|
234
|
+
// y: `0%`,
|
|
235
|
+
// scale: 1,
|
|
236
|
+
// immediate: initial,
|
|
237
|
+
// };
|
|
238
|
+
// }
|
|
239
|
+
|
|
231
240
|
var newY = heights.slice(0, sortedIndex).reduce(function (acc, itemHeight) {
|
|
232
241
|
return acc + itemHeight;
|
|
233
242
|
}, 0);
|
|
@@ -282,8 +291,8 @@ var zzzz = function zzzz(_ref) {
|
|
|
282
291
|
return elementsRef.current[it.id] || null;
|
|
283
292
|
});
|
|
284
293
|
var heights = refs.map(function (it) {
|
|
285
|
-
var _it$
|
|
286
|
-
return (it === null || it === void 0 || (_it$
|
|
294
|
+
var _it$getBoundingClient3;
|
|
295
|
+
return (it === null || it === void 0 || (_it$getBoundingClient3 = it.getBoundingClientRect()) === null || _it$getBoundingClient3 === void 0 ? void 0 : _it$getBoundingClient3.height) || 0;
|
|
287
296
|
});
|
|
288
297
|
var ys = heights.map(function (itemHeight, heightIndex) {
|
|
289
298
|
var endY = itemHeight + heights.slice(0, heightIndex).reduce(function (acc, h) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-game-sort",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.738",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"access": "public",
|
|
88
88
|
"registry": "https://registry.npmjs.org/"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "01cf2bc1d2bf4769cb33fb817304c6103e2b60f3"
|
|
91
91
|
}
|