fawaz-ahmed / react-native-read-more

React native library to show text in a condensed way and expand when needed. Drop in replacement for Text component and highly customizable. Can be used with expo or native cli for react native.
https://www.npmjs.com/package/@fawazahmed/react-native-read-more
MIT License
275 stars 37 forks source link

Allow collapse/expand programatically via prop, keep global animation… #73

Closed fawaz-ahmed closed 1 year ago

fawaz-ahmed commented 1 year ago

… disbaled untill animate true/default is passed

hotaryuzaki commented 1 year ago

so the default value for setLayoutAnimationEnabledExperimental is false? and we have to set animate props to true to change it?

if it so, i think you have to update the docs. because it's stated for the animate props: defaults to true => applies a subtle animation to see more and see less text, not the complete text itself

fawaz-ahmed commented 1 year ago

The logic is that, it will not set setLayoutAnimationEnabledExperimental if you pass animate={false} However, if you dont pass animate prop, it will use default value which is true

hotaryuzaki commented 1 year ago

The logic is that, it will not set setLayoutAnimationEnabledExperimental if you pass animate={false} However, if you dont pass animate prop, it will use default value which is true

oh okay, the default value for setLayoutAnimationEnabledExperimental is true. so we have to set animate props to false to disable it, right?

fawaz-ahmed commented 1 year ago

The logic is that, it will not set setLayoutAnimationEnabledExperimental if you pass animate={false} However, if you dont pass animate prop, it will use default value which is true

oh okay, the default value for setLayoutAnimationEnabledExperimental is true. so we have to set animate props to false to disable it, right?

Yes that is correct

hotaryuzaki commented 1 year ago

The logic is that, it will not set setLayoutAnimationEnabledExperimental if you pass animate={false} However, if you dont pass animate prop, it will use default value which is true

so this package still sets setLayoutAnimationEnabledExperimental to true by default? it does not resolve my problem, because this package sets it for the entire app automatically. I still need to patch this package to fix my issue.

My suggestion is to put setLayoutAnimationEnabledExperimental in the installation setup, so people have discretion to use it based on their needs.

fawaz-ahmed commented 1 year ago

If setting animate={false} by default, it will have 2 issues:

  1. Break backward compatibility
  2. It will be a choice by most of users to have animation enabled by default, since it will be desired in most cases.

Now, for the next part, which is setting setLayoutAnimationEnabledExperimental, it will be needed for animation. So by default it will be needed.

As per my update, if some user decides to not have animation enabled, then user can pass animate={false}. It will disable animation and also not set setLayoutAnimationEnabledExperimental.

hotaryuzaki commented 1 year ago

You are right. I found that native base also set setLayoutAnimationEnabledExperimental (true) Maybe I have to fixed my issues in other way. Thank you for your assistance.

fawaz-ahmed commented 1 year ago

You are right. I found that native base also set setLayoutAnimationEnabledExperimental (true) Maybe I have to fixed my issues in other way. Thank you for your assistance.

You're welcome