Skip to content

feat: autoStop, onThreshold callbacks, and progress label #39

@franverona

Description

@franverona

Overview

Three related enhancements to improve progress control and visual feedback.


autoStop

A new boolean option that automatically calls stop() when setprogress(100) is reached, removing boilerplate users currently wire up manually.

Proposed API:

// Vanilla
Loadgo.init(el, { autoStop: true })

// jQuery
$('#logo').loadgo({ autoStop: true })

onThreshold

A new option that fires callbacks when progress crosses specific threshold values. Useful for multi-stage loading UIs (e.g. showing a message at 50%, unlocking a button at 100%).

Thresholds should only fire once per crossing (not on every setprogress call while above the value).

Proposed API:

Loadgo.init(el, {
  onThreshold: {
    50: () => console.log('halfway there'),
    75: () => console.log('almost done'),
    100: () => console.log('complete'),
  }
})

Progress label

A new option to display the current progress percentage as text inside the overlay. Should support a configurable template string.

Proposed API:

Loadgo.init(el, {
  showLabel: true,
  labelTemplate: '{progress}%',  // default
})

The label element should be styled to be centered over the overlay and excluded when filter mode is active (since there is no overlay in that case).


Notes

  • All three options should be supported in both loadgo.js (jQuery) and loadgo-vanilla.js.
  • onThreshold composes naturally with the custom events work currently in progress.
  • autoStop and the 100 threshold in onThreshold are complementary but independent — both can be used together.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions