mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
Add definitions for svg-injector
This commit is contained in:
parent
35989a3ab4
commit
899595db5d
22
svg-injector/svg-injector-tests.ts
Normal file
22
svg-injector/svg-injector-tests.ts
Normal file
@ -0,0 +1,22 @@
|
||||
/// <reference path="svg-injector.d.ts" />
|
||||
|
||||
var SVGInjector: SVGInjector;
|
||||
|
||||
// Simple example
|
||||
var mySVGsToInject = document.querySelectorAll('img.inject-me');
|
||||
SVGInjector(mySVGsToInject);
|
||||
|
||||
// Single DOM element
|
||||
SVGInjector(document.querySelector('.inject-me'));
|
||||
|
||||
// Configuration
|
||||
SVGInjector(mySVGsToInject, {
|
||||
evalScripts: 'always',
|
||||
pngFallback: './path/to/images/',
|
||||
each: eachCallback
|
||||
});
|
||||
function eachCallback(element: SVGElement) { }
|
||||
|
||||
// Callback
|
||||
SVGInjector(mySVGsToInject, null, callback);
|
||||
function callback(count: number) { }
|
||||
43
svg-injector/svg-injector.d.ts
vendored
Normal file
43
svg-injector/svg-injector.d.ts
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// Type definitions for SVG Injector
|
||||
// Project: https://github.com/iconic/SVGInjector
|
||||
// Definitions by: Patrick Westerhoff <https://github.com/poke>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare interface SVGInjector {
|
||||
/**
|
||||
* Replace the given elements with their full inline SVG DOM elements.
|
||||
*
|
||||
* @param elements Array of or single DOM element.
|
||||
* @param options Injector options.
|
||||
* @param done Callback that receives the injected element count as parameter.
|
||||
*/
|
||||
(elements: Node | NodeList | Array<Node>, options?: SVGInjectorOptions, done?: (elementCount: number) => void): void;
|
||||
}
|
||||
|
||||
declare interface SVGInjectorOptions {
|
||||
/**
|
||||
* Whether to run scripts blocks found in the SVG.
|
||||
*
|
||||
* Possible values:
|
||||
* 'always' — Run scripts every time.
|
||||
* 'once' — Only run scripts once for each SVG.
|
||||
* 'never' — Ignore scripts (default)
|
||||
*/
|
||||
evalScripts?: string;
|
||||
|
||||
/**
|
||||
* Location of fallback pngs, if desired.
|
||||
*/
|
||||
pngFallback?: string;
|
||||
|
||||
/**
|
||||
* Callback to run during each SVG injection. The SVG element is passed if
|
||||
* the injection was successful.
|
||||
*/
|
||||
each?: (svg: SVGElement | string) => void;
|
||||
}
|
||||
|
||||
declare module "svg-injector" {
|
||||
var SVGInjector: SVGInjector;
|
||||
export = SVGInjector;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user