Module: UI

Contains code to manage the UI (header interactions, buttons, infoText update, etc.).
Author:
  • Radim Brnka
License:
  • MIT
Source:

Members

(static, constant) isAnimationActive

Source:

(inner) headerVisible :boolean

Type:
  • boolean
Source:

Methods

(static) enableMandelbrotMode()

Implemented in a way it's not needed to be called at the first render. Everything should be pre-initialized for Mandelbrot mode.
Source:

(static) getCurrentPaletteId() → {string|null}

Returns the current palette ID from the fractal renderer
Source:
Returns:
Type
string | null

(static) getUserPresets() → {Array.<PRESET>}

Gets user presets from localStorage for current fractal mode
Source:
Returns:
Type
Array.<PRESET>

(static) initUI(fractalRenderer)

Initializes the UI and registers UI event handlers
Parameters:
Name Type Description
fractalRenderer
Source:

(static) resetActivePresetIndex()

This needs to happen on any fractal change
Source:

(static) resetAppState()

Resets buttons, active presets and URL
Source:

(static) showEditCoordsDialog()

Shows the edit coordinates dialog
Source:

(static) showSaveViewDialog()

Shows the save view dialog
Source:

(static) startJuliaDive(dives, index) → {Promise.<void>}

Starts the Julia dive infinite animation
Parameters:
Name Type Description
dives Array.<DIVE>
index number Index of the dive
Source:
Returns:
Type
Promise.<void>

(static) switchFractalMode(mode, presetopt)

Switches among fractal modes
Parameters:
Name Type Attributes Description
mode FRACTAL_TYPE
preset PRESET | MANDELBROT_PRESET | JULIA_PRESET <optional>
If present, it's set as the default state through travelToPreset
Source:

(static) switchFractalTypeWithPersistence(targetType) → {Promise.<void>}

Switches among fractal modes but keeps the c/pan settings so the fractals match each other.
Parameters:
Name Type Description
targetType FRACTAL_TYPE
Source:
Returns:
Type
Promise.<void>

(static) toggleCenterLines()

Toggles x/y axes
Source:

(static) toggleDebugMode()

Inits debug bar with various information permanently shown on the screen
Source:

(static) toggleDemo() → {Promise.<void>}

Turns demo on/off and/or stops current animation
Source:
Returns:
Type
Promise.<void>

(static) toggleHeader(show)

Shows/hides/toggles header.
Parameters:
Name Type Description
show boolean | null Show header? If null, then toggles current state
Source:

(static) travelToPreset(presets, index) → {Promise.<void>}

Travels to preset at given index
Parameters:
Name Type Description
presets Array.<PRESET>
index number Preset array index
Source:
Returns:
Type
Promise.<void>

(static) updateColorTheme(paletteopt)

Updates color scheme
Parameters:
Name Type Attributes Description
palette PALETTE <optional>
defaults to the fractal palette
Source:

(static) updateInfo(force)

Updates the bottom info bar. Throttled to avoid layout thrashing during animations (max ~10 updates/sec).
Parameters:
Name Type Description
force boolean If true, ensures an update is scheduled even if throttled (won't be dropped)
Source:

(static) updatePaletteCycleButtonState()

Updates the palette cycle button state to match the actual cycling state
Source:

(async, inner) applyEditedCoords()

Applies the edited coordinates and animates travel
Source:

(inner) closeDivesDropdown()

Closes the dives dropdown menu
Source:

(inner) closePaletteDropdown()

Closes the palette dropdown menu
Source:

(inner) closePresetsDropdown()

Closes the presets dropdown menu
Source:

(inner) deleteUserPreset(presetId)

Deletes a user preset by its id
Parameters:
Name Type Description
presetId string
Source:

(inner) exitAnimationMode()

Enables controls, resets demo button
Source:

(inner) getUserPresetsKey() → {string}

Gets the localStorage key for user presets based on current fractal mode
Source:
Returns:
Type
string

(inner) hideEditCoordsDialog()

Hides the edit coordinates dialog
Source:

(inner) hideSaveViewDialog()

Hides the save view dialog
Source:

(inner) initAnimationMode()

Disables controls, activates demo button
Source:

(inner) initCommonButtonEvents()

Inits behavior common for all buttons
Source:

(inner) initEditCoordsDialog()

Initializes the edit coordinates dialog events
Source:

(inner) initSaveViewDialog()

Initializes the save view dialog events
Source:

(inner) parseEditCoordsInput() → {Object}

Parses user input from either JSON or individual fields Tries JSON first, then falls back to field-by-field parsing
Source:
Returns:
Parsed coordinates object or {error: string}
Type
Object

(inner) saveCurrentViewAsPreset(name)

Saves the current view as a user preset
Parameters:
Name Type Description
name string The name for the preset
Source:

(inner) saveUserPresets(presets)

Saves user presets to localStorage for current fractal mode
Parameters:
Name Type Description
presets Array.<PRESET>
Source:

(async, inner) startJuliaDemo()

Starts the Julia demo
Source:

(async, inner) startMandelbrotDemo()

Starts the Mandelbrot demo
Source:

(inner) toggleDivesDropdown()

Toggles the dives dropdown menu
Source:

(inner) togglePaletteDropdown()

Toggles the palette dropdown menu
Source:

(inner) togglePresetsDropdown()

Toggles the presets dropdown menu
Source:

(inner) validateEditCoordsInput() → {boolean}

Validates current input and updates UI accordingly
Source:
Returns:
True if valid
Type
boolean