Add types for jquery-awesome-cursor (#23311)

This commit is contained in:
Zsolt Kovács
2018-01-31 21:40:26 +01:00
committed by Sheetal Nandi
parent 0b755d302f
commit 00aad235f1
4 changed files with 122 additions and 0 deletions

34
types/jquery-awesome-cursor/index.d.ts vendored Normal file
View File

@@ -0,0 +1,34 @@
// Type definitions for jquery-awesome-cursor 0.3
// Project: https://jwarby.github.io/jquery-awesome-cursor
// Definitions by: Zsolt Kovács <https://github.com/zskovacs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery" />
declare namespace JQueryAwesomeCursor {
type flip = "horizontal" | "vertical" | "both";
type cssHandler = (name: string) => void;
interface Options {
color?: string;
size?: number;
hotspot?: number[] | string;
flip?: flip;
rotate?: number;
outline?: string;
font?: Font;
}
interface Font {
family: string;
cssClass: string | cssHandler;
}
}
interface JQueryStatic {
awesomeCursor(icon: string, options?: JQueryAwesomeCursor.Options): JQuery;
}
interface JQuery {
awesomeCursor(icon: string, options?: JQueryAwesomeCursor.Options): JQuery;
}

View File

@@ -0,0 +1,64 @@
// Default
jQuery.awesomeCursor('pencil');
// Color
jQuery.awesomeCursor('pencil', {
color: '#ff0000'
});
// Size
jQuery.awesomeCursor('pencil', {
size: 32
});
// Hotspot
jQuery.awesomeCursor('pencil', {
hotspot: [0, 17]
});
jQuery.awesomeCursor('pencil', {
hotspot: 'bottom left'
});
// Flip
jQuery.awesomeCursor('pencil', {
flip: 'horizontal'
});
jQuery.awesomeCursor('pencil', {
flip: 'vertical'
});
jQuery.awesomeCursor('pencil', {
flip: 'both'
});
// Rotate
jQuery.awesomeCursor('pencil', {
rotate: 45
});
// Outline
jQuery.awesomeCursor('pencil', {
outline: 'red'
});
// Different font
jQuery.awesomeCursor('brush', {
font: {
family: 'typicons',
cssClass: 'typcn typcn-%s'
}
});
jQuery.awesomeCursor('brush', {
font: {
family: 'typicons',
cssClass: (name) => {
return 'typcn typcn-' + name;
}
}
});
// Mixed
jQuery.awesomeCursor('long-arrow-left', {
color: 'red',
hotspot: 'top left',
rotate: 45,
});

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jquery-awesome-cursor-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }