publ-echo 0.0.37 → 0.0.38

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.
@@ -1,11 +1,17 @@
1
1
  export function calcGridColWidth(positionParams) {
2
2
  var margin = positionParams.margin, containerPadding = positionParams.containerPadding, containerWidth = positionParams.containerWidth, cols = positionParams.cols;
3
- return ((containerWidth - margin[0] * (cols - 1) - containerPadding[0] * 2) / cols);
3
+ console.log({
4
+ containerPadding: containerPadding,
5
+ margin: margin,
6
+ cols: cols,
7
+ containerWidth: containerWidth
8
+ });
9
+ return (Math.floor((containerWidth - margin[0] * (cols - 1) - containerPadding[0] * 2) / cols));
4
10
  }
5
11
  export function calcGridItemWHPx(gridUnits, colOrRowSize, marginPx) {
6
12
  if (!Number.isFinite(gridUnits))
7
13
  return gridUnits;
8
- return Math.ceil(colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx);
14
+ return Math.round(colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx);
9
15
  }
10
16
  export var resolveRowHeight = function (rowHeight, width) {
11
17
  return typeof rowHeight === "number" ? rowHeight : rowHeight(width);
@@ -15,8 +21,8 @@ export function calcGridItemPosition(positionParams, x, y, z, w, h, state) {
15
21
  var colWidth = calcGridColWidth(positionParams);
16
22
  var rowHeightNumber = resolveRowHeight(rowHeight, colWidth);
17
23
  var result = {
18
- left: Math.ceil((colWidth + margin[0]) * x + containerPadding[0]),
19
- top: Math.ceil((rowHeightNumber + margin[1]) * y + containerPadding[1]),
24
+ left: Math.round((colWidth + margin[0]) * x + containerPadding[0]),
25
+ top: Math.round((rowHeightNumber + margin[1]) * y + containerPadding[1]),
20
26
  width: w === Infinity ? w : calcGridItemWHPx(w, colWidth, margin[0]),
21
27
  height: h === Infinity ? h : calcGridItemWHPx(h, rowHeightNumber, margin[1]),
22
28
  z: z,
@@ -36,10 +42,8 @@ export function calcGridItemPosition(positionParams, x, y, z, w, h, state) {
36
42
  result.left = Math.round(state.dragging.left);
37
43
  }
38
44
  else {
39
- result.top = Math.ceil((rowHeightNumber + margin[1]) * y + containerPadding[1]);
40
- result.left = Math.ceil((colWidth + margin[0]) * x + containerPadding[0]);
41
- console.log(result.left);
42
- console.log({ colWidth: colWidth, margin0: margin[0], x: x, containerPadding: containerPadding[0] });
45
+ result.top = Math.round((rowHeightNumber + margin[1]) * y + containerPadding[1]);
46
+ result.left = Math.round((colWidth + margin[0]) * x + containerPadding[0]);
43
47
  }
44
48
  return result;
45
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "publ-echo",
3
- "version": "0.0.37",
3
+ "version": "0.0.38",
4
4
  "private": false,
5
5
  "main": "dist/lib/index.js",
6
6
  "types": "dist/lib/index.d.js",