Convert Figma logo to code with AI

facebookarchive logorebound

A Java library that models spring dynamics and adds real world physics to your app.

5,436
819
5,436
31

Top Related Projects

Spring dynamics in JavaScript.

✌️ A spring physics based React animation library

A spring that solves your animation problems.

49,575

JavaScript animation engine

19,483

GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web

19,945

Simple animation libraries for delightful user interfaces

Quick Overview

Rebound is a Java library that models spring dynamics. It provides a powerful and flexible animation system for creating realistic, physics-based animations in Android applications. The library simulates the behavior of springs, allowing developers to create smooth and natural-looking motion effects.

Pros

  • Easy to integrate into Android projects
  • Provides a realistic physics-based animation system
  • Highly customizable with various spring configurations
  • Lightweight and efficient, suitable for mobile applications

Cons

  • Limited to spring-based animations
  • Requires understanding of spring physics concepts
  • May have a learning curve for developers new to physics-based animations
  • Not actively maintained (archived repository)

Code Examples

  1. Creating a simple spring animation:
Spring spring = new Spring();
spring.setEndValue(1);

spring.addListener(new SimpleSpringListener() {
    @Override
    public void onSpringUpdate(Spring spring) {
        float value = (float) spring.getCurrentValue();
        view.setScaleX(value);
        view.setScaleY(value);
    }
});
  1. Configuring spring properties:
Spring spring = new Spring();
spring.setSpringConfig(new SpringConfig(tension, friction));
spring.setVelocity(5);
spring.setEndValue(1);
  1. Chaining multiple springs:
SpringChain chain = SpringChain.create();

for (int i = 0; i < 5; i++) {
    final int index = i;
    chain.addSpring(new SimpleSpringListener() {
        @Override
        public void onSpringUpdate(Spring spring) {
            float value = (float) spring.getCurrentValue();
            views[index].setTranslationY(value);
        }
    });
}

chain.setControlSpringIndex(0);
chain.getControlSpring().setEndValue(200);

Getting Started

To use Rebound in your Android project:

  1. Add the dependency to your build.gradle file:
dependencies {
    implementation 'com.facebook.rebound:rebound:0.3.8'
}
  1. Create a Spring object and configure it:
Spring spring = new Spring();
spring.setEndValue(1);

spring.addListener(new SimpleSpringListener() {
    @Override
    public void onSpringUpdate(Spring spring) {
        float value = (float) spring.getCurrentValue();
        // Use the value to animate your view
    }
});
  1. Start the animation by calling spring.setEndValue() with the desired final value.

Competitor Comparisons

Spring dynamics in JavaScript.

Pros of rebound-js

  • JavaScript implementation allows for easier integration with web projects
  • Can be used in both browser and Node.js environments
  • Provides a more familiar API for JavaScript developers

Cons of rebound-js

  • May have slightly lower performance compared to the Java-based rebound
  • Limited to JavaScript ecosystem, while rebound can be used in Android development
  • Potentially smaller community and fewer resources due to being a port

Code Comparison

rebound (Java):

Spring spring = new Spring(springSystem)
    .setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(40, 3))
    .addListener(new SimpleSpringListener() {
        @Override
        public void onSpringUpdate(Spring spring) {
            // Update UI here
        }
    });

rebound-js (JavaScript):

const spring = springSystem.createSpring()
    .setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(40, 3))
    .addListener({
        onSpringUpdate: (spring) => {
            // Update UI here
        }
    });

Both libraries provide similar APIs for creating and configuring springs, with syntax differences reflecting their respective languages. The JavaScript version offers a more concise callback syntax using arrow functions.

✌️ A spring physics based React animation library

Pros of react-spring

  • Specifically designed for React, offering seamless integration with React components
  • Provides a more declarative API, making it easier to create complex animations
  • Supports server-side rendering and native platforms through React Native

Cons of react-spring

  • Steeper learning curve for developers not familiar with React ecosystem
  • May have a larger bundle size due to its React-specific features

Code Comparison

react-spring:

import { useSpring, animated } from 'react-spring'

function AnimatedComponent() {
  const props = useSpring({ opacity: 1, from: { opacity: 0 } })
  return <animated.div style={props}>I will fade in</animated.div>
}

rebound:

const spring = new rebound.Spring()
spring.setCurrentValue(0).setEndValue(1)
spring.addListener({
  onSpringUpdate: (spring) => {
    const value = spring.getCurrentValue()
    element.style.opacity = value
  }
})

Summary

react-spring is tailored for React applications, offering a more declarative and React-friendly API. It provides better integration with React components and supports server-side rendering. However, it may have a steeper learning curve for non-React developers and a larger bundle size. rebound, on the other hand, is more lightweight and framework-agnostic but requires more manual setup for animations.

A spring that solves your animation problems.

Pros of react-motion

  • Specifically designed for React applications, providing seamless integration
  • Uses a more declarative API, making it easier to understand and maintain
  • Offers better performance optimization for React components

Cons of react-motion

  • Limited to React ecosystem, not suitable for non-React projects
  • Steeper learning curve for developers unfamiliar with React concepts
  • May have slightly more overhead due to React-specific implementation

Code Comparison

react-motion:

import { Motion, spring } from 'react-motion';

<Motion defaultStyle={{x: 0}} style={{x: spring(10)}}>
  {({x}) => <div style={{transform: `translateX(${x}px)`}} />}
</Motion>

rebound:

Spring spring = springSystem.createSpring();
spring.setEndValue(1);

spring.addListener(new SimpleSpringListener() {
  @Override
  public void onSpringUpdate(Spring spring) {
    float value = (float) spring.getCurrentValue();
    // Use value to update UI
  }
});

Summary

react-motion is tailored for React applications, offering a more declarative API and better performance optimization. However, it's limited to the React ecosystem and may have a steeper learning curve. rebound, on the other hand, is more versatile and can be used in various environments but lacks React-specific optimizations. The choice between the two depends on the project requirements and the development team's familiarity with React concepts.

49,575

JavaScript animation engine

Pros of Anime

  • Lightweight and flexible JavaScript animation library
  • Supports a wide range of animation properties and easing functions
  • Easy to use with a chainable API and timeline feature

Cons of Anime

  • Limited to web-based animations (JavaScript)
  • May require more manual setup for complex animations
  • Less optimized for mobile performance compared to native solutions

Code Comparison

Anime:

anime({
  targets: '.element',
  translateX: 250,
  rotate: '1turn',
  duration: 800,
  easing: 'easeInOutQuad'
});

Rebound:

Spring spring = springSystem.createSpring();
spring.setEndValue(1);
spring.addListener(new SimpleSpringListener() {
  @Override
  public void onSpringUpdate(Spring spring) {
    float value = (float) spring.getCurrentValue();
    view.setScaleX(value);
    view.setScaleY(value);
  }
});

Key Differences

  • Anime is JavaScript-based, while Rebound is primarily for Android
  • Rebound focuses on spring animations, Anime offers a broader range of animation types
  • Anime provides a more declarative API, Rebound uses a more imperative approach
  • Rebound is optimized for mobile performance, Anime is more versatile for web applications
19,483

GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web

Pros of GSAP

  • More comprehensive animation toolkit with a wider range of features
  • Extensive documentation and community support
  • Cross-browser compatibility and performance optimization

Cons of GSAP

  • Larger file size and potential overhead for simpler projects
  • Steeper learning curve due to its extensive feature set

Code Comparison

GSAP:

gsap.to(".box", {duration: 1, x: 100, y: 50, rotation: 360});

Rebound:

const spring = new rebound.Spring(1, 100);
spring.addListener({
  onSpringUpdate: (spring) => {
    target.style.transform = `translateX(${spring.getCurrentValue()}px)`;
  }
});

Summary

GSAP offers a more comprehensive animation toolkit with extensive features and support, making it suitable for complex projects. However, it may be overkill for simpler animations. Rebound, on the other hand, focuses specifically on spring animations, providing a lightweight solution for physics-based interactions. The choice between the two depends on the project's requirements and complexity.

19,945

Simple animation libraries for delightful user interfaces

Pros of Popmotion

  • More comprehensive animation library with a wider range of features
  • Active development and maintenance
  • Better documentation and community support

Cons of Popmotion

  • Steeper learning curve due to more complex API
  • Larger file size, which may impact performance in some cases

Code Comparison

Rebound:

const spring = rebound.createSpring(40, 3);
spring.addListener({
  onSpringUpdate: (spring) => {
    const value = spring.getCurrentValue();
    // Use the value to update UI
  }
});
spring.setEndValue(1);

Popmotion:

import { spring } from 'popmotion';

spring({
  from: 0,
  to: 1,
  stiffness: 100,
  damping: 10
}).start((value) => {
  // Use the value to update UI
});

Summary

Popmotion offers a more feature-rich animation library with active development and better documentation. However, it may have a steeper learning curve and larger file size compared to Rebound. Rebound provides a simpler API focused on spring animations, while Popmotion offers a wider range of animation types and more customization options. The choice between the two depends on the specific project requirements and the developer's familiarity with each library.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Rebound

Build Status Android Arsenal

About

Rebound is a java library that models spring dynamics. Rebound spring models can be used to create animations that feel natural by introducing real world physics to your application.

Rebound is not a general purpose physics library; however, spring dynamics can be used to drive a wide variety of animations. The simplicity of Rebound makes it easy to integrate and use as a building block for creating more complex components like pagers, toggles, and scrollers.

For examples and usage instructions head over to:

facebook.github.io/rebound

If you are looking to build springy animations for the web, check out the Javascript version.

License

BSD License

For Rebound software

Copyright (c) 2013, Facebook, Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

NPM DownloadsLast 30 Days