3.2.38 • Published 4 years ago

postcss-glitch v3.2.38

Weekly downloads
3
License
MIT
Repository
-
Last release
4 years ago

postcss-glitch

Glitch effect implemented with PostCSS. With this plugin you can easily add glitch effect to any text!

npm version CircleCI

animation

Check out our demo page (source)

Installation

yarn add postcss-glitch

You can use .postcssrc.js to add plugin to your project just like this:

// .postcssrc.js

module.exports = {
	plugins: {
		'postcss-import': {},
		'postcss-glitch': {},
		'postcss-url': {},
		autoprefixer: {},
	},
};

Usage

TL;DR

.foo {
  glitch: <height in px | pt | % | em | rem > <first color> <second color> <shadow size>;
}

Guide

  1. Create a positioned element
<div class="wrapper"></div>
.wrapper {
	position: relative;
}
  1. Create element which you want to apply glitch effect
<div class="wrapper">
	<div class="glitch">PostCSS Glitch</div>
</div>
  1. Add data-text attribute to the last created element
<div class="wrapper">
	<div class="glitch" data-text="PostCSS Glitch">PostCSS Glitch</div>
</div>
.wrapper {
	position: relative;
}
.glitch {
	font-weight: 700;
	font-size: 23pt;
	glitch: 42px #f00 #00f 2px;
}

What actually happens?

.glitch {
	font-weight: 700;
	font-size: 23pt;
	glitch: 42px #f00 #00f 2px;
}

transforms to

@keyframes glitch-animation-before {
	0% {
		clip-path: inset(5px 0 32px 0);
	}
	25% {
		clip-path: inset(14px 0 23px 0);
	}
	50% {
		clip-path: inset(15px 0 22px 0);
	}
	75% {
		clip-path: inset(11px 0 26px 0);
	}
	to {
		clip-path: inset(18px 0 19px 0);
	}
}

@keyframes glitch-animation-after {
	0% {
		clip-path: inset(20px 0 17px 0);
	}
	25% {
		clip-path: inset(37px 0 0 0);
	}
	50% {
		clip-path: inset(16px 0 21px 0);
	}
	75% {
		clip-path: inset(20px 0 17px 0);
	}
	to {
		clip-path: inset(17px 0 20px 0);
	}
}

.wrapper {
	position: relative;
}

.glitch {
	font-weight: 700;
	font-size: 23pt;
}

.glitch:after,
.glitch:before {
	content: attr(data-text);
	position: absolute;
	top: 0;
	left: 0;
	overflow: hidden;
	clip-path: inset(42px 0 0 0);
}

.glitch:before {
	text-shadow: -2px 0 #f00;
	animation: glitch-animation-before 3s infinite linear alternate-reverse;
}

.glitch:after {
	text-shadow: 2px 0 #00f;
	animation: glitch-animation-after 2s infinite linear alternate-reverse;
}

And yeah it also works with CSSModules!

Contributing

PR's are welcome 👍

3.2.38

4 years ago

3.2.35

4 years ago

3.2.34

4 years ago

3.2.16

4 years ago

3.2.15

4 years ago

3.2.13

4 years ago

3.2.12

4 years ago

3.2.8

4 years ago

3.2.4

4 years ago

3.2.3

4 years ago

3.2.2

4 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.5

5 years ago

3.1.4

5 years ago

3.1.3

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.10

5 years ago

3.0.9

5 years ago

3.0.8

5 years ago

3.0.7

5 years ago

3.0.6

5 years ago

3.0.5

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

3.0.0-beta.1

5 years ago

3.0.0-alpha.3

5 years ago

3.0.0-alpha.2

5 years ago

3.0.0-alpha.1

5 years ago

2.0.0

5 years ago

2.0.0-beta.5

5 years ago

2.0.0-beta.4

5 years ago

1.1.4

5 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.28

6 years ago

1.0.27

6 years ago

1.0.26

6 years ago

1.0.25

6 years ago

1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago