It's fun to touch. You can understand by making it. Ideas and ways to make your site more gorgeous. Add playfulness to your screen with CSS, JavaScript, and SVG.
On each page, we will introduce the following steps: ``Moving demo → How to try it → Run it at hand → How it works → Try changing it.'' For those who understand the basics of HTML/CSS and want to try out JavaScript.
If you have some experience with HTML/CSS, start here.
At first, it works without building an environment, just by pressing a button. Open the saved HTML and try changing the touch feel and color.
For a playful CTA. If you transform using transform, the position of the surrounding text will not change. Even if you hit repeatedly, the animation will not overlap.
For feedback on successful operations, such as copy completion. This model only increases the number of marks when you press it, but does not save or send it. There can be up to 6 marks.
status.textContent = 'コピーしました';
None of these demos plays sound. Animations are skipped when your device requests reduced motion.
Trying out a pinch-and-throw physics calculation UI using JavaScript.
Today's topic: accessories on the desk
01 / Pinch
Drag or use the arrow keys to move. Press Enter to jump and Escape to return to the starting position.
Pinch up, down, left and right to make a pop. When you release it, it will fall and bounce on the floor.
Also on keyboard: Select with Tab → Play with arrow keys / Enter
movement recipe
HeavyBouncy
If your device is set to reduce movement, it will stop at the position you release it from.
Behind the scenes of a small device
What creates movement is Weight and bounce.
When you let go, it accelerates due to gravity, and when it hits the floor, it bounces upward. It gradually loses momentum and eventually stops. The higher you lift it, the thinner and smaller the shadow becomes, giving a sense of height.
Pictures are SVG, operations are Pointer Events. You can touch it the same way with your finger or mouse. Falling and bouncing are calculated only while the object is in motion.
Current settings · Implementation excerpt
This excerpt is about the idea of falling and rebounding. The implementation also includes stop judgment, wall repulsion, friction, and drag processing.