@qrvey/utils 1.15.0-13 → 1.15.0-14
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.
|
@@ -40,6 +40,14 @@ export declare const getFixedPositionByDevice: (item: VemFixed, device: CanvasDe
|
|
|
40
40
|
* @returns
|
|
41
41
|
*/
|
|
42
42
|
export declare function findFixedAvailablePositions(canvasWidth: number, newElements: VemFixed[], elements: VemFixed[], device: CanvasDevice, startWithPositionY?: boolean, findRightToLeft?: boolean, canvasHeight?: number): VemFixed[];
|
|
43
|
+
/**
|
|
44
|
+
* Adjusts the `width` of a responsive element to fit within the specified canvas width and updates its position.
|
|
45
|
+
* @param element - The fixed element to adjust.
|
|
46
|
+
* @param canvasWidth - The width of the canvas in grid columns.
|
|
47
|
+
* @param canvasDevice - The target device type (e.g., desktop, tablet, mobile).
|
|
48
|
+
* @returns - The updated responsive element with an adjusted `width`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function calculateWidth(element: VemFixed, canvasWidth: number, canvasDevice: CanvasDevice): VemFixed;
|
|
43
51
|
/**
|
|
44
52
|
* @param elements elements to calculate
|
|
45
53
|
* @param device current device
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFixedGridElementsBottomLimit = exports.findFixedAvailablePositions = exports.getFixedPositionByDevice = exports.findAvailablePosition = exports.updateFixedPosition = void 0;
|
|
3
|
+
exports.getFixedGridElementsBottomLimit = exports.calculateWidth = exports.findFixedAvailablePositions = exports.getFixedPositionByDevice = exports.findAvailablePosition = exports.updateFixedPosition = void 0;
|
|
4
|
+
const IVemPosition_1 = require("../interfaces/IVemPosition");
|
|
4
5
|
const overlap_1 = require("../utils/overlap");
|
|
6
|
+
const position_1 = require("../utils/position");
|
|
5
7
|
const SPACE_DELTA = 10;
|
|
6
8
|
/**
|
|
7
9
|
* update the position for a specific device
|
|
@@ -96,14 +98,29 @@ function findFixedAvailablePositions(canvasWidth, newElements, elements, device,
|
|
|
96
98
|
const initialY = startWithPositionY
|
|
97
99
|
? nElement.position.fixed[device].y
|
|
98
100
|
: 0;
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
+
const newElement = calculateWidth(nElement, canvasWidth, device);
|
|
102
|
+
const availablePosition = findAvailablePosition(canvasWidth, newElement, processedElements, device, { initialY, findRightToLeft, canvasHeight });
|
|
103
|
+
const newElemWithPosition = updateFixedPosition(newElement, availablePosition, device);
|
|
101
104
|
resultElems.push(newElemWithPosition);
|
|
102
105
|
processedElements.push(newElemWithPosition);
|
|
103
106
|
});
|
|
104
107
|
return resultElems;
|
|
105
108
|
}
|
|
106
109
|
exports.findFixedAvailablePositions = findFixedAvailablePositions;
|
|
110
|
+
/**
|
|
111
|
+
* Adjusts the `width` of a responsive element to fit within the specified canvas width and updates its position.
|
|
112
|
+
* @param element - The fixed element to adjust.
|
|
113
|
+
* @param canvasWidth - The width of the canvas in grid columns.
|
|
114
|
+
* @param canvasDevice - The target device type (e.g., desktop, tablet, mobile).
|
|
115
|
+
* @returns - The updated responsive element with an adjusted `width`.
|
|
116
|
+
*/
|
|
117
|
+
function calculateWidth(element, canvasWidth, canvasDevice) {
|
|
118
|
+
const currentPosition = element.position.fixed[canvasDevice];
|
|
119
|
+
const fixedWidth = Math.min(currentPosition.width, canvasWidth);
|
|
120
|
+
const position = Object.assign(Object.assign({}, currentPosition), { width: fixedWidth });
|
|
121
|
+
return (0, position_1.setElementPosition)(element, IVemPosition_1.VemPositionType.FIXED, canvasDevice, position);
|
|
122
|
+
}
|
|
123
|
+
exports.calculateWidth = calculateWidth;
|
|
107
124
|
const getFixedGridElementY = (element, device, allowNegative = false) => {
|
|
108
125
|
var _a;
|
|
109
126
|
const position = element.position.fixed[device];
|
|
@@ -40,6 +40,14 @@ export declare const getFixedPositionByDevice: (item: VemFixed, device: CanvasDe
|
|
|
40
40
|
* @returns
|
|
41
41
|
*/
|
|
42
42
|
export declare function findFixedAvailablePositions(canvasWidth: number, newElements: VemFixed[], elements: VemFixed[], device: CanvasDevice, startWithPositionY?: boolean, findRightToLeft?: boolean, canvasHeight?: number): VemFixed[];
|
|
43
|
+
/**
|
|
44
|
+
* Adjusts the `width` of a responsive element to fit within the specified canvas width and updates its position.
|
|
45
|
+
* @param element - The fixed element to adjust.
|
|
46
|
+
* @param canvasWidth - The width of the canvas in grid columns.
|
|
47
|
+
* @param canvasDevice - The target device type (e.g., desktop, tablet, mobile).
|
|
48
|
+
* @returns - The updated responsive element with an adjusted `width`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function calculateWidth(element: VemFixed, canvasWidth: number, canvasDevice: CanvasDevice): VemFixed;
|
|
43
51
|
/**
|
|
44
52
|
* @param elements elements to calculate
|
|
45
53
|
* @param device current device
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { VemPositionType } from "../interfaces/IVemPosition";
|
|
1
2
|
import { OverlapIntervalTree } from "../utils/overlap";
|
|
3
|
+
import { setElementPosition } from "../utils/position";
|
|
2
4
|
const SPACE_DELTA = 10;
|
|
3
5
|
/**
|
|
4
6
|
* update the position for a specific device
|
|
@@ -90,13 +92,27 @@ export function findFixedAvailablePositions(canvasWidth, newElements, elements,
|
|
|
90
92
|
const initialY = startWithPositionY
|
|
91
93
|
? nElement.position.fixed[device].y
|
|
92
94
|
: 0;
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
+
const newElement = calculateWidth(nElement, canvasWidth, device);
|
|
96
|
+
const availablePosition = findAvailablePosition(canvasWidth, newElement, processedElements, device, { initialY, findRightToLeft, canvasHeight });
|
|
97
|
+
const newElemWithPosition = updateFixedPosition(newElement, availablePosition, device);
|
|
95
98
|
resultElems.push(newElemWithPosition);
|
|
96
99
|
processedElements.push(newElemWithPosition);
|
|
97
100
|
});
|
|
98
101
|
return resultElems;
|
|
99
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Adjusts the `width` of a responsive element to fit within the specified canvas width and updates its position.
|
|
105
|
+
* @param element - The fixed element to adjust.
|
|
106
|
+
* @param canvasWidth - The width of the canvas in grid columns.
|
|
107
|
+
* @param canvasDevice - The target device type (e.g., desktop, tablet, mobile).
|
|
108
|
+
* @returns - The updated responsive element with an adjusted `width`.
|
|
109
|
+
*/
|
|
110
|
+
export function calculateWidth(element, canvasWidth, canvasDevice) {
|
|
111
|
+
const currentPosition = element.position.fixed[canvasDevice];
|
|
112
|
+
const fixedWidth = Math.min(currentPosition.width, canvasWidth);
|
|
113
|
+
const position = Object.assign(Object.assign({}, currentPosition), { width: fixedWidth });
|
|
114
|
+
return setElementPosition(element, VemPositionType.FIXED, canvasDevice, position);
|
|
115
|
+
}
|
|
100
116
|
const getFixedGridElementY = (element, device, allowNegative = false) => {
|
|
101
117
|
var _a;
|
|
102
118
|
const position = element.position.fixed[device];
|