question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there any way to transform strings with useTransform?

See original GitHub issue

I didn’t find it anywhere in the docs, so I’m asking it here. How do you combine some CSS filter, for example, invert, with useViewportScroll and useTransform hook? I noticed that you can put only numbers in useTransform and not filter strings like invert(0). When I try to add filters I get:

Error: 'invert(0)' is not an animatable color. Use the equivalent color code instead.

This is code that replicates the error: https://codesandbox.io/s/dry-butterfly-m888o

Is there some alternative to this?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
vassiliskrikoniscommented, Jan 4, 2020

I didn’t find it anywhere in the docs, so I’m asking it here. How do you combine some CSS filter, for example, invert, with useViewportScroll and useTransform hook? I noticed that you can put only numbers in useTransform and not filter strings like invert(0). When I try to add filters I get:

Error: 'invert(0)' is not an animatable color. Use the equivalent color code instead.

This is code that replicates the error: https://codesandbox.io/s/dry-butterfly-m888o

Is there some alternative to this?

@crn1 I made your example work by using the first form of useTransform that takes just a Transformer<T> as a (second) argument

const invertFilter = useTransform(scrollYProgress, v => `invert(${v})`);
0reactions
Acccentcommented, Feb 5, 2020

Hi,

This was closed but the solution is more of a workaround… And the issue also exists with transform(), which doesn’t have the overload which takes a function as a second argument.

The problem seems to be in this file, color.test returns true even when the string doesn’t actually describe a color. I’m not sure how to fix it. Any ideas?

Read more comments on GitHub >

github_iconTop Results From Across the Web

useTransform | Framer for Developers
Create a new motion value that transforms the output of one or more other motion values. useTransform is the primary way to compose...
Read more >
framer-motion
1, import { MotionValue } from "../value";. 2, import { TransformOptions } from "../utils/transform";. 3, export declare type InputRange = number[];.
Read more >
Java String transform() Method: 2 Real-Life Examples
Java String transform() method is used to apply a function to this string. The function should accept a single string argument and return...
Read more >
Framer Motion — Animation Hooks
We can use the useMotionTemplate hook to combine multiple motion values into one using a template string literal. The useTransform hook lets us...
Read more >
How to convert an instance of std::string to lower case
tolower() ), since you need to put the characters in a new string. Would you use transform() and something like std::bind1st( std::mem_fun() )...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found