scroll‑start Property Playground - Online Carousel Initial Snap
Define the initial scroll position for a scroll container with scroll‑start. Test with and without snapping. New feature.
UD5 Toolkit
实时手势控制演示 · 触摸轨迹可视化 · 移动端体验最佳
touch-action: auto;
在移动设备上,切换不同的 touch-action 值后尝试在主画布上滑动,可以真实感受浏览器手势行为的变化。
none 会阻止页面滚动,pan-y 仅允许垂直滚动。桌面端请使用浏览器设备模拟模式获得完整体验。
touch-action 是一个CSS属性,用于控制浏览器在触摸设备上如何处理触摸手势(如平移、缩放)。它允许开发者指定在特定元素上哪些手势应由浏览器默认处理,哪些应完全交给JavaScript自定义处理。这对于构建流畅的移动端交互体验至关重要,特别是在需要自定义拖拽、绘图或滑动手势的应用中。
auto — 浏览器默认行为,允许所有手势(滚动、缩放等)。none — 完全阻止浏览器默认手势,所有触摸事件由JS处理。适用于自定义绘图画布、游戏等。pan-x — 仅允许水平单指平移,阻止垂直滚动和缩放。pan-y — 仅允许垂直单指平移,阻止水平滚动和缩放。pinch-zoom — 仅允许多指缩放(pinch zoom),阻止平移。manipulation — 允许平移和缩放,但阻止双击缩放(double-tap zoom),相当于 pan-x pan-y pinch-zoom 的组合。pan-left / pan-right / pan-up / pan-down — 仅允许指定方向的平移(浏览器支持有限)。touch-action 解决了这一痛点:
touch-action: none 防止画布上的触摸操作触发页面滚动。touch-action: none 确保拖拽流畅不被滚动打断。touch-action: pan-y 允许垂直滚动页面但水平滑动用于切换图片。touch-action: manipulation 允许平移和缩放但阻止双击放大。touch-action: none 获取完全的手势控制权。touchstart 和 touchmove 事件设置为passive模式(即 {passive: true}),意味着事件处理器无法调用 preventDefault() 来阻止滚动。设置 touch-action: none 告诉浏览器该元素不需要默认手势处理,从而使非passive的事件监听器能够正常工作。这是性能和交互之间的关键平衡机制。
touch-action 在所有现代浏览器中都有良好支持,包括Chrome 36+、Firefox 52+、Safari 13+、Edge 79+。iOS Safari从13版本开始支持,Android Chrome完全支持。pinch-zoom 值在Safari中支持较晚(Safari 13+)。pan-left/right/up/down 等方向性值的浏览器支持较为有限,建议使用 pan-x 和 pan-y 作为替代。对于不支持的旧浏览器,可配合polyfill或降级方案。
touch-action计算值。touch-action设置(该属性可继承)。{passive: false}选项以配合touch-action: none。touch-action: none 实际上可以提升性能。因为它明确告诉浏览器该元素不需要默认手势处理,浏览器可以跳过手势识别步骤,减少触摸事件的延迟(从约300ms降至接近即时)。这正是 manipulation 值的设计初衷之一——消除双击缩放带来的300ms延迟,同时保留平移和缩放能力。合理设置 touch-action 是移动端性能优化的最佳实践之一。
Define the initial scroll position for a scroll container with scroll‑start. Test with and without snapping. New feature.
A full‑screen drawing canvas supporting multiple touch points simultaneously. Different colors per finger. Works on mobile.
Create an animation that advances with scroll using animation‑timeline: scroll(). See the visual timeline editor. Modern CSS.
See how overflow: visible, hidden, scroll, and auto behave with real content. Clone to test with your text.
See the View Transitions API in action. Cross‑fade and morph between two states. Copy the JavaScript starter code.
Use CSS masks and fixed backgrounds to create a unique parallax reveal effect. Copy the code. No JavaScript.
Register and apply a custom paint worklet to draw a background pattern dynamically. Write the paint function in the browser.
A beautiful full‑screen drawing canvas with variable brush sizes, colors, and an eraser. Export your sketch as PNG. All data stays local.
Create a pure CSS scroll progress indicator using animation‑timeline: scroll(). No JavaScript. Copy the complete code.
Create CSS mask‑image effects with custom shapes, gradients, and SVGs. Visually see the mask applied to an image. Copy the CSS.
Customize falling snow particles with pure CSS or canvas. Adjust speed, size, and wind. Copy the code for your website.
Visually create the glassmorphism effect: background blur, transparency, and border. Copy the complete CSS. Modern UI design.
Write a paint worklet in JavaScript and see it used as a CSS background instantly. Experiment with Houdini. Local.
Write JavaScript using element.animate() and see the result in a live preview. Compare with CSS keyframes. Debugger included.
Help the bird fly through pipes without touching them. Click or tap to flap. Track your high score in localStorage. Classic time‑waster.
Create a custom element with named slots and see content projection in action. Learn Web Components basics.
Draw shapes and experiment with globalCompositeOperation. See Porter‑Duff operators in action. Great for game devs.
Toggle content‑visibility: auto on long blocks and see the rendering time difference. Understand this powerful property.
Take a screenshot of the current browser tab using Screen Capture API. Crop, annotate with text and arrows, and download as PNG. Local only.
Fairly distribute pooled tips among staff based on hours worked or points. Customizable percentages. All calculations local and private.
Add many complex CSS styles and measure frames per second. Isolate expensive properties. Practical performance lab.
Configure how your PWA launches: focus existing or create new. Test with the launch_handler manifest field.
Select any HTML element on a page and capture its screenshot. Download as PNG. Perfect for bug reports. JavaScript API demo.
Answer simple questions (braid/mono, hook/swivel) to see the recommended fishing knot with step‑by‑step animation.
Drop files onto a zone and see a preview with name, size, and type. Copy the JavaScript pattern for your site.
Apply content‑visibility: auto to off‑screen sections and see the rendering cost drop. Demos for infinite scroll optimization.
Explore the Mandelbrot set with click-to-zoom and vibrant colors. A mesmerizing math journey inside your browser.
Enter the amount of leftover paint and see how many square feet it still covers. Plan touch-ups.
Pixelate or censor parts of an image by dragging. Adjust block size for mosaic effect. Useful for hiding faces or sensitive data. Client-side processing.
Open a modal and see how focus is trapped and restored. Copy the lightweight focus‑trap code. Accessible pattern.