Collective #676




Collective 676 item image

canistilluse.com

Jim Nielsen hopes that browser makers can find a way forward in improving the deficiencies of APIs like alert without setting further precedent that breaking the web is the price of progress.

Read it


Collective 676 item image

Imba

Imba is a programming language for building web applications with insane performance. You can use it both for the server and client. Read the backstory in HN.

Check it out



Collective 676 item image

Pop

Seamless remote pair programming with multiplayer control, crystal-clear voice and high-quality video.

Check it out



Collective 676 item image

Psst

Fast Spotify client with native GUI, without Electron, built in Rust. Very early in development.

Check it out



Collective 676 item image

Alda 101

Alda is a text-based programming language for music composition. It allows you to write and play back music using only a text editor and the command line.

Check it out



Collective 676 item image

Vytal

Vytal shows you what traces your browser leaves behind while surfing the web. This scan allows you to understand how easy it is to identify and track your browser even while using private mode.

Check it out




Collective 676 item image

GitNFT

Autograph and sell your GitHub commits as NFTs. Build your collection and support the contributors you love.

Check it out









Collective 676 item image

On the <dl>

Ben Myers explains why the description list element is underrated and how you can use it.

Read it


The post Collective #676 appeared first on Codrops.

Collective #646








Collective 646 Item Image

How We Improved SmashingMag Performance

In this article, you’ll learn about the changes made on Smashing Magazine — running on JAMStack with React — to optimize the web performance and improve the Core Web Vitals metrics.

Read it













Collective 646 Item Image

Wldlght

Follow an amazing journey in Japan with this projection mapping project, Wldlght.

Check it out






Collective 646 Item Image

Formality

A designless, multistep, conversational, secure, all-in-one WordPress forms plugin.

Check it out





The post Collective #646 appeared first on Codrops.

Awesome Demos Roundup #16

With the fantastic ScrollTrigger plugin that the great folks of GSAP released some time ago, we’ve been blessed with many awesome scroll demos that are nothing short of creativity and that show what cool things are possible by simply scrolling a page. Take a look at these and other playful and inspiring demos; we hope you enjoy this special selection!

Interactive Password Validator

by Eren Guldas

Pure CSS solar system animation in 2D and 3D

by Yan Zhu

T-Shirt Cannon Button

by Jhey Tompkins

Responsive CSS Grid – Books

by Andy Barefoot

Password Reveal

by Mikael Ainalem

deconstructed

by Gerard Ferrandez

Who can get my blood?

by Romina

Balancing Moods

by Chris Gannon

The Oscars 2020

by Robert Borghesi and Valentino Borghesi

3D button

by Robin Delaporte

switch.css

by Sarah Fossheim

Animal Crossing: Isabelle’s Day Off ??(Pure CSS)

by Tee Diang

Painter

by Ricardo Oliva Alonso

Ghost at the Disco – by Anna the Scavenger

by Anna the Scavenger

PureCSS Gaze

By Diana Smith

Single div CSS “Six”

by Lynn Fisher

Water

by Kasper De Bruyne

boids

by Marius Ballot

sphere

by Giulian Drimba

ScrollTrigger Demo

by Mariusz Dabrowski

(v2) Paper plane button

by Aaron Iker

CSS Grid: Newspaper Layout

by Olivia Ng

Bouncing tab bar

by Aaron Iker

CSS Night Train Ride Animation

by Aysenur Turk

Bedroom Construction with threejs + GSAP

by Yiting Liu

Airplanes.

by Steve Gardner

Text Refraction

by Juan Fuentes

GSAP ScrollTrigger on Variable Fonts Perspective

by Pete Barr

Voyage Slider

by Sikriti Dakua

Checkboxes waves

by Louis Hoebregts

CasioPT-1.css

by Sarah Fossheim

2020.06.15

by Ikeda Ryou

slices

by Atrahasis

Little book of GSAP w/ ScrollTrigger

by Jhey Tompkins

ScrollTrigger – Highlight Text

by Ryan Mulligan

Book Store UI

by Aysenur Turk

The post Awesome Demos Roundup #16 appeared first on Codrops.

Awesome Demos Roundup #13

We are very happy to share our latest selection of fantastic web experiments with you! Some beautiful and exciting code gems were created; from realistic objects with pure CSS, to flowy surprises and fun brushes, there’s lots to explore and learn from.

We hope you enjoy this special pick and get inspired!

pullmearound

by Lars Berg

emoji-brush

by Yoksel

Cut/Copy/Paste

by Adam Kuhn

SVG Pattern Doodler

by Niklas Knaack

subscribercoaster

by Adam Kuhn

Physarum-fluid-2

by Domenico Bruzzese

The line game

by Fabio Ottaviani

Shimmery Text w/ SVG + GSAP

by Jhey Tompkins

fireworks

by Magnus Persson

Typo-coaster

by Michelle Barker

2D Fluid Simulation

by Andrés Valencia Téllez

Radio Hopping

by Jon Kantner

Walkers – How to

by Louis Hoebregts

Night at the Museum of Very Good Boys

by Adam Kuhn

3D CSS Kinetic Type Poster

by Pete Barr

noisy-water

by Nathan Taylor

Flowers

by Cassie Evans

VIBES

by Sikriti Dakua

glitchbrush

by Fabio Ottaviani

Pure CSS Glitch Experiment (Twitch Intro WIP)

by Tee Diang

Tabbar animation – Only CSS

by Milan Raring

PPL MVR

by Kristopher Van Sant

Feedback Reactions

by Aaron Iker

HanaGL

by Ryohei Ukon

Band Moiré Filter

by Henry Desroches

Toggles

by Olivia Ng

Night & Day v2

by Steve Gardner

Polaroid Camera In CSS

by Sarah Fossheim

Animating Clip-Path Sections w/ Intersection Observer

by Ryan Mulligan

verlet-motion

by Jordan Machado

Newton’s Light Bulbs

by Jhey Tompkins

rgbKineticSlider

by Hadrien Mongouachon

Flowing Image – How To

by Louis Hoebregts

Zodiac Hustle

by Daniel Long

ogl-hypnose

by Joseph Merdrignac

Awesome Demos Roundup #13 was written by Mary Lou and published on Codrops.

Simulating Mouse Movement

If you've ever had to display an interactive animation during a live talk or a class, then you may know that it's not always easy to interact with your slides and while talking.

This happened to me when I needed to show this particles demo to my students. I didn't want to have to stay next to my computer to move my mouse in order to show off the demo.

See the Pen
Particles (on move)
by Louis Hoebregts (@Mamboleoo)
on CodePen.

If you do not interact with the iframe, you will see nothing but a blank space. As soon as you start moving your mouse or your finger, you can see the animation.

For that reason, I created the same demo but I used some extra code to simulate someone interacting with the demo.

See the Pen
Particles (fake)
by Louis Hoebregts (@Mamboleoo)
on CodePen.

Simplex noise

The trick here is to use an algorithm that will generate "smooth" random positions. If we use a classic random function, the fake mouse will be at a purely random position on every frame. What we want is to have a position on every frame that is directly linked to the previous one. Thankfully, there is a technique that does exactly what we need: Simplex noise (or more commonly known as Perlin noise).

Let's take a look at this image where the height of each column is defined with random values on top, and values from Simplex noise algorithm below.

You can quickly notice that the bottom graph seems much smoother because every column height is connected to the previous one. Those graphs are only showing one dimension (the x-axis, from left to right) but with Simplex noise you can get values in multiples dimensions. In our case, we will need two dimensions for the X and Y coordinates of the fake mouse we're simulating.

If you are more interested to know how Simplex noise works, check out the video "I.5: Perlin Noise - The Nature of Code" by Daniel Shiffman

Get noise coordinates

The first thing we need to make our demo work is to implement a script that generates noise. In my case, I'm using this script by Seph.

Once the noise script is loaded, we can start using it on every frame to make our mouse move.

I will be using an image of a mouse for the demos that I put on position: fixed; with a class .mouse, but you could animate anything else for your own projects.

So, let's take a look at the code:

// We retrieve the image from the DOM
const el = document.querySelector('.mouse');

// The render function is called on every frame
function render (a) {
  // The a variable is the amount of milliseconds since we started our script
  
  // Get a noise value based on the elapsed time to get a new value on every frame
  // This noise algorithm is returning values between [-1, 1] so we need to map them to [0, 1] by adding one to the value and dividing it by 2
  const noiseX = (noise.simplex2(0, a*0.0005) + 1) / 2;
  // We get another noise value for the y axis but because we don't want the same value than x, we need to use another value for the first parameter
  const noiseY = (noise.simplex2(1, a*0.0005) + 1) / 2;
  
  // Convert the noise values from [0, 1] to the size of the window
  const x = noiseX * window.innerWidth;
  const y = noiseY * window.innerHeight;
  
  // Apply the x & y coordinates on our element
  el.style.transform = `translate(${x}px, ${y}px)`;
  
  // Call the render function once the browser is ready to make it an infinite loop
  requestAnimationFrame(render);
}

// Ask the browser to call render to start our animation
requestAnimationFrame(render);

Here is the result we get with the above script:

See the Pen
Virtual user 1
by Louis Hoebregts (@Mamboleoo)
on CodePen.

Allow interactivity

With the current code, we are not allowed to interact with our demo anymore. Let's add a bit more code to use our real mouse position when we interact with the demo and switch back to a fake mouse as soon as we stop.

const el = document.querySelector('.mouse');
let lastMove = 0;

// When the mouse is being moved
function onMouseMove (e) {
  // Get the x and y coordinates
  x = e.clientX;
  y = e.clientY;
  
  // Save the last move time
  lastMove = Date.now();
}

// Update the mouse position based on x & y
function updateMouse (x, y) {
  el.style.transform = `translate(${x}px, ${y}px)`;
}

function render (a) {
  // Check if last move was more than 500ms ago
  if (Date.now() - lastMove > 500) {
    // Generate a fake mouse position
    ...
    updateMouse(x, y);
  }
}

// Listen to mouse events
window.addEventListener('mousemove', onMouseMove);

Now, if you move your mouse, the fake mouse will follow yours. If you stop moving for 500ms, the fake mouse will start moving again.

See the Pen
Virtual user 3
by Louis Hoebregts (@Mamboleoo)
on CodePen.

Customized movement

The speed of the mouse can be updated by changing the value of the third parameter. So far, we are setting this value by taking the elapsed time multiplied by 0.0005, which is equal to a/2000.

// Define a speed ratio
const speed = a * 0.0005;
// Use the speed
const noiseX = (noise.simplex3(1, 0, speed) + 1) / 2;

We can also add a bit more randomness in the changes of direction by adding more noise from its position.

let random = 0;
function render (a) {
  ...
  // Update the random value
  random += 0.1;
  // Compute a x random offset based on the window width
  const randX = noise.simplex3(1, 0, random) * window.innerWidth * 0.1;
  // Compute a y random offset based on the window height
  const randY = noise.simplex3(3, 0, random) * window.innerHeight * 0.1;
  
  // Define the x & y values based on (noise * screen) + randomness
  const x = noiseX * innerWidth + randX;
  const y = noiseY * innerHeight + randY;
  ...
}

Play with the inputs to see how speed and randomly calculated values can influence the fake mouse movement.

See the Pen
Virtual user 4
by Louis Hoebregts (@Mamboleoo)
on CodePen.

More mice

Now that we have created one fake mouse, why not create 500 of them?

See the Pen
Virtual user 5
by Louis Hoebregts (@Mamboleoo)
on CodePen.

I now use this trick for almost all my demos. I think it's really cool to be able to display a project without using a video or being forced to keep moving the mouse randomly while trying to talk about the demo.

If you have any questions or remarks, please leave a comment below or ping me on Twitter.

The post Simulating Mouse Movement appeared first on CSS-Tricks.