All files / src/events stop.js

100% Statements 6/6
50% Branches 1/2
100% Functions 2/2
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69                                                        31x                         1x       1x         1x         1x             31x            
/**
 * Imports the config module
 * @module config
 */
import config from "../config.js";
 
/**
 * Imports the config state module.
 * @module utilities/configState
 */
import ConfigState from "../utilities/configState.js";
 
/**
 * Imports the AmplitudeJS Play Pause Elements
 * @module visual/PlayPauseElements
 */
import PlayPauseElements from "../visual/playPauseElements.js";
 
/**
 * Imports the AmplitudeJS Core Methods
 * @module core/Core
 */
import Core from "../core/core.js";
 
/**
 * Handles all of the stop events
 * @module events/Stop
 */
let Stop = (function() {
  /**
   * Handles an event on a stop element.
   *
   * HANDLER FOR:       class="amplitude-stop"
   *
   * @access public
   */
  function handle() {
    /*
      If touch is not moving, we run. We don't want to accidentally press
      stop if touch is moving.
    */
    Eif (!config.is_touch_moving) {
      /*
				Sets all of the play/pause buttons to pause
			*/
      PlayPauseElements.syncToPause();
 
      /*
				Stops the active song.
			*/
      Core.stop();
 
      /*
        Set the state of the player.
      */
      ConfigState.setPlayerState();
    }
  }
 
  /**
   * Returns public facing methods
   */
  return {
    handle: handle
  };
})();
 
export default Stop;