Options
All
  • Public
  • Public/Protected
  • All
Menu

Alarm type

Hierarchy

  • default

Index

Constructors

  • description

    Constructor of AlarmType

    example
    // Create alarm type
    const customAlarmType = new Stopwatch.AlarmType( "SNAP", ( time, alarmTime ) => {

    // Snap in 0.5 second increments
    return alarmTime - alarmTime % 500;

    } );

    // Alarm occurs after 5 seconds
    stopwatch.setAlarm( 5321, customAlarmType );

    Parameters

    • id: StringOrNumber

      Alarm type id

    • timeCalculator: Function

      function to calculate time

    Returns default

Properties

property

{StringOrNumber} id Alarm type id

timeCalculator: Function
property

{Function} timeCalculator function to calculate time

ABSOLUTE: default = ...
description

This is the default value for the alarm type. Regardless of the elapsed time, the argument value itself is used for the alarm.

RELATIVE: default = ...
description

This is the default value for the alarm type. The time obtained by adding the argument value from the elapsed time becomes the alarm time.

Methods

  • timeCalculation(elapsedTime: number, alarmTime: number): number
  • description

    Calculates and returns the alarm time.

    example
    // Alarm time calculation
    const alarmTime = customAlarmType.timeCalculation( 3000, 3435 );

    Parameters

    • elapsedTime: number

      elapsed time

    • alarmTime: number

      alarm time

    Returns number

    Calculated alarm time

Generated using TypeDoc