Skip to content

Commit f487606

Browse files
authored
Merge pull request #2421 from adumesny/master
touchscreen tweaks
2 parents 3fbca94 + 0666182 commit f487606

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

doc/CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Change log
55
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
66
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
77

8+
- [9.0.0-dev (TBD)](#900-dev-tbd)
89
- [9.0.0 (2023-08-23)](#900-2023-08-23)
910
- [8.4.0 (2023-07-20)](#840-2023-07-20)
1011
- [8.3.0 (2023-06-13)](#830-2023-06-13)
@@ -93,6 +94,10 @@ Change log
9394

9495
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
9596

97+
## 9.0.0-dev (TBD)
98+
* tweak to `fitToContent` [#2412](from https://github.com/gridstack/gridstack.js/pull/2412#issuecomment-1690219018)
99+
* fix [#2413](https://github.com/gridstack/gridstack.js/issues/2413) support touchscreen+mouse devices. Thank you [@Ruslan207](https://github.com/Ruslan207)
100+
96101
## 9.0.0 (2023-08-23)
97102
- feat [#404](https://github.com/gridstack/gridstack.js/issues/404) added `GridStackOptions.fitToContent` and `GridStackWidget.fitToContent` to make gridItems size themselves to their content (no scroll bar), calling `GridStack.resizeToContent(el)` whenever the grid or item is resized.
98103
- also added new `'resizecontent'` event, and `resizeToContentCB` and `resizeToContentParent` vars.

src/dd-touch.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,8 @@ export function touchend(e: TouchEvent): void {
175175
*/
176176
export function pointerdown(e: PointerEvent): void {
177177
// console.log("pointer down")
178-
if (e.pointerType !== 'mouse') {
179-
(e.target as HTMLElement).releasePointerCapture(e.pointerId) // <- Important!
180-
}
178+
if (e.pointerType === 'mouse') return;
179+
(e.target as HTMLElement).releasePointerCapture(e.pointerId) // <- Important!
181180
}
182181

183182
export function pointerenter(e: PointerEvent): void {
@@ -187,9 +186,8 @@ export function pointerenter(e: PointerEvent): void {
187186
return;
188187
}
189188
// console.log('pointerenter');
190-
if (e.pointerType !== 'mouse') {
191-
simulatePointerMouseEvent(e, 'mouseenter');
192-
}
189+
if (e.pointerType === 'mouse') return;
190+
simulatePointerMouseEvent(e, 'mouseenter');
193191
}
194192

195193
export function pointerleave(e: PointerEvent): void {
@@ -199,12 +197,11 @@ export function pointerleave(e: PointerEvent): void {
199197
// console.log('pointerleave ignored');
200198
return;
201199
}
202-
if (e.pointerType !== 'mouse') {
203-
DDTouch.pointerLeaveTimeout = window.setTimeout(() => {
204-
delete DDTouch.pointerLeaveTimeout;
205-
// console.log('pointerleave delayed');
206-
simulatePointerMouseEvent(e, 'mouseleave');
207-
}, 10);
208-
}
200+
if (e.pointerType === 'mouse') return;
201+
DDTouch.pointerLeaveTimeout = window.setTimeout(() => {
202+
delete DDTouch.pointerLeaveTimeout;
203+
// console.log('pointerleave delayed');
204+
simulatePointerMouseEvent(e, 'mouseleave');
205+
}, 10);
209206
}
210207

0 commit comments

Comments
 (0)