• Stars
    star
    1,831
  • Rank 25,220 (Top 0.5 %)
  • Language
    CSS
  • License
    Apache License 2.0
  • Created about 4 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

:octocat: Drop-in CSS transitions

Total Downloads Latest Release License Netlify Status

46 pre-built transitions!

Hands on at Codepen or preview all @ transition.style



Basics

Import the CSS and set an attribute on some HTML: try on Codepen

<link rel="stylesheet" href="https://unpkg.com/transition-style">

<div transition-style="in:wipe:up">
  ๐Ÿ‘
</div>


Installation

NPM

  1. npm i transition-style
  2. import from CSS
@import "transition-style";
  1. or import from JS
import 'transition-style';

CDN

https://unpkg.com/transition-style


Individual Category Bundles

  • Circles https://unpkg.com/transition-style/transition.circles.min.css
  • Squares https://unpkg.com/transition-style/transition.squares.min.css
  • Polygons https://unpkg.com/transition-style/transition.polygons.min.css
  • Wipes https://unpkg.com/transition-style/transition.wipes.min.css

Import category bundles from NPM too import "transition-style/transition.circles.min.css"


๐Ÿ‘‰ The Hackpack

https://unpkg.com/transition-style/transition.hackpack.min.css

More options, more control, smaller import
by importing only the custom properties and base styles:

  • compose custom transition combinations
  • create multi-part transitions
  • bring your own architecture with classes or CSS-in-JS or anything!

The Hackpack Sandbox

Custom properties ship with each .min.css as well


๐Ÿ”— Bookmarklet

Try transition.css on almost any existing site! Just copy ๐Ÿ“‹ the following, create a new bookmark, and paste in the URL:

javascript:(function(){var a=document.createElement("link");a.rel="stylesheet";a.href="https://unpkg.com/transition-style";document.head.append(a);})();

You can now go to a website and click the bookmark to try it out! Animations automatically run when you manually add classes in dev tools, or run code like this in the console:

$('body').setAttribute('transition-style','in:circle:bottom-right')

Caveat: this bookmarklet doesn't work on websites that have a strict CSP set up.




Usage

After transition.css has been added to your project, add an attribute to an element and watch the magic:

<div transition-style="in:circle:bottom-right">
  A transitioned IN element
</div>

<div transition-style="out:wipe:down">
  A transitioned OUT element
</div>

if nothing is happening when using the attributes, it's likely transition.css has not loaded


Attributes were chosen as the default so there's no question which transition is active. **There can be only 1 at a time.** With classes, for example, what happens when multiple "transition in" classes are applied to an element? Transition.css chooses to default with a state machine approach so things like a classname collision doesn't need solved. See the [custom](#custom) section below for ways to use classes and/or the shape custom properties so transition.css can fit into your development environment. The built in attribute based approach is very easy to hack, customize and escape.

Using @keyframes

Each bundle ships with the @keyframes declared, and you can use them as you see fit. You can use these to build your own animations or just hook into the presets in your own way:

.main--state-in {
  animation: wipe-in-left;
  animation-duration: 2s;
  animation-fill-mode: both;
}

Checkout the src to find the names of the @keyframe animations. They follow a pattern like the attributes, so you should be able to assume what they are with decent accuracy.


Using CSS Custom Properties

Each bundle ships with clearly named custom properties which contain the state and geometry needed to orchestrate custom transitions.

.overrides {
  --transition__duration: 1s;            /* default: 2.5s */
  --transition__easing: ease-in-out;     /* default: cubic-bezier(.25, 1, .30, 1) */
  --transition__delay: 1s;               /* default: 0 */
}

or target a specific transition and override it's defaults:

[transition="in:wipe:up"] {
  --transition__duration: 1s;
}

Custom

Go off the rails and build your own transitions with these variables. There's even the The Hackpack which is exclusively the custom props ๐Ÿค˜๐Ÿ’€ Here's how you can compose a brand new transition from the custom property primitives:

@keyframes circle-swoop {
  from {
    clip-path: var(--circle-top-right-out);
  }
  to {
    clip-path: var(--circle-bottom-right-in);
  }
}

.--in-custom {
  --transition__duration: 1s;
  --transition__easing: ease-in-out;
  animation-name: circle-swoop;
}

Then, in the HTML:

<div transition-style class="--in-custom">
  A custom transitioned element
</div>

The only rule is that you must transition from the same type of shapes

At this point you're using Transition.css to it's maximum. You can reach a huge set of transitions by using the custom properties. Have fun!

Play

Play and experiment with this Codepen



Development

See the svelte branch.

Production

npm run bundle concurrently bundles and minifies.

More Repositories

1

open-props

CSS custom properties to help accelerate adaptive and consistent design.
HTML
4,604
star
2

gui-challenges

Components from the YouTube show GUI Challenges: accessible, responsive, adaptive and cross browser components.
HTML
2,781
star
3

ragrid

:octocat: Intrinsic first auto-layout flexbox grid
CSS
252
star
4

blingblingjs

๐Ÿ’ฒ Micro-library of shorthands for DOM selection, events, and attribute manipulation
JavaScript
232
star
5

morphull

Astro starter powered by MPA view transitions
Astro
223
star
6

conic.css

nice'n simple conic gradients ๐ŸŽจ
JavaScript
209
star
7

shortstack

๐Ÿฅž minimal Rollup + PostCSS modern syntax starter template
JavaScript
168
star
8

roving-ux

stateful roving index for web ui
JavaScript
129
star
9

scrollyfills

grab and go polyfill functions for web scroll features
JavaScript
102
star
10

ScrollSnapExplainers

89
star
11

slyd

Snappy, responsive, touch optimized, bi-directional presentation framework
CSS
73
star
12

twop

tailwind += open props
TypeScript
51
star
13

vite-postcss-preset-env

HTML
41
star
14

Kung-Fury-Theme

80's dark retro theme for VS Code and Sublime Text
35
star
15

Bolt

โšก is a fast grunt based, data driven, static site seed project, for rapid web development of PWA's or JAMstack projects
HTML
34
star
16

2022-css-day_oh-snap

Astro
28
star
17

Google-IO-2021-Workshop_User-Adaptive-Interfaces

HTML
27
star
18

chat-ui

๐Ÿ’ฌ rich message handling chat interface for bot projects
JavaScript
19
star
19

snowpack-template-preset-env

babel and postcss at latest with browserlist powered preset-env
JavaScript
18
star
20

slyd-starter

clone and go Slyd starter kit
HTML
17
star
21

css-at-cds

links to demo's and docs from our talk at Chrome Dev Summit 2019
HTML
15
star
22

scrollend-explainer

12
star
23

argyleink

11
star
24

houdini-tabs

WIP: scroll-snap-points + ScrollTimeline + Houdini AnimationWorklet
JavaScript
11
star
25

css-n-js

JavaScript
10
star
26

houdini-static-gradient

a houdini paint worklet with a retro static gradient effect
JavaScript
9
star
27

HTML5-ClearUI

Node, Mongo, Zepto, HTML5
JavaScript
8
star
28

Android-Webapp-Boilerplate

The project code needed to make a single webview android app
7
star
29

coinsafe

PWototype demo for JScamp 2019 presentation
HTML
6
star
30

london-css-2020

CSS ๐ŸŽ‰
HTML
5
star
31

jscamp

talk for JScamp 2019 in Barcelona
HTML
5
star
32

NintendoSwitch.tmTheme

๐ŸŽฎ dark theme with bubble gum code highlighting and subdued machine characters for optimal dev focus and nostalgia
4
star
33

JS-Web-App-Starter

Vagrant/Nginx/Express/MySQL/Grunt/Jade/Stylus
CSS
4
star
34

app-img

<app-image> a lazy image loading custom element for considerate user experiences
HTML
4
star
35

Node--Express--and-Socket.io-Starter-Kit

Get started right way with a socket node app. I made this for me, but you can use it too!
JavaScript
4
star
36

iOS-Webview-Boilerplate

Objective-C
3
star
37

browserify-babel

Quickstart for playing with ES6 Babel and Browserify
JavaScript
2
star
38

prefers-reduced-data-explainer

2
star
39

surfin

JavaScript
2
star
40

RxState

๐Ÿ’Š Turn any object or array into a reactive store
JavaScript
2
star
41

2021-csscamp-css-color

HTML
2
star
42

Leap-Motion---Finger-Tracking

JavaScript gesture and pointer following mechanism with CSS
JavaScript
1
star
43

DieAntsDie

ActionScript 3.0 port to Lua
Lua
1
star
44

csscamp

HTML
1
star
45

Greensock-Touch-Carousel

JavaScript
1
star
46

adobe-dreamweaver-fun-cs6-demo

JavaScript
1
star
47

jack

repo for local wordpress build
PHP
1
star
48

N-Gon

Virtualized infinite sided cube, touch enabled bi-directional rotation
JavaScript
1
star
49

PageSlider

A simple library providing hardware accelerated page transitions for Mobile Apps
JavaScript
1
star
50

hd-color-bugs

a stash of issues and bugs found while using new HD color functions in CSS
1
star
51

jQuery-Mobile-Ratio-Boilerplate

JavaScript
1
star
52

Android-Full-Screen-Webview-Seed

Use this for a quick android project that points to your dev environment
Java
1
star
53

affilicats

๐Ÿˆ Progressive Web App demo that showcases flaky network resilience measures (๐Ÿ“ถ or ๐Ÿšซ๐Ÿ“ถ).
JavaScript
1
star
54

parcel-cssNext-esNext

โšก๏ธ Hot load CSS and JS with no state loss, build a site with the powers of Jade
CSS
1
star
55

Parallax-JS

Sideways! Parallax page generator from simple HTML & CSS
JavaScript
1
star
56

bash_profile

Shell
1
star
57

jade-cssnext-babel-webpacked

โšก๏ธ Build a multipage site with Jade and Webpack, where each page is created from a bundle entry file
HTML
1
star