-
I'm not even sure how to title it properly, but the issue is showcased in the video below. Error.mp4It breaks on this section:
I'm calling it in my code like this:
usage:
I'd love to get some help with this because I loved the effect, and if I can't fix it, unfortunately I'd have to remove it from the project :\ |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hey there @Ashlc , there are a few things to consider here:
I think this code should do what you want: import { useGlitch } from "react-powerglitch";
// [..]
function Handler() {
// [..]
const glitch = useGlitch({
playMode: "manual",
timing: {
duration: 1000,
iterations: 1,
},
glitchTimeSpan: {
start: 0.0,
end: 0.4,
},
});
// [..]
const miss = () => {
glitch.startGlitch();
// [..]
};
// [..]
return (
// [..]
<p className="nes-text title" ref={glitch.ref}>...</p>
// [..]
);
} Demo (I've cloned your project to try): use-glitch.mp4Hope this helps |
Beta Was this translation helpful? Give feedback.
-
I would like to retract one point from my original response, for anyone that would end up reading this discussion:
Since |
Beta Was this translation helpful? Give feedback.
Hey there @Ashlc , there are a few things to consider here:
You are not supposed to call
PowerGlitch.glitch(..)
multiple times, in general - I think that's what's causing the error hereIn your case, as you are using
iterations: 1
, callingstartGlitch(..)
will only play the animation once, so there's no need to callstopGlitch(..)
(General advice) You should restrict to glitching small elements, because glitching relies on cloning DOM nodes. If you are trying to glitch the whole
<body />
, I expect you'll encounter visual artefacts at best, errors at worst, especially if used with a frameworkSince you are using React, you should probably take a look at the React wrapper,
react-pow…