{"id":280309,"date":"2019-01-02T08:18:55","date_gmt":"2019-01-02T15:18:55","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=280309"},"modified":"2019-01-02T08:18:55","modified_gmt":"2019-01-02T15:18:55","slug":"touch-action","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/t\/touch-action\/","title":{"rendered":"touch-action"},"content":{"rendered":"

The touch-action<\/code> property in CSS gives you control over the effect of touchscreen interactions with an element, similar to the more widely-used pointer-events<\/a><\/code> property used to control mouse interactions.<\/p>\n

#element {\r\n  touch-action: pan-right pinch-zoom;\r\n}<\/code><\/pre>\n

The touch-action<\/code> property is useful primarily for interactive UI elements that need slightly different behavior depending on the type of device being used. When your users might expect an element to behave a particular way with a mouse, and slightly different behavior on a touch screen, touch-action<\/code> will come in handy.<\/p>\n

<\/p>\n

The most obvious example of this is an interactive map element. If you’ve ever viewed a map not designed to work with touch devices, you’ve probably tried to pinch and zoom only to find the browser magnifying the element, but not actually zooming the actual map.<\/p>\n

By default, a browser will handle touch interactions automatically: Pinch to zoom, swipe to scroll, etc. Setting touch-action<\/code> to none<\/code> will disable all browser handling of these events, leaving them up to you to implement (via JavaScript). If you only want to take over one interaction, tell the browser to handle the rest. For example, if you wrote some JavaScript that only handles zooming, you can tell the browser to handle everything else with this property: touch-action: pan-x pan-y;<\/code>.<\/p>\n

See the Pen examples of touch-action<\/a> by CSS-Tricks (@css-tricks<\/a>) on CodePen<\/a>.<\/p>\n

Syntax<\/h3>\n
touch-action: auto | none | [ [ pan-x | pan-left | pan-right ] || [ pan-y | pan-up | pan-down ] || pinch-zoom ] | manipulation<\/code><\/pre>\n

Values<\/h3>\n

The touch-action<\/code> property accepts the following values:<\/p>\n