Giter Club home page Giter Club logo

animerx's Issues

[fix bug] fix sleep not working properly

Look at the code below, It seems that Sleep did not work as expected

Anime.Play(new Vector3(-5f, 0f, 0f), new Vector3(5f, 0f, 0f), Easing.OutExpo(2f))
    .Sleep(3f)
    .Play(new Vector3(-5f, 0f, 0f), Easing.OutExpo(2f))
    .SubscribeToPosition(cube);

it should have waited here for 1 second after the cube moved to position 5f before moving to position -5. but it will move immediately to position Vector3 (0f, 0f, 0f) and wait for 1 second here then move to position -5, by default (Vector3) returns Vector3.zero

        public static IObservable<T> Sleep<T>(float duration, IScheduler scheduler)
        {
            return SleepInternal(duration, scheduler).Select(_ => default(T));
        }

        public static IObservable<T> Sleep<T>(float duration, T value, IScheduler scheduler)
        {
            return SleepInternal(duration, scheduler).Select(_ => default(T)).Stay(value);
        }

default (T) needs to be replaced

I write it into something like:

        public static IObservable<T> Sleep<T>(float duration, T value)
        {
            return Sleep(duration, value, DefaultScheduler);
        }

        public static IObservable<T> Sleep<T>(float duration, T value, IScheduler scheduler)
        {
            return SleepInternal(duration, scheduler).Select(_ => value);
        }

*Full code

public static partial class Anime
    {
        public static IObservable<Unit> Sleep(float duration)
        {
            return Sleep(duration, DefaultScheduler);
        }

        public static IObservable<Unit> Sleep(float duration, IScheduler scheduler)
        {
            return SleepInternal(duration, scheduler);
        }

        public static IObservable<T> Sleep<T>(float duration, T value)
        {
            return Sleep(duration, value, DefaultScheduler);
        }

        public static IObservable<T> Sleep<T>(float duration, T value, IScheduler scheduler)
        {
            return SleepInternal(duration, scheduler).Select(_ => value);
        }

        public static IObservable<T> Sleep<T>(this IObservable<T> self, float duration)
        {
            return self.Select(x => self.Concat(Sleep(duration, x))).Switch();
        }

        public static IObservable<T> Sleep<T>(this IObservable<T> self, float duration, IScheduler scheduler)
        {
            return self.Select(x => self.Concat(Sleep(duration, x, scheduler))).Switch();
        }

        public static IObservable<T> Sleep<T>(this IObservable<T> self, float duration, T value)
        {
            return self.Concat(Sleep(duration, value));
        }

        public static IObservable<T> Sleep<T>(this IObservable<T> self, float duration, T value, IScheduler scheduler)
        {
            return self.Concat(Sleep(duration, value, scheduler));
        }
    }

Shake or Punch?

Hi, fantastic library, planing to replace the one we use currently with AnimeRx because of great UniRx integration. Question: is the support for "higher level" tweens like Punch or Shake planned?

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.