Skip to content

Commit

Permalink
Add combinable touch-action support (#6115)
Browse files Browse the repository at this point in the history
* add combinable `touch-action` support

* update changelog
  • Loading branch information
RobinMalfait committed Nov 17, 2021
1 parent ef325ea commit 03f9de9
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 9 deletions.
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

0 comments on commit 03f9de9

Please sign in to comment.