its_ui_vite 1.1.12 → 1.1.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.
- package/package.json +1 -1
- package/src/assets/js/helpers.js +35 -9
package/package.json
CHANGED
package/src/assets/js/helpers.js
CHANGED
|
@@ -57,11 +57,12 @@ export const CClasses = {
|
|
|
57
57
|
|
|
58
58
|
export function addTracingElement(target, moveFn = () => {}) {
|
|
59
59
|
let timer;
|
|
60
|
+
let interval;
|
|
60
61
|
let debounceTimer;
|
|
61
62
|
let positionInfo;
|
|
62
63
|
let lockPosition = true;
|
|
63
64
|
|
|
64
|
-
const handlesEvents = ['
|
|
65
|
+
const handlesEvents = ['wheel', 'load', 'fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'msfullscreenchange']
|
|
65
66
|
|
|
66
67
|
function setPositionInfo(position, e) {
|
|
67
68
|
positionInfo = {
|
|
@@ -74,6 +75,10 @@ export function addTracingElement(target, moveFn = () => {}) {
|
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
|
|
78
|
+
function isMoveTarget(position) {
|
|
79
|
+
return position.top !== target.value?.getBoundingClientRect().top;
|
|
80
|
+
}
|
|
81
|
+
|
|
77
82
|
function isVisible(position) {
|
|
78
83
|
if (!position) return false
|
|
79
84
|
|
|
@@ -120,38 +125,59 @@ export function addTracingElement(target, moveFn = () => {}) {
|
|
|
120
125
|
lockPosition = !e?.deltaY;
|
|
121
126
|
|
|
122
127
|
if (timer) return;
|
|
123
|
-
|
|
128
|
+
// это нужно чтобы проверить сдвинулся ли скролл
|
|
129
|
+
requestAnimationFrame(() => {
|
|
130
|
+
if (isMoveTarget(position)) dispatch(positionInfo);
|
|
131
|
+
});
|
|
124
132
|
|
|
125
133
|
timer = setTimeout(() => {
|
|
126
134
|
timer = undefined;
|
|
127
135
|
|
|
128
|
-
dispatch(positionInfo);
|
|
136
|
+
if (isMoveTarget(position)) dispatch(positionInfo);
|
|
129
137
|
|
|
130
|
-
// здесь
|
|
131
|
-
|
|
132
|
-
|
|
138
|
+
// здесь interval т.к. некоторые элементы могут двигатся после onMounted (к примеру попапы на карте)
|
|
139
|
+
clearInterval(interval);
|
|
140
|
+
interval = setInterval(() => {
|
|
133
141
|
const position = target.value?.getBoundingClientRect();
|
|
134
|
-
lockPosition = true;
|
|
135
142
|
|
|
136
143
|
setPositionInfo(position);
|
|
137
144
|
dispatch(positionInfo);
|
|
138
145
|
}, 200);
|
|
146
|
+
|
|
147
|
+
// здесь debounce т.к. не всегда привязанный элемент встает на место
|
|
148
|
+
clearTimeout(debounceTimer);
|
|
149
|
+
debounceTimer = setTimeout(() => {
|
|
150
|
+
clearInterval(interval);
|
|
151
|
+
lockPosition = true;
|
|
152
|
+
}, 1250);
|
|
139
153
|
}, 100);
|
|
140
154
|
}
|
|
141
155
|
|
|
156
|
+
function setDargHandler(e) {
|
|
157
|
+
if (e.type === 'mousedown') document.body.addEventListener('mousemove', targetMoveHandler)
|
|
158
|
+
else document.body.removeEventListener('mousemove', targetMoveHandler)
|
|
159
|
+
}
|
|
160
|
+
|
|
142
161
|
function addListeners() {
|
|
143
162
|
handlesEvents.forEach((eventName) => {
|
|
144
163
|
const handleRoot = eventName === 'load' ? window : document.body
|
|
145
164
|
handleRoot.addEventListener(eventName, targetMoveHandler)
|
|
146
165
|
})
|
|
147
|
-
|
|
166
|
+
|
|
167
|
+
document.body.addEventListener('mousedown', setDargHandler)
|
|
168
|
+
document.body.addEventListener('mouseup', setDargHandler)
|
|
169
|
+
|
|
170
|
+
targetMoveHandler();
|
|
148
171
|
}
|
|
149
172
|
|
|
150
173
|
function removeListeners() {
|
|
151
174
|
handlesEvents.forEach((eventName) => {
|
|
152
175
|
const handleRoot = eventName === 'load' ? window : document.body
|
|
153
176
|
handleRoot.removeEventListener(eventName, targetMoveHandler)
|
|
154
|
-
})
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
document.body.removeEventListener('mousedown', setDargHandler)
|
|
180
|
+
document.body.removeEventListener('mouseup', setDargHandler)
|
|
155
181
|
}
|
|
156
182
|
|
|
157
183
|
return {
|