mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-28 09:25:50 +08:00
NProgress typings
This commit is contained in:
30
nprogress/NProgress-tests.ts
Normal file
30
nprogress/NProgress-tests.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
function test_basics() {
|
||||
NProgress.start();
|
||||
NProgress.inc();
|
||||
NProgress.done();
|
||||
NProgress.set(0.5);
|
||||
|
||||
var status = NProgress.status;
|
||||
var version = NProgress.version;
|
||||
}
|
||||
|
||||
function test_configuration() {
|
||||
NProgress.configure({
|
||||
speed: 0.3
|
||||
});
|
||||
|
||||
NProgress.configure({
|
||||
trickle: false
|
||||
});
|
||||
|
||||
NProgress.configure({
|
||||
ease: 'ease',
|
||||
minimum: 0.09,
|
||||
showSpinner: false,
|
||||
speed: 420,
|
||||
template: "<div>blah</div>",
|
||||
trickle: false,
|
||||
trickleRate: 0.42,
|
||||
trickleSpeed: 42
|
||||
});
|
||||
}
|
||||
99
nprogress/NProgress.d.ts
vendored
Normal file
99
nprogress/NProgress.d.ts
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
// Type definitions for NProgress
|
||||
// Project: https://github.com/rstacruz/nprogress
|
||||
// Definitions by: Judah Gabriel Himango <http://debuggerdotbreak.wordpress.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface NProgressStatic {
|
||||
/**
|
||||
* Shows the progress bar and begins trickling progress.
|
||||
*/
|
||||
start();
|
||||
|
||||
/**
|
||||
* Finishes loading by transitioning it to 100%, then fading out.
|
||||
* @param {boolean} forceShow Forces the progress bar to show, even if it's not being shown. (The default behavior is that .done() will not do anything if .start() isn't called.)
|
||||
*/
|
||||
done(forceShow?: boolean);
|
||||
|
||||
/**
|
||||
* Increments the progress bar with a random amount. This will never get to 100%: use it for every image load (or similar).
|
||||
*/
|
||||
inc();
|
||||
|
||||
/**
|
||||
* Removes the progress indicator.
|
||||
*/
|
||||
remove();
|
||||
|
||||
/**
|
||||
* Sets the progress percentage.
|
||||
* @param {number} progressPercent A number between 0.0 and 1.0 that represents the progress percentage.
|
||||
*/
|
||||
set(progressPercent: number);
|
||||
|
||||
/**
|
||||
* Configures the progress indicator.
|
||||
* @param {NProgressConfigureOptions} options An object containing the configuration options.
|
||||
*/
|
||||
configure(options: NProgressConfigureOptions);
|
||||
|
||||
/**
|
||||
* Gets the NProgress version.
|
||||
*/
|
||||
version: string;
|
||||
|
||||
/**
|
||||
* Gets the status. If started, it will be the last progress number set.
|
||||
*/
|
||||
status: any;
|
||||
|
||||
/**
|
||||
* Gets whether progress has been started.
|
||||
*/
|
||||
isStarted(): boolean;
|
||||
}
|
||||
|
||||
interface NProgressConfigureOptions {
|
||||
|
||||
/**
|
||||
* The minimum progress percentage. Default is 0.08.
|
||||
*/
|
||||
minimum?: number;
|
||||
|
||||
/**
|
||||
* How much to increase per trickle. Example: .02. Default is true.
|
||||
*/
|
||||
trickleRate?: number;
|
||||
|
||||
/**
|
||||
* How often to trickle, in milliseconds. Default is 800.
|
||||
*/
|
||||
trickleSpeed?: number;
|
||||
|
||||
/**
|
||||
* Whether to show the spinner. Defaults to true. Default is true.
|
||||
*/
|
||||
showSpinner?: boolean;
|
||||
|
||||
/**
|
||||
* Whether to enable trickling the progress. Default is true.
|
||||
*/
|
||||
trickle?: boolean;
|
||||
|
||||
/**
|
||||
* The CSS easing animation to use. Default is 'ease'.
|
||||
*/
|
||||
ease?: string;
|
||||
|
||||
/**
|
||||
* The animation speed in milliseconds. Default is 200.
|
||||
*/
|
||||
speed?: number;
|
||||
|
||||
/**
|
||||
* The HTML markup inserted for the progress indicator. To keep the progress bar working, keep an element with role='bar' in there.
|
||||
*/
|
||||
template?: string;
|
||||
}
|
||||
|
||||
declare var NProgress: NProgressStatic;
|
||||
Reference in New Issue
Block a user