forked from ctrl-freaks/freezeframe.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ctrl-freaks#68 from ctrl-freaks/nf/typescript
Port FreezeFrame core to TypeScript
- Loading branch information
Showing
27 changed files
with
12,239 additions
and
8,262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
**/node_modules/** | ||
**/*.min.js |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,18 @@ animate on mouse hover / mouse click / touch event, or manually via class method | |
Version 4.x no longer requires or supports jQuery. If you want to use freezeframe as a jQuery | ||
plugin, check out [freezeframe v3.0.10](https://github.com/ctrl-freaks/freezeframe.js/tree/archived/3.0.10). | ||
|
||
## TypeScript | ||
|
||
Freezeframe is now built in TypeScript! The library will still support usage in JavaScript, but if your project uses TypeScript, you'll have access to Freezeframe's type definitions, improved input validation, and depending on your IDE/text editor, autocompletion/intellisense. | ||
|
||
To get started using the TypeScript beta: | ||
|
||
```sh | ||
npm install [email protected] | ||
``` | ||
|
||
- [Freezeframe.js](#freezeframejs) | ||
- [TypeScript](#typescript) | ||
- [Examples](#examples) | ||
- [Installation](#installation) | ||
- [npm](#npm) | ||
|
@@ -79,7 +90,7 @@ It is also possible to put the `.freezeframe` class on a parent element containi | |
If your environment supports commonjs modules (`require`) or es6 module imports (`import`), you can import freezeframe like so: | ||
|
||
```js | ||
// es6 modules | ||
// es/ts modules | ||
import Freezeframe from 'freezeframe'; | ||
|
||
// or commonjs | ||
|
@@ -120,13 +131,13 @@ logo.toggle(); // toggle animation | |
|
||
- ### ```selector``` | ||
|
||
<code><b>type:</b> string | DOM object</code> | ||
<code><b>type:</b> string | Element | HTMLCollectionOf<Element> | NodeListOf<Element></code> | ||
<code><b>default</b>: ".freezeframe"</code> | ||
|
||
The selector used to search for .gifs to freeze. | ||
Selector may either be passed as the first argument of the Freezeframe constructor, or as a | ||
property of the options object. You may pass a string selector or a DOM reference. If a string | ||
is passed, we use `querySelectorAll`. | ||
property of the options object. You may pass a string selector or a DOM object. If a string | ||
is passed, we use `querySelectorAll` to query for the elements. | ||
|
||
- ### ```trigger``` | ||
|
||
|
@@ -171,7 +182,7 @@ logo.toggle(); // toggle animation | |
// String as selector | ||
new Freezeframe('.foo'); | ||
|
||
// DOM reference as selector | ||
// DOM object as selector | ||
new Freezeframe(document.querySelectorAll('.foo')); | ||
|
||
// Custom options | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
rm ../../docs/index.html | ||
rm ../../docs/freezeframe.min.js | ||
rm -f ../../docs/index.html | ||
rm -f ../../docs/freezeframe.min.js | ||
|
||
cp ./dist/index.html ../../docs/index.html | ||
cp ./dist/freezeframe.min.js ../../docs/freezeframe.min.js |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export declare const classes: { | ||
SELECTOR: string; | ||
CONTAINER: string; | ||
LOADING_ICON: string; | ||
IMAGE: string; | ||
CANVAS: string; | ||
READY: string; | ||
INACTIVE: string; | ||
ACTIVE: string; | ||
CANVAS_READY: string; | ||
RESPONSIVE: string; | ||
OVERLAY: string; | ||
}; | ||
export declare const defaultOptions: { | ||
selector: string; | ||
responsive: boolean; | ||
trigger: string; | ||
overlay: boolean; | ||
warnings: boolean; | ||
}; | ||
export declare const styleId = "ff-styles"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { SelectorOrNodes, Freeze, FreezeframeOptions, RequireProps } from '../types'; | ||
declare class Freezeframe { | ||
#private; | ||
options: FreezeframeOptions; | ||
items: Freeze[]; | ||
$images: HTMLImageElement[]; | ||
private _eventListeners; | ||
private get _stylesInjected(); | ||
constructor(target?: SelectorOrNodes | RequireProps<FreezeframeOptions, 'selector'>, options?: FreezeframeOptions); | ||
private _init; | ||
private _capture; | ||
private _load; | ||
private _setup; | ||
private _wrap; | ||
private _process; | ||
private _ready; | ||
private _attach; | ||
private _addEventListener; | ||
private _removeEventListener; | ||
private _injectStylesheet; | ||
private _emit; | ||
private _toggleOn; | ||
private _toggleOff; | ||
private _toggle; | ||
start(): this; | ||
stop(): this; | ||
toggle(): this; | ||
on(event: string, cb: Function): this; | ||
destroy(): void; | ||
} | ||
export default Freezeframe; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export declare const stylesheet: () => string; | ||
export declare const container: () => string; | ||
export declare const canvas: () => string; | ||
export declare const overlay: () => string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { SelectorOrNodes, FreezeframeOptions } from '../../types/index'; | ||
export declare const pipe: (...fns: Function[]) => (...initArgs: any[]) => any; | ||
export declare const formatMessage: (string: string) => string; | ||
export declare const error: (message: string, ...args: any[]) => void; | ||
export declare const warn: (message: string, ...args: any[]) => void; | ||
export declare const isTouch: () => boolean; | ||
export declare const parseFilename: (filePath: string) => string; | ||
export declare const validateFilename: (filePath: string) => boolean; | ||
export declare const normalizeElements: (selectorOrNodes: SelectorOrNodes) => Element | HTMLCollectionOf<Element> | NodeListOf<Element>; | ||
export declare const validateElements: (elements: Element | Element[], _: any, options: FreezeframeOptions) => any[]; | ||
export declare const dedupeImages: (images: HTMLImageElement[]) => HTMLImageElement[]; | ||
export declare const htmlToNode: (html: string) => HTMLElement; | ||
export declare const wrapNode: ($el: HTMLElement, $wrapper: HTMLElement) => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export declare type RequireProps<T extends {}, K extends keyof T> = Omit<T, K> & { | ||
[MK in K]-?: NonNullable<T[MK]>; | ||
}; | ||
export declare type SelectorOrNodes = string | Element | HTMLCollectionOf<Element> | NodeListOf<Element>; | ||
export declare type TriggerType = string | false; | ||
export declare enum FreezeframeEventTypes { | ||
START = "start", | ||
STOP = "stop", | ||
TOGGLE = "toggle" | ||
} | ||
export interface FreezeframeOptions { | ||
selector?: SelectorOrNodes; | ||
responsive?: boolean; | ||
trigger?: TriggerType; | ||
overlay?: boolean; | ||
warnings?: boolean; | ||
} | ||
export interface Freeze { | ||
$container: HTMLElement; | ||
$canvas: HTMLCanvasElement; | ||
$image: HTMLImageElement; | ||
} | ||
export interface FreezeframeEvent { | ||
$image: HTMLImageElement; | ||
event: string; | ||
listener: EventListenerOrEventListenerObject; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.