Giter VIP home page Giter VIP logo

react-native-shimmer's Introduction

react-native-shimmer

Simple shimmering effect in React Native. Based on Shimmer/shimmer-android.

Shimmer

Installation

yarn add react-native-shimmer
cd ios && pod install
Installation for React Native <= 0.59

Option: With CocoaPods

Add the following to your Podfile and run pod update:

pod 'react-native-shimmer', :path => 'node_modules/react-native-shimmer'

Option: With react-native link

$ react-native link react-native-shimmer

Option: Manually

iOS

Add ios/RNShimmer.xcodeproj to Libraries and add libRNShimmer.a to Link Binary With Libraries under Build Phases. More info and screenshots about how to do this is available in the React Native documentation.

Android

  • Edit android/settings.gradle to look like this (without the +):
rootProject.name = 'MyApp'

include ':app'

+ include ':react-native-shimmer'
+ project(':react-native-shimmer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-shimmer/android')
  • Edit android/app/build.gradle (note: app folder) to look like this:
apply plugin: 'com.android.application'

android {
  ...
}

dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile "com.android.support:appcompat-v7:23.0.1"
  compile "com.facebook.react:react-native:+"  // From node_modules
+ compile project(':react-native-shimmer')
}
  • Edit your MainApplication.java (deep in android/app/src/main/java/...) to look like this (note two places to edit):
package com.myapp;

+ import com.oblador.shimmer.RNShimmerPackage;

....

  @Override
  protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
      new MainReactPackage()
+   , new RNShimmerPackage()
    );
  }

}

Usage

NOTE: Shimmer may only have one child.

import Shimmer from 'react-native-shimmer';

<Shimmer>
  <Text>Loading...</Text>
</Shimmer>;

Properties

Prop Description Default
animating Whether or not to show shimmering effect. true
direction The direction of shimmering animation, valid values are up, down, left, right. right
duration The shimmering animation duration in milliseconds. 1000
pauseDuration The time interval between shimmerings in milliseconds. 400
animationOpacity The opacity of the content while it is shimmering. 1
opacity The opacity of the content before it is shimmering. 0.5
highlightLength The highlight length of shimmering. Range of 0–1. iOS only 1
beginFadeDuration The duration of the fade used when shimmer begins. iOS only 0
endFadeDuration The duration of the fade used when shimmer ends. iOS only 0
tilt The tilt angle of the highlight, in degrees. Android only 0
intensity The intensity of the highlight mask. Range of 0–1. Android only 0

License

MIT License. Shimmer is under BSD license. © Joel Arvidsson 2016 - present

react-native-shimmer's People

Contributors

byohay avatar chaseholland avatar jaredrohe avatar joncursi avatar koox00 avatar oblador avatar silverchen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-shimmer's Issues

Shimmer not working on Android

It works as expected on iOS, but not at all on android. I've tested it on android 8.1 with a Pixel device and also version 9 with a Pixel 2 simulator - neither shimmers.

are the props really work on iOS?

The shimmer with default props is work nicely on both platform. I try to change the duration and pauseDuration props then it's getting weird only on iOS.

"react-native": "0.61.5",
"react-native-shimmer": "^0.6.0",

Shimmer on View IOS vs Android.

Hi all,

The behaviour I am experiencing:
Android only works when the animating props value is constant. animating={true}
IOS only works when the animating value is dynamic. Like connected to redux

This is my Android code setup.

TouchableOpacity  style={styles.buttonFloat} onPress={()=> {}}>
                        <Shimmer>
                        <View  >
                            <Text >{'START MY FIRST PROGRAM'}</Text>
                        </View>
                        </Shimmer>
                    </TouchableOpacity>

This is my IOS setup

TouchableOpacity  style={styles.buttonFloat} onPress={()=> {}}>
                        <Shimmer
                        animating={( this.props.currentScreen=='currentScreen')?true:false}
                         >
                        <View  >
                            <Text >{'START MY FIRST PROGRAM'}</Text>
                        </View>
                        </Shimmer>
                    </TouchableOpacity>

I think its to do with the View

Not working inside Stack Navigator

Shimmer is working fine when I'm rendering the page alone but with createStackNavigator, it's not working.
I'm attaching the screenshots for the two :

  1. When it's working:

screenshot_1549103929

  1. When it's not working:

screenshot_1549103903

I'm using Pixel 2 with API 27, environment : android.

Shimmer not working on IOS RN 0.59.1

IOS compile error
Xcode v 10.1
error: Build input file cannot be found: '........./RN59/node_modules/react-native-shimmer/ios/Shimmer/FBShimmering/FBShimmeringView.m'
any solution?

Shimmer not working on iOS

I am currently working with
"react-native": "0.61.3" and "react-native-shimmer": "^0.6.0".

I have a Shimmer with a nested flatlist inside. For android it works like a charm but for iOS it is not working. Sometimes you can see only a flicker once when it renders, then just no animation, change or opacity, nothing.

<Shimmer >
          <FlatList .../> //Deleted it for simplicity purposes 
</Shimmer>

Shimmer animation stops when button clicked (Android).

Hi. I am using this library to create a shimmering effect for 2 Texts indicating left and right arrows as shown in the screenshot below.

shimmer buttons

The problem is, when the user is clicking on either of the 2 circular buttons (red or green), the shimmer animation on the >>> and the <<< arrows stops. And this is only happening on Android Devices.

Here is the code that I am using for the left red circular icon -

 <SlideButton
                                    onSlideSuccess={this.props.dismissReminder}
                                    slideDirection={SlideDirection.RIGHT}
                                    width={100}
                                    height={50}>
                                    <View style={{flexDirection: 'row', alignItems: 'center'}}>
                                        <View>
                                            <TouchableOpacity onPress={this.props.dismissReminder} style={{
                                                height: 80,
                                                width: 80,
                                                borderRadius: 40,
                                                backgroundColor: 'red',
                                                justifyContent: 'center',
                                                alignItems: 'center'
                                            }}>
                                                <Text style={{fontSize: 50, fontWeight: '400', color: '#fff'}}>X</Text>
                                            </TouchableOpacity>
                                        </View>
                                        <View style={{alignSelf: 'flex-start', paddingTop: 5}}>
                                            <Shimmer direction="right">
                                                <Text
                                                    style={styles.dismissArrow}>
                                                    {'> > > >'}
                                                </Text>
                                            </Shimmer>
                                        </View>
                                    </View>
                                </SlideButton>

Kindly look into this issue and share your inputs. Thanks ! Love the library btw. 👍

Couldn't install pods

I run:
yarn add react-native-shimmer
cd ios && pod install

and the following failure message comes up for pod install:

Analyzing dependencies
[!] Unable to find a specification for `Shimmer (~> 1)` depended upon by `react-native-shimmer`

You have either:
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

Couldn't install Pods. Updating the Pods project and trying again...
Command `pod install` failed.
└─ Cause: Unable to find a specification for `Shimmer (~> 1)` depended upon by `react-native-shimmer`

I also tried:
npx react-native link react-native-shimmer
which gives me a success response, but still no luck.

I have react-native v0.63.4

Shimmer not showing on Interactable.View

Hey there!

I have created a Shimmer component and using it inside and Interactable.View element, and it does not work. Does it work within third party elements or just React Native components?

Shimmer component:

<Shimmer style={styles.shimmerContainer} pauseDuration={0} opacity={0}>
    <Text style={styles.shimmerLoader} />
</Shimmer>

View component:

<Interactable.View>
    <ShimmerCard />
    <View style={cardStyles}>
        {content}
    </View>
</Interactable.View>

React native version 0.59.10
react-native-shimmer version 0.4.1

Exception thrown while executing UI block: Attempted to remove non-existent subview

software-mansion/react-native-reanimated#2554

Description

I am using react-native-shimmer. when I update [email protected] and [email protected] then I am receiving the below error

Exception thrown while executing UI block: Attempted to remove non-existent subview

at

https://github.com/software-mansion/react-native-reanimated/blob/ce76e66aaf47c26bb1ff818d72a50b55e092ca05/ios/LayoutReanimation/REAAnimationsManager.m#L101

because it has conflict with react-native-shimmer

RNShimmeringView.m#L28

Expected behavior

Should not throw the error.

Actual behavior & Steps To Reproduce

Repro: https://github.com/nomi9995/ReproNonExistentsubview
Throws an error but still works if I just close it.

just installed Package versions which I added below.
then below code will reproduce this error

import React, {useState} from 'react';
import {SafeAreaView, StyleSheet, Text, View, Button} from 'react-native';
import Shimmer from 'react-native-shimmer';

const App = () => {
  const [isVisible, setIsVisible] = useState<boolean>(true);

  return (
    <SafeAreaView style={styles.container}>
      {isVisible && (
        <Shimmer>
          <Text>Loading...</Text>
        </Shimmer>
      )}
      <Button
        onPress={() => setIsVisible(!isVisible)}
        title={isVisible ? 'Hide' : 'Visible'}
      />
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});

export default App;

Package versions

  • React Native: ^v0.66.1
  • React Native Reanimated: ^2.3.0-alpha.3
  • react-native-shimmer: ^0.6.0

Affected platforms

  • Android
  • iOS
  • Web

loop prop

hi, did this library support the loop feature? or the duration means the one time duration & it would restart automatically?

Doesn't re-animate when view is re-rendered

When the parent component is re-rendered due to prop change such that we set animating to false, then set it back to true, the Shimmer view won't animate again. It stops the animation fine, but won't restart the animation again.

Not compatible with RN 0.49.1

RN 0.49.1 upgrades react to a 16-beta which removes support for React.PropTypes.

This package still uses React.PropTypes, which breaks the build.

style issue with text

Here's my layout:

<View style={styles.introTextContainer}>
          <Shimmer
            animating={isLoading}
            animationOpacity={0.2}
          >
            <Text style={[styles.text, styles.introText]}>
              Investing with AI.{'\n'}
              Automated. End to End.
            </Text>
          </Shimmer>
          <Shimmer
            animating={isLoading}
            animationOpacity={0.2}
          >
            <Text style={[styles.text, styles.introSubtext]}>
              Portfolios that invest using Artificial Intelligence, Data Science
              and Machine Learning
            </Text>
          </Shimmer>
</View>

& here's the styling:

text: {
    fontSize: 16,
    textAlign: 'center',
    fontWeight: '400',
    margin: 10,
  },
  introTextContainer: {
    flex: 1,
    backgroundColor: 'transparent',
    justifyContent: 'center',
  },
  introText: {
    color: '#FFFFFF',
    fontSize: 28,
    fontWeight: '400',
  },
  introSubtext: {
    color: Colors.lightSecondaryText,
  },

Seems <Shimmer> component somehow screws up the styling of the <Text>. If i encapsulate the text component in a <View> component, the styling works fine but the shimmering stops as mentioned in #1

text not centered here:
screen shot 2017-03-22 at 8 06 05 pm

text centered since encapsulated in a view
screen shot 2017-03-22 at 8 05 27 pm

Shimmer color coming in rounded-radius corner while shimmer

<Shimmer style={{flex: 1,alignSelf: "center", height: 56, width: "90%", borderRadius: 10 ,marginBottom: 16, flexDirection: 'row', backgroundColor: 'red'}}>
<Text style={{ padding: 15, backgroundColor: '#D6D6D6', borderRadius: 10, height: 20}}>rahul pant

"react-native-shimmer": "^0.6.0",
"react-native" : "0.69.8"
"react" : "18.2.0"

shimmer

shimmer

how to remove this corner color

Shimmer has no propType

I come across the problem, like this "Shimmer has no propType for native prop ''RnShimmeringView.onLayout" of native type 'boolean', how to resolve it.

Publish to NPM please

Thank you for your contributions to the open-source community! I noticed changes were made after the last release of v0.6.0. Could you please release the new changes to the NPM registry so versions/changes can be tracked? Thanks!

Doesn't work for <Text> inside <View>

This works with

<Shimmer>
    <Text>Hello</Text>
</Shimmer>

But for any other kind of views, it does not work.
For example, if I have a bunch of texts inside a View, it won't work.

<Shimmer>
    <View>
         <Text>Hello</Text>
         <Text>Hello</Text>
         <Text>Hello</Text>
    </View
</Shimmer>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.