All files / src/events playbackSpeed.js

100% Statements 11/11
80% Branches 4/5
100% Functions 2/2
100% Lines 11/11
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                                              31x                 9x             9x   4x 4x   3x 3x   2x 2x           9x             31x            
/**
 * Imports the config module
 * @module config
 */
import config from "../config.js";
 
/**
 * Imports the Amplitude Core module
 * @module core/Core
 */
import Core from "../core/core.js";
 
/**
 * Imports the Playback Speed Visual Elements
 * @module visual/PlaybackSpeedElements
 */
import PlaybackSpeedElements from "../visual/playbackSpeedElements.js";
 
/**
 * AmplitudeJS Playback Speed Event Handler
 *
 * @module events/PlaybackSpeed
 */
let PlaybackSpeed = (function() {
  /**
   * Handles an event on the playback speed button
   *
   * HANDLER FOR:       class="amplitude-playback-speed"
   *
   * @access public
   */
  function handle() {
    Eif (!config.is_touch_moving) {
      /*
				We increment the speed by .5 everytime we click
				the button to change the playback speed. Once we are
				actively playing back at 2, we start back at 1 which
				is normal speed.
			*/
      switch (config.playback_speed) {
        case 1:
          Core.setPlaybackSpeed(1.5);
          break;
        case 1.5:
          Core.setPlaybackSpeed(2);
          break;
        case 2:
          Core.setPlaybackSpeed(1);
          break;
      }
 
      /*
				Visually sync the playback speed.
			*/
      PlaybackSpeedElements.sync();
    }
  }
 
  /*
    Returns public facing methods
  */
  return {
    handle: handle
  };
})();
 
export default PlaybackSpeed;