项目作者: sakalx

项目描述 :
React Glitch effects
高级语言: JavaScript
项目地址: git://github.com/sakalx/react-glitch-effect.git
创建时间: 2018-09-23T11:44:40Z
项目社区:https://github.com/sakalx/react-glitch-effect

开源协议:MIT License

下载


React glitch-effect-components


DEMO



Squiggly Glitch Component

import GlitchSquiggly from 'react-glitch-effect/core/GlitchSquiggly';

Props

Name Type Default
disabled boolean false
duration string 3s
iterationCount string infinite
onHover boolean false
baseFrequency number 0.02
scaleNoise number 5


Example Squiggly glitch effect component

  1. import React, { useState } from 'react';
  2. import GlitchSquiggly from 'react-glitch-effect/core/GlitchSquiggly';
  3. const MyComponent = () => {
  4. const [isDisabled, setDisabled] = useState(false);
  5. const handleToggleGlitch = () => {
  6. setDisabled(!isDisabled);
  7. };
  8. return (
  9. <div>
  10. <button onClick={handleToggleGlitch}>TOGGLE EFFECT</button>
  11. <GlitchSquiggly disabled={isDisabled}>
  12. <h1>GlitchSquiggly</h1>
  13. </GlitchSquiggly>
  14. </div>
  15. )
  16. };


Clip Glitch Component

import GlitchClip from 'react-glitch-effect/core/GlitchClip';

Props

Name Type Default
disabled boolean false
duration string 3s
iterationCount string infinite
onHover boolean false


Example Clip glitch effect component

  1. import React from 'react';
  2. import GlitchClip from 'react-glitch-effect/core/GlitchClip';
  3. const MyComponent = () => {
  4. return (
  5. <GlitchClip>
  6. <h1>Glitch</h1>
  7. </GlitchClip>
  8. )
  9. }

Manually trigger example Clip glitch effect component

  1. import React, {useState} from 'react';
  2. import GlitchClip from 'react-glitch-effect/core/Clip';
  3. const MyComponent = () => {
  4. const [isDisabled, setDisabled] = useState(false);
  5. const handleToggleGlitch = () => {
  6. setDisabled(!isDisabled);
  7. };
  8. return (
  9. <div>
  10. <button onClick={handleToggleGlitch}>TOGGLE EFFECT</button>
  11. <GlitchClip disabled={isDisabled}>
  12. <h1>Glitch</h1>
  13. </GlitchClip>
  14. </div>
  15. )
  16. };

Example Clip glitch effect with on hover

  1. import React from 'react';
  2. import GlitchClip from 'react-glitch-effect/core/Clip';
  3. const MyComponent = () => {
  4. return (
  5. <GlitchClip onHover={true}>
  6. <h1>Glitch</h1>
  7. </GlitchClip>
  8. )
  9. }


Text Glitch Component

import GlitchText from 'react-glitch-effect/core/GlitchText';

Props

Name Type Default
component string span
color1 string rgba(77, 171, 245, .5)
color2 string rgba(245, 0, 87, .3)
disabled boolean false
duration string 2s
iterationCount string infinite
onHover boolean false


Example Text glitch effect component

  1. import React, {useState} from 'react';
  2. import GlitchText from 'react-glitch-effect/core/GlitchText';
  3. const MyComponent = () => {
  4. const [isDisabled, setDisabled] = useState(false);
  5. const handleToggleGlitch = () => {
  6. setDisabled(!isDisabled);
  7. };
  8. return (
  9. <div>
  10. <button onClick={handleToggleGlitch}>TOGGLE EFFECT</button>
  11. <GlitchText component='h1' disabled={isDisabled}>
  12. Glitch
  13. </GlitchText>
  14. </div>
  15. )
  16. };