Skip to content

Commit d99560a

Browse files
committed
docs: follow tinygesture recommendation for longpress without tap
1 parent c0fa871 commit d99560a

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

packages/site/src/routes/demo/common/_UseActionsPannable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function Pannable(node: HTMLElement) {
2727

2828
node.style.transition =
2929
(node.style.transition ? node.style.transition + ', ' : '') +
30-
'opacity ease .3s';
30+
'opacity .3s ease';
3131

3232
node.addEventListener('touchstart', preventDefault, { passive: false });
3333

packages/site/src/routes/demo/common/_UseActionsSwipeable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function Swipeable(node: HTMLElement) {
99

1010
node.style.transition =
1111
(node.style.transition ? node.style.transition + ', ' : '') +
12-
'transform ease 0.3s';
12+
'transform .3s ease';
1313

1414
node.addEventListener('touchstart', preventDefault, { passive: false });
1515

packages/site/src/routes/demo/common/_UseActionsTappable.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ export default function Tappable(
1414

1515
node.style.transition =
1616
(node.style.transition ? node.style.transition + ', ' : '') +
17-
'background-color ease 0.3s, color ease 0.3s';
17+
'background-color .3s ease, color .3s ease';
1818

1919
gesture.on('tap', () => {
20-
if (!pressed) {
21-
node.style.transform = 'perspective(1000px) translate3d(0, 0, 100px)';
22-
clearTimeout(tapTimeout);
23-
tapTimeout = setTimeout(() => (node.style.transform = ''), 300);
20+
if (pressed) {
21+
return;
2422
}
25-
pressed = false;
23+
node.style.transform = 'perspective(1000px) translate3d(0, 0, 100px)';
24+
clearTimeout(tapTimeout);
25+
tapTimeout = setTimeout(() => (node.style.transform = ''), 300);
2626
});
2727
gesture.on('doubletap', () => {
2828
node.style.transform = 'perspective(1000px) translate3d(0, 0, 400px)';
@@ -37,10 +37,16 @@ export default function Tappable(
3737
});
3838

3939
gesture.on('panend', () => {
40-
pressTimeout = setTimeout(() => {
41-
node.style.backgroundColor = '';
42-
node.style.color = '';
43-
}, 300);
40+
if (pressed) {
41+
pressTimeout = setTimeout(() => {
42+
node.style.backgroundColor = '';
43+
node.style.color = '';
44+
}, 300);
45+
46+
setTimeout(() => {
47+
pressed = false;
48+
}, 0);
49+
}
4450
});
4551

4652
return {

0 commit comments

Comments
 (0)