Coder Social home page Coder Social logo

Comments (3)

richieteh94 avatar richieteh94 commented on September 16, 2024

I've figured out myself. I add a code block between the stop function in the slotmachine.js
(Added in after the prevent jumping code block)

{
    key: 'stop',
    value: function stop(onStop) {
      var _this4 = this;

      if (!this.running || this.stopping) {
        return this.nextActive;
      }

      this.running = true;
      this.stopping = true;

      if (!Number.isInteger(this.nextActive)) {
        // Get random or custom element
        this.nextActive = this.custom;
      }

      // Check direction to prevent jumping
      if (this._isGoingBackward()) {
        this._resetPosition(this.bounds.firstToLast);
      } else if (this._isGoingForward()) {
        this._resetPosition(this.bounds.lastToFirst);
      }

      // Stop in a goodway <--###  Added code(Start)
      if (this.bounds.key == 'up') {
        this._resetPosition(this.bounds.lastToFirst);
      } else if (this.bounds.key == 'down') {
        this._resetPosition(this.bounds.firstToLast);
      }
      //<--###  Added code(End)

      // Update last choosen element index
      this.active = this.nextActive;

      // Perform animation
      var delay = this._getDelayFromSpins(1);
      // this.delay = delay;
      this._changeTransition(delay);
      this._animationFX = FX_STOP;
      this._changeTransform(this.getTileOffset(this.active));
      raf(function () {
        _this4.stopping = false;
        _this4.running = false;
        _this4.nextActive = null;

        if (typeof _this4.onComplete === 'function') {
          _this4.onComplete(_this4.active);
        }

        if (typeof onStop === 'function') {
          onStop.apply(_this4, [_this4.active]);
        }
      }, delay);

      return this.active;
    }
  }

from jquery-slotmachine.

tedwong avatar tedwong commented on September 16, 2024

@richieteh94 May I know which line of codes?

from jquery-slotmachine.

richieteh94 avatar richieteh94 commented on September 16, 2024

@tedwong I can't access the code, but what i can tell the code is

// Stop in a goodway <--### Added code(Start)
if (this.bounds.key == 'up') {
this._resetPosition(this.bounds.lastToFirst);
} else if (this.bounds.key == 'down') {
this._resetPosition(this.bounds.firstToLast);
}
//<--### Added code(End)

You can see on the above code snippet

from jquery-slotmachine.

Related Issues (20)

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.