Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.

solution difference es5 and es-next #147

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leader-line",
"version": "1.0.5",
"version": "1.1.5",
"title": "LeaderLine",
"description": "Draw a leader line in your web page.",
"keywords": [
Expand All @@ -15,6 +15,7 @@
"svg"
],
"main": "leader-line.min.js",
"types": "types/index.d.ts",
"files": [
"leader-line.min.js",
"bower.json"
Expand Down
9 changes: 9 additions & 0 deletions src/leader-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -5185,3 +5185,12 @@

return LeaderLine;
})();

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global['leader-line'] = factory());
}(this, (function () {
return LeaderLine;
})));

202 changes: 202 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
export as namespace LeaderLine;
export = LeaderLine;

declare namespace LeaderLine {
export type Element = HTMLElement | SVGElement;
export type PlugType = 'disc' | 'square' | 'arrow1' | 'arrow2' | 'arrow3' | 'hand' | 'crosshair' | 'behind';
export type PathType = 'straight' | 'arc' | 'fluid' | 'magnet' | 'grid';
export type SocketType = 'top' | 'right' | 'bottom' | 'left' | 'auto';
export type ShowEffectName = 'none' | 'fade' | 'draw';
export type AreaAnchorShape = 'rect' | 'circle' | 'polygon';

export interface LabelFontOptions {
fontFamily?: any;
fontStyle?: any;
fontVariant?: any;
fontWeight?: any;
fontStretch?: any;
fontSize?: any;
fontSizeAdjust?: any;
kerning?: any;
letterSpacing?: any;
wordSpacing?: any;
textDecoration?: any;
}

export interface Options {
end?: Element | AnchorAttachment;
start?: Element | AnchorAttachment;

size?: number;
color?: string;
path?: PathType;
startSocket?: SocketType;
endSocket?: SocketType;
startSocketGravity?: number | string | Array<string | number>;
endSocketGravity?: number | string | Array<string | number>;

startPlug?: PlugType;
endPlug?: PlugType;
startPlugColor?: string;
endPlugColor?: string;

startPlugSize?: number;
endPlugSize?: number;
outline?: boolean;
outlineColor?: string;
outlineSize?: number;

startPlugOutline?: boolean;
endPlugOutline?: boolean;

startPlugOutlineColor?: string;
endPlugOutlineColor?: string;

startPlugOutlineSize?: number;
endPlugOutlineSize?: number;

startLabel?: string | LeaderLine.LabelAttachment;
middleLabel?: string | LeaderLine.LabelAttachment;
endLabel?: string | LeaderLine.LabelAttachment;

dash?: boolean | DashOptions;
gradient?: boolean | GradientOptions;
dropShadow?: boolean | DropShadowOptions;

show?: boolean;
hide?: boolean;
}

export interface DashOptions {
len?: number | string;
gap?: number | string;

animation?: boolean | AnimationOptions;
}

export interface GradientOptions {
startColor?: string;
endColor?: string;
}

export interface DropShadowOptions {
dx?: number;
dy?: number;
blur?: number;
color?: string;
opacity?: number;
}

export interface AnimationOptions {
timing?: 'ease' | 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | Array<number>;
duration?: number;
}

export interface PointAnchorOptions {
x?: string | number;
y?: string | number;
element?: Element;
}

export interface AreaAnchorOptions {
x?: number | string;
y?: number | string;
shape?: AreaAnchorShape;
width?: number | string;
radius?: number;
height?: number | string;
element?: Element;
points?: Array<[number|string, number|string]>;
color?: string;
fillColor?: string;
size?: number;
dash?: boolean | LeaderLine.DashOptions;
}

export interface MouseHoverAnchorOptions {
element?: Element;
showEffectName?: ShowEffectName,
animOptions?: AnimationOptions,
style?: { [key: string]: any };
hoverStyle?: { [key: string]: any };
onSwitch?: (event: MouseEvent) => any;
}

export interface CaptionLabelOptions extends LabelFontOptions {
text?: string;
offset?: Array<number>;
lineOffset?: number;
color?: string;
outlineColor?: string;
}

export interface PathLabelOptions extends LabelFontOptions {
text?: string;
lineOffset?: number;
color?: string;
outlineColor?: string;
}

export class LabelAttachment { }

export class AnchorAttachment { }

}

declare class LeaderLine {
end: Element | LeaderLine.AnchorAttachment;
start: Element | LeaderLine.AnchorAttachment;
size: number;
color: string;
startSocketGravity: string;
endSocketGravity: string;
startPlugColor: string;
endPlugColor: string;
startPlugSize: number;
endPlugSize: number;
outline: boolean;
outlineColor: string;
outlineSize: number;
startPlugOutline: boolean;
endPlugOutline: boolean;
startPlugOutlineColor: string;
endPlugOutlineColor: string;
startPlugOutlineSize: number;
endPlugOutlineSize: number;
path: LeaderLine.PathType;
startSocket: LeaderLine.SocketType;
endSocket: LeaderLine.SocketType;
startPlug: LeaderLine.PlugType;
endPlug: LeaderLine.PlugType;
dash: boolean | LeaderLine.DashOptions;
gradient: boolean | LeaderLine.GradientOptions;
dropShadow: boolean;
startLabel: string | LeaderLine.LabelAttachment;
endLabel: string | LeaderLine.LabelAttachment;
middleLabel: string | LeaderLine.LabelAttachment;

constructor(options: LeaderLine.Options);
constructor(start: Element | LeaderLine.AnchorAttachment, end: Element | LeaderLine.AnchorAttachment, options?: LeaderLine.Options);

static pointAnchor(options: LeaderLine.PointAnchorOptions): LeaderLine.AnchorAttachment;
static pointAnchor(element: LeaderLine.Element, options?: LeaderLine.PointAnchorOptions): LeaderLine.AnchorAttachment;

static areaAnchor(options: LeaderLine.AreaAnchorOptions): LeaderLine.AnchorAttachment;
static areaAnchor(element: LeaderLine.Element, options?: LeaderLine.AreaAnchorOptions): LeaderLine.AnchorAttachment;
static areaAnchor(element: LeaderLine.Element, shape?: LeaderLine.AreaAnchorShape, options?: LeaderLine.AreaAnchorOptions): LeaderLine.AnchorAttachment;

static mouseHoverAnchor(options: LeaderLine.MouseHoverAnchorOptions): LeaderLine.AnchorAttachment;
static mouseHoverAnchor(element: LeaderLine.Element, showEffectName?: LeaderLine.ShowEffectName, options?: LeaderLine.MouseHoverAnchorOptions): LeaderLine.AnchorAttachment;

static captionLabel(options: any): LeaderLine.LabelAttachment;
static captionLabel(text?: string, options?: any): LeaderLine.LabelAttachment;

static pathLabel(options: LeaderLine.PathLabelOptions): LeaderLine.LabelAttachment;
static pathLabel(text: string, options?: LeaderLine.PathLabelOptions): LeaderLine.LabelAttachment;

hide(showEffectName?: LeaderLine.ShowEffectName, animOptions?: LeaderLine.AnimationOptions): void;
show(showEffectName?: LeaderLine.ShowEffectName, animOptions?: LeaderLine.AnimationOptions): void;
remove(): void;
position(): void;
setOptions(options: LeaderLine.Options): void;
}