@oat-sa/tao-core-ui 3.13.3 → 3.13.5

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.
@@ -119,6 +119,182 @@ define(['jquery', 'lodash', 'interact', 'core/mouseEvent'], function ($, _, inte
119
119
  domElement.style.transform = 'translate(0px, 0px) translateZ(0px)';
120
120
  domElement.setAttribute('data-x', 0);
121
121
  domElement.setAttribute('data-y', 0);
122
+ },
123
+ /**
124
+ * Improve touch devices support:
125
+ * - prevent native scroll while dragging
126
+ * - start drag only after longpress:
127
+ * when user is scrolling through the long page, he can accidentally get his finger on the draggable element:
128
+ * this will cause unwanted, unnoticed drag and can mess up his response.
129
+ * @example
130
+ * touchPatch = interactUtils.touchPatchFactory();
131
+ * interact(selector)
132
+ * .draggable({
133
+ onstart: () => {
134
+ touchPatch.onstart();
135
+ },
136
+ onend: () => {
137
+ touchPatch.onend();
138
+ }
139
+ })
140
+ .actionChecker(touchPatch.actionChecker);
141
+ ...
142
+ function destroy() {
143
+ ` touchPatch.destroy()
144
+ interact(selector).unset();
145
+ }
146
+ * @returns {Object}
147
+ */
148
+ touchPatchFactory: function touchPatchFactory() {
149
+ const delayBefore = 300;
150
+ const distanceTolerance = 20; //while waiting for delayBefore, finger can move a little bit
151
+
152
+ interact.pointerMoveTolerance(distanceTolerance);
153
+ let isDragging = false;
154
+
155
+ // webKit requires cancelable `touchmove` events to be added as early as possible
156
+ // alternative: `touch-action: pinch-zoom` css: add it after drag start [?]; or have it always - worse ux
157
+ function touchmoveListener(e) {
158
+ if (isDragging) {
159
+ e.preventDefault();
160
+ }
161
+ }
162
+ window.addEventListener('touchmove', touchmoveListener, {
163
+ passive: false
164
+ });
165
+ function contextmenuListener(e) {
166
+ e.preventDefault();
167
+ }
168
+ return {
169
+ /**
170
+ * @param {PointerEvent} pointer
171
+ * @param {PointerEvent} event
172
+ * @param {Object} action
173
+ * @param {Object} interactable
174
+ * @returns {Object}
175
+ */
176
+ actionChecker: (pointer, event, action, interactable, element) => {
177
+ if (event && action && action.name === 'drag') {
178
+ const isTouch = event.pointerType === 'touch';
179
+ interactable.options[action.name].delay = isTouch ? delayBefore : 0;
180
+ if (isTouch && !element.dataset.noContextMenu) {
181
+ //prevent context menu on longpress
182
+ //this listener can stay forever until the element is destroyed
183
+ element.addEventListener('contextmenu', contextmenuListener);
184
+ element.dataset.noContextMenu = true;
185
+ }
186
+ }
187
+ return action;
188
+ },
189
+ onstart: () => {
190
+ isDragging = true;
191
+ },
192
+ onend: () => {
193
+ isDragging = false;
194
+ },
195
+ destroy: () => {
196
+ window.removeEventListener('touchmove', touchmoveListener);
197
+ }
198
+ };
199
+ },
200
+ /**
201
+ * Builds a scroll observer that will make sure the dragged element keeps an accurate positioning
202
+ * @example
203
+ * scrollObserver = interactUtils.scrollObserverFactory($container);
204
+ * dragOptions = {
205
+ autoScroll: {
206
+ container: scrollObserver.getScrollContainer().get(0)
207
+ },
208
+ onstart: function (e) {
209
+ scrollObserver.start($activeChoice);
210
+ },
211
+ onend: function (e) {
212
+ scrollObserver.stop();
213
+ }
214
+ };
215
+ * @param {jQuery} $scrollContainer
216
+ * @returns {scrollObserver}
217
+ */
218
+ scrollObserverFactory: function scrollObserverFactory($scrollContainer) {
219
+ let currentDraggable = null;
220
+ let beforeY = 0;
221
+ let beforeX = 0;
222
+ let afterY = 0;
223
+ let afterX = 0;
224
+
225
+ // reset the scroll observer context
226
+ function resetScrollObserver() {
227
+ currentDraggable = null;
228
+ beforeY = 0;
229
+ beforeX = 0;
230
+ afterY = 0;
231
+ afterX = 0;
232
+ }
233
+
234
+ // keep the position of the dragged element accurate with the scroll position
235
+ function onScrollCb() {
236
+ let x;
237
+ let y;
238
+ if (currentDraggable) {
239
+ beforeY = afterY;
240
+ beforeX = afterX;
241
+ if (afterY === 0 && beforeY === 0) beforeY = this.scrollTop;
242
+ if (afterX === 0 && beforeX === 0) beforeX = this.scrollLeft;
243
+ afterY = this.scrollTop;
244
+ afterX = this.scrollLeft;
245
+ y = (parseInt(currentDraggable.getAttribute('data-y'), 10) || 0) + (afterY - beforeY);
246
+ x = (parseInt(currentDraggable.getAttribute('data-x'), 10) || 0) + (afterX - beforeX);
247
+
248
+ // translate the element
249
+ currentDraggable.style.webkitTransform = currentDraggable.style.transform = `translate(${x}px, ${y}px)`;
250
+
251
+ // update the position attributes
252
+ currentDraggable.setAttribute('data-x', x);
253
+ currentDraggable.setAttribute('data-y', y);
254
+ }
255
+ }
256
+
257
+ // find the scroll container within the parents if any
258
+ $scrollContainer.parents().each(function findScrollContainer() {
259
+ const $el = $(this);
260
+ const ovf = $el.css('overflow');
261
+ if (ovf !== 'hidden' && ovf !== 'visible') {
262
+ $scrollContainer = $el;
263
+ return false;
264
+ }
265
+ });
266
+
267
+ // make sure the drop zones will follow the scroll
268
+ interact.dynamicDrop(true);
269
+
270
+ /**
271
+ * @typedef {Object} scrollObserver
272
+ */
273
+ return {
274
+ /**
275
+ * Gets the scroll container
276
+ * @returns {jQuery}
277
+ */
278
+ getScrollContainer: function getScrollContainer() {
279
+ return $scrollContainer;
280
+ },
281
+ /**
282
+ * Initializes the scroll observer while dragging a choice
283
+ * @param {HTMLElement|jQuery} draggedElement
284
+ */
285
+ start: function start(draggedElement) {
286
+ resetScrollObserver();
287
+ currentDraggable = draggedElement instanceof $ ? draggedElement.get(0) : draggedElement;
288
+ $scrollContainer.on('scroll.scrollObserver', _.throttle(onScrollCb, 50));
289
+ },
290
+ /**
291
+ * Tears down the the scroll observer once the dragging is done
292
+ */
293
+ stop: function stop() {
294
+ $scrollContainer.off('.scrollObserver');
295
+ resetScrollObserver();
296
+ }
297
+ };
122
298
  }
123
299
  };
124
300
  var interactHelper$1 = interactHelper;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oat-sa/tao-core-ui",
3
- "version": "3.13.3",
3
+ "version": "3.13.5",
4
4
  "displayName": "TAO Core UI",
5
5
  "description": "UI libraries of TAO",
6
6
  "scripts": {
@@ -19,6 +19,14 @@ nav {
19
19
  list-style: none;
20
20
  }
21
21
  }
22
+ .writing-mode-vertical-rl ol {
23
+ li::marker {
24
+ text-combine-upright: all;
25
+ }
26
+ li {
27
+ padding-inline-start: 6px;
28
+ }
29
+ }
22
30
 
23
31
  /*
24
32
  This SCSS generates CSS classes for custom list styling, it:
package/src/css/basic.css CHANGED
@@ -1541,6 +1541,12 @@ html nav ul {
1541
1541
  margin: 0;
1542
1542
  list-style: none;
1543
1543
  }
1544
+ html .writing-mode-vertical-rl ol li::marker {
1545
+ text-combine-upright: all;
1546
+ }
1547
+ html .writing-mode-vertical-rl ol li {
1548
+ padding-inline-start: 6px;
1549
+ }
1544
1550
  html [class^=list-style-],
1545
1551
  html [class*=" list-style-"] {
1546
1552
  counter-reset: custom-counter;