mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-29 00:51:29 +08:00
create() method should accept a parameter of type Element, rather than HTMLElement to work with document.querySelector()
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
/// <reference path="ladda.d.ts" />
|
|
|
|
// Automatically trigger the loading animation on click
|
|
Ladda.bind('input[type=submit]');
|
|
|
|
// Same as the above but automatically stops after two seconds
|
|
Ladda.bind('input[type=submit]', { timeout: 2000 });
|
|
|
|
// Create a new instance of ladda for the specified button
|
|
var l = Ladda.create(document.querySelector('.my-button'));
|
|
|
|
// Start loading
|
|
l.start();
|
|
|
|
// Will display a progress bar for 50% of the button width
|
|
l.setProgress(0.5);
|
|
|
|
// Stop loading
|
|
l.stop();
|
|
|
|
// Toggle between loading/not loading states
|
|
l.toggle();
|
|
|
|
// Check the current state
|
|
l.isLoading();
|
|
|
|
// Test bind
|
|
Ladda.bind('button.ladda-button', { timeout: 42, callback: btn => alert('Clicked!!!') });
|
|
Ladda.bind('button.ladda-button');
|
|
Ladda.bind(document.createElement('button'), {});
|
|
Ladda.bind(document.createElement('button'));
|
|
|
|
// Test stop all
|
|
Ladda.stopAll();
|
|
|
|
// Test create
|
|
var btnElement = document.createElement('button');
|
|
var laddaBtn = Ladda.create(btnElement);
|
|
|
|
// Test operations via chaining
|
|
laddaBtn.start().stop().toggle().setProgress(42).enable().disable().start();
|
|
|
|
// Test isLoading
|
|
console.assert(laddaBtn.isLoading() === true);
|