whitesmith / flooper

Use flex order to create an infinite animated loop of items.
http://whitesmith.github.io/flooper
MIT License
10 stars 2 forks source link

Start stop play slowmotion #9

Closed renatodeleao closed 6 years ago

renatodeleao commented 6 years ago

Fixes #9

This branch is based on a-dev-system and I forgot to squash commits. Help git masters?

tomasmcm commented 6 years ago

@renatodeleao what do you think of this Boolean way of starting/pausing/resuming?

renatodeleao commented 6 years ago

@tomasmcm like the way ya think, slightly disagree on execution of slowmotion methods. I do like boolean flags for the checks, but i don't like the smell of two different methods for a toggle state function :p.

If you're using booleans for pause this.paused why not do the same for slowmotion? also plus 1 for consistency!


constructor{
    ...
    // Flags
    this.paused = false;
    this.slowmotion = false;
}

  /**
   * --------------------
   * ANIMATION
   * --------------------
   */
  slowMotion(){
    this.slowmotion = !this.slowmotion; // toggle if on goes off, if off goes on

    if (this.slowmotion){
        this.speed = this.speed/2;
    } else {
        this.speed = this.lastKnownSpeed; //[1]
    }
  }

// events
 addEvents(){
    this.flooper.addEventListener('mouseenter', this.slowMotion, false);
    this.flooper.addEventListener('mouseleave', this.slowMotion, false);
  }

What do you think? maybe change the method name for checkSlowMotion() or toggleSlowMotion()? or we can leave it as is. Everything else 🎊 !!

(also if you want me to rebase the mess left from the dev env PR, let me know.)

tomasmcm commented 6 years ago

@renatodeleao you're absolutely right, I focused on the play/pause logic and didn't even looked at the slowMotion functions. That's way better, and consistent! I can fix this tomorrow and merge

renatodeleao commented 6 years ago

@tomasmcm I have to rebase this to fix the mess left by the previous PR, so i can update if for you now as i have sublime engine up and running! Thanks for the ✋ !