Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add combinable touch-action support #6115

Merged
merged 2 commits into from Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Add `placeholder` variant ([#6106](https://github.com/tailwindlabs/tailwindcss/pull/6106))
- Add tuple syntax for configuring screens while guaranteeing order ([#5956](https://github.com/tailwindlabs/tailwindcss/pull/5956))
- Add combinable `touch-action` support ([#6115](https://github.com/tailwindlabs/tailwindcss/pull/6115))

## [3.0.0-alpha.2] - 2021-11-08

Expand Down
53 changes: 45 additions & 8 deletions src/corePlugins.js
Expand Up @@ -602,17 +602,54 @@ export let corePlugins = {

cursor: createUtilityPlugin('cursor'),

touchAction: ({ addUtilities }) => {
touchAction: ({ addBase, addUtilities }) => {
addBase({
'@defaults touch-action': {
'--tw-pan-x': 'var(--tw-empty,/*!*/ /*!*/)',
'--tw-pan-y': 'var(--tw-empty,/*!*/ /*!*/)',
'--tw-pinch-zoom': 'var(--tw-empty,/*!*/ /*!*/)',
'--tw-touch-action': 'var(--tw-pan-x) var(--tw-pan-y) var(--tw-pinch-zoom)',
},
})

addUtilities({
'.touch-auto': { 'touch-action': 'auto' },
'.touch-none': { 'touch-action': 'none' },
'.touch-pan-x': { 'touch-action': 'pan-x' },
'.touch-pan-left': { 'touch-action': 'pan-left' },
'.touch-pan-right': { 'touch-action': 'pan-right' },
'.touch-pan-y': { 'touch-action': 'pan-y' },
'.touch-pan-up': { 'touch-action': 'pan-up' },
'.touch-pan-down': { 'touch-action': 'pan-down' },
'.touch-pinch-zoom': { 'touch-action': 'pinch-zoom' },
'.touch-pan-x': {
'@defaults touch-action': {},
'--tw-pan-x': 'pan-x',
'touch-action': 'var(--tw-touch-action)',
},
'.touch-pan-left': {
'@defaults touch-action': {},
'--tw-pan-x': 'pan-left',
'touch-action': 'var(--tw-touch-action)',
},
'.touch-pan-right': {
'@defaults touch-action': {},
'--tw-pan-x': 'pan-right',
'touch-action': 'var(--tw-touch-action)',
},
'.touch-pan-y': {
'@defaults touch-action': {},
'--tw-pan-y': 'pan-y',
'touch-action': 'var(--tw-touch-action)',
},
'.touch-pan-up': {
'@defaults touch-action': {},
'--tw-pan-y': 'pan-up',
'touch-action': 'var(--tw-touch-action)',
},
'.touch-pan-down': {
'@defaults touch-action': {},
'--tw-pan-y': 'pan-down',
'touch-action': 'var(--tw-touch-action)',
},
'.touch-pinch-zoom': {
'@defaults touch-action': {},
'--tw-pinch-zoom': 'pinch-zoom',
'touch-action': 'var(--tw-touch-action)',
},
'.touch-manipulation': { 'touch-action': 'manipulation' },
})
},
Expand Down
25 changes: 24 additions & 1 deletion tests/basic-usage.test.css
Expand Up @@ -19,6 +19,16 @@
scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}

.touch-pan-x,
.touch-pan-y,
.touch-pan-up,
.touch-pinch-zoom {
--tw-pan-x: var(--tw-empty, /*!*/ /*!*/);
--tw-pan-y: var(--tw-empty, /*!*/ /*!*/);
--tw-pinch-zoom: var(--tw-empty, /*!*/ /*!*/);
--tw-touch-action: var(--tw-pan-x) var(--tw-pan-y) var(--tw-pinch-zoom);
}

.snap-x {
--tw-scroll-snap-strictness: proximity;
}
Expand Down Expand Up @@ -374,8 +384,21 @@
.cursor-pointer {
cursor: pointer;
}
.touch-pan-x {
--tw-pan-x: pan-x;
touch-action: var(--tw-touch-action);
}
.touch-pan-y {
touch-action: pan-y;
--tw-pan-y: pan-y;
touch-action: var(--tw-touch-action);
}
.touch-pan-up {
--tw-pan-y: pan-up;
touch-action: var(--tw-touch-action);
}
.touch-pinch-zoom {
--tw-pinch-zoom: pinch-zoom;
touch-action: var(--tw-touch-action);
}
.touch-manipulation {
touch-action: manipulation;
Expand Down
1 change: 1 addition & 0 deletions tests/basic-usage.test.html
Expand Up @@ -170,6 +170,7 @@
<div class="transition transition-all"></div>
<div class="ease-in-out"></div>
<div class="translate-x-5 -translate-x-4 translate-y-6 -translate-x-3"></div>
<div class="touch-pan-up touch-pan-x touch-pinch-zoom"></div>
<div class="select-none"></div>
<div class="align-middle"></div>
<div class="invisible"></div>
Expand Down