-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
871 additions
and
866 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 @@ | ||
export {}; | ||
export {}; |
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 @@ | ||
export declare const fixture = "\n<div id=\"container\">\n <ul>\n <li><a href=\"#content01\">Content 01</a></li>\n <li><a href=\"#content02\">Content 02</a></li>\n <li><a href=\"#content03\">Content 03</a></li>\n <li><a href=\"#content04\">Content 04</a></li>\n <li><a href=\"#content05\">Content 05</a></li>\n <li><a href=\"#footer\">Footer</a></li>\n </ul>\n <section id=\"content01\"><h2>Content 01</h2><a href=\"#\">page top</a></section>\n <section id=\"content02\"><h2>Content 02</h2><a href=\"#\">page top</a></section>\n <section id=\"content03\"><h2>Content 03</h2><a href=\"#\">page top</a></section>\n <section id=\"content04\"><h2>Content 04</h2><a href=\"#\">page top</a></section>\n <section id=\"content05\"><h2>Content 05</h2><a href=\"#\">page top</a></section>\n</div>\n"; | ||
export declare const fixture = "\n<div id=\"container\">\n <ul>\n <li><a href=\"#content01\">Content 01</a></li>\n <li><a href=\"#content02\">Content 02</a></li>\n <li><a href=\"#content03\">Content 03</a></li>\n <li><a href=\"#content04\">Content 04</a></li>\n <li><a href=\"#content05\">Content 05</a></li>\n <li><a href=\"#footer\">Footer</a></li>\n </ul>\n <section id=\"content01\"><h2>Content 01</h2><a href=\"#\">page top</a></section>\n <section id=\"content02\"><h2>Content 02</h2><a href=\"#\">page top</a></section>\n <section id=\"content03\"><h2>Content 03</h2><a href=\"#\">page top</a></section>\n <section id=\"content04\"><h2>Content 04</h2><a href=\"#\">page top</a></section>\n <section id=\"content05\"><h2>Content 05</h2><a href=\"#\">page top</a></section>\n</div>\n"; |
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 @@ | ||
export {}; | ||
export {}; |
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 @@ | ||
export {}; | ||
export {}; |
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 @@ | ||
export interface EasingFunction { | ||
(x: number, t: number, b: number, c: number, d: number, s?: number): number; | ||
} | ||
export interface Easings { | ||
[name: string]: EasingFunction; | ||
} | ||
export declare const easings: Easings; | ||
export interface EasingFunction { | ||
(x: number, t: number, b: number, c: number, d: number, s?: number): number; | ||
} | ||
export interface Easings { | ||
[name: string]: EasingFunction; | ||
} | ||
export declare const easings: Easings; |
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,8 +1,8 @@ | ||
export interface RequestAnimationFrame { | ||
(callback: (time: number) => void): number; | ||
} | ||
export interface CancelAnimationFrame { | ||
(handle: number): void; | ||
} | ||
export declare const raf: RequestAnimationFrame; | ||
export declare const caf: CancelAnimationFrame; | ||
export interface RequestAnimationFrame { | ||
(callback: (time: number) => void): number; | ||
} | ||
export interface CancelAnimationFrame { | ||
(handle: number): void; | ||
} | ||
export declare const raf: RequestAnimationFrame; | ||
export declare const caf: CancelAnimationFrame; |
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,5 +1,5 @@ | ||
import { Offset } from './dom/offsets'; | ||
export interface Coordinate extends Offset { | ||
relative: boolean; | ||
} | ||
export declare const parseCoordinate: (coordinate: any, enableVertical: boolean) => Coordinate | null; | ||
import { Offset } from './dom/offsets'; | ||
export interface Coordinate extends Offset { | ||
relative: boolean; | ||
} | ||
export declare const parseCoordinate: (coordinate: any, enableVertical: boolean) => Coordinate | null; |
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,9 +1,10 @@ | ||
export interface Size { | ||
width: number; | ||
height: number; | ||
} | ||
export declare const getSize: ($el: HTMLElement) => Size; | ||
export declare const getViewportAndElementSizes: ($el: HTMLElement) => { | ||
viewport: Size; | ||
size: Size; | ||
}; | ||
import { ScrollableElement } from 'src/types'; | ||
export interface Size { | ||
width: number; | ||
height: number; | ||
} | ||
export declare const getSize: ($el: HTMLElement) => Size; | ||
export declare const getViewportAndElementSizes: ($el: ScrollableElement) => { | ||
viewport: Size; | ||
size: Size; | ||
}; |
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,5 +1,6 @@ | ||
export interface EventListener { | ||
(e: Event): void; | ||
} | ||
export declare const addEvent: ($el: Element, event: string, listener: EventListener, passive: boolean) => void; | ||
export declare const removeEvent: ($el: Element, event: string, listener: EventListener, passive: boolean) => void; | ||
import { ScrollableElement } from '../types'; | ||
export interface EventListener { | ||
(e: Event): void; | ||
} | ||
export declare const addEvent: ($el: ScrollableElement, event: string, listener: EventListener, passive: boolean) => void; | ||
export declare const removeEvent: ($el: ScrollableElement, event: string, listener: EventListener, passive: boolean) => 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 |
---|---|---|
@@ -1,16 +1,15 @@ | ||
export interface Offset { | ||
top: number; | ||
left: number; | ||
} | ||
export declare type Direction = 'x' | 'y'; | ||
export declare const directionMethodMap: { | ||
y: string; | ||
x: string; | ||
}; | ||
export declare const directionPropMap: { | ||
y: string; | ||
x: string; | ||
}; | ||
export declare const getScroll: ($el: Element, direction: Direction) => number; | ||
export declare const setScroll: ($el: Element, offset: number, direction: Direction) => void; | ||
export declare const getOffset: ($el: Element, $context: Element) => Offset; | ||
import { ScrollableElement } from '../types'; | ||
export interface Offset { | ||
top: number; | ||
left: number; | ||
} | ||
export declare type Direction = 'x' | 'y'; | ||
export declare const directionMethodMap: { | ||
[P in Direction]: 'scrollTop' | 'scrollLeft'; | ||
}; | ||
export declare const directionPropMap: { | ||
[P in Direction]: 'pageXOffset' | 'pageYOffset'; | ||
}; | ||
export declare const getScroll: ($el: ScrollableElement, direction: Direction) => number; | ||
export declare const setScroll: ($el: ScrollableElement, offset: number, direction: Direction) => void; | ||
export declare const getOffset: ($el: Element, $context: ScrollableElement) => Offset; |
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,6 +1,7 @@ | ||
import { Direction } from './offsets'; | ||
export declare const $$: (selector: string) => Element[]; | ||
export declare const $: (selector: string) => Element | null; | ||
export declare const matches: ($el: Element, selector: string | Element) => boolean; | ||
export declare const isRootContainer: ($el: Element) => boolean; | ||
export declare const findScrollable: (selectors: string | Element, direction: Direction) => Element | null; | ||
import { ScrollableElement } from '../types'; | ||
export declare const $$: (selector: string) => Element[]; | ||
export declare const $: (selector: string) => Element | null; | ||
export declare const isElement: (obj: any) => obj is Element; | ||
export declare const isWindow: ($el: ScrollableElement) => $el is Window; | ||
export declare const isRootContainer: ($el: ScrollableElement) => boolean; | ||
export declare const matches: ($el: Element, selector: string | Element) => boolean; |
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,94 +1,95 @@ | ||
import { RequestAnimationFrame, CancelAnimationFrame } from './animation/requestAnimationFrame'; | ||
import { EasingFunction } from './animation/easings'; | ||
import { Offset } from './dom/offsets'; | ||
import { Options, PartialOptions } from './options'; | ||
export { Options, PartialOptions, EasingFunction, Offset, RequestAnimationFrame, CancelAnimationFrame }; | ||
export default class SweetScroll { | ||
/** | ||
* You can set Polyfill (or Ponyfill) for browsers that do not support requestAnimationFrame. | ||
*/ | ||
static raf: RequestAnimationFrame; | ||
static caf: CancelAnimationFrame; | ||
/** | ||
* SweetScroll instance factory. | ||
*/ | ||
static create(options?: PartialOptions, container?: string | Element): SweetScroll; | ||
/** | ||
* Instance properties. | ||
*/ | ||
private opts; | ||
private $el; | ||
private ctx; | ||
/** | ||
* Constructor | ||
*/ | ||
constructor(options?: PartialOptions, container?: string | Element); | ||
/** | ||
* Scroll animation to the specified position. | ||
*/ | ||
to(distance: any, options?: PartialOptions): void; | ||
/** | ||
* Scroll animation to specified left position. | ||
*/ | ||
toTop(distance: any, options?: PartialOptions): void; | ||
/** | ||
* Scroll animation to specified top position. | ||
*/ | ||
toLeft(distance: any, options?: PartialOptions): void; | ||
/** | ||
* Scroll animation to specified element. | ||
*/ | ||
toElement($element: Element, options?: PartialOptions): void; | ||
/** | ||
* Stop the current scroll animation. | ||
*/ | ||
stop(gotoEnd?: boolean): void; | ||
/** | ||
* Update options. | ||
*/ | ||
update(options: PartialOptions): void; | ||
/** | ||
* Destroy instance. | ||
*/ | ||
destroy(): void; | ||
/** | ||
* Callback methods. | ||
*/ | ||
protected onBefore(_: Offset, __: Element | null): boolean | void; | ||
protected onStep(_: number): void; | ||
protected onAfter(_: Offset, __: Element | null): void; | ||
protected onCancel(): void; | ||
protected onComplete(_: boolean): void; | ||
/** | ||
* Start scrolling animation. | ||
*/ | ||
protected start(opts: Options): void; | ||
/** | ||
* Handle each frame of the animation. | ||
*/ | ||
protected loop: (time: number) => void; | ||
/** | ||
* Handle the completion of scrolling animation. | ||
*/ | ||
protected complete(): void; | ||
/** | ||
* Callback function and method call. | ||
*/ | ||
protected hook(options: Options, type: string, ...args: any[]): any; | ||
/** | ||
* Bind events of container element. | ||
*/ | ||
protected bind(click: boolean, stop: boolean): void; | ||
/** | ||
* Unbind events of container element. | ||
*/ | ||
protected unbind(click: boolean, stop: boolean): void; | ||
/** | ||
* Handling of container click event. | ||
*/ | ||
protected handleClick: (e: Event) => void; | ||
/** | ||
* Handling of container stop events. | ||
*/ | ||
protected handleStop: (e: Event) => void; | ||
} | ||
import { RequestAnimationFrame, CancelAnimationFrame } from './animation/requestAnimationFrame'; | ||
import { EasingFunction } from './animation/easings'; | ||
import { Offset } from './dom/offsets'; | ||
import { Options, PartialOptions } from './options'; | ||
import { ScrollableElement } from './types'; | ||
export { Options, PartialOptions, EasingFunction, Offset, RequestAnimationFrame, CancelAnimationFrame, }; | ||
export default class SweetScroll { | ||
/** | ||
* You can set Polyfill (or Ponyfill) for browsers that do not support requestAnimationFrame. | ||
*/ | ||
static raf: RequestAnimationFrame; | ||
static caf: CancelAnimationFrame; | ||
/** | ||
* SweetScroll instance factory. | ||
*/ | ||
static create(options?: PartialOptions, container?: string | ScrollableElement): SweetScroll; | ||
/** | ||
* Instance properties. | ||
*/ | ||
private opts; | ||
private $el; | ||
private ctx; | ||
/** | ||
* Constructor | ||
*/ | ||
constructor(options?: PartialOptions, container?: string | ScrollableElement); | ||
/** | ||
* Scroll animation to the specified position. | ||
*/ | ||
to(distance: any, options?: PartialOptions): void; | ||
/** | ||
* Scroll animation to specified left position. | ||
*/ | ||
toTop(distance: any, options?: PartialOptions): void; | ||
/** | ||
* Scroll animation to specified top position. | ||
*/ | ||
toLeft(distance: any, options?: PartialOptions): void; | ||
/** | ||
* Scroll animation to specified element. | ||
*/ | ||
toElement($element: Element, options?: PartialOptions): void; | ||
/** | ||
* Stop the current scroll animation. | ||
*/ | ||
stop(gotoEnd?: boolean): void; | ||
/** | ||
* Update options. | ||
*/ | ||
update(options: PartialOptions): void; | ||
/** | ||
* Destroy instance. | ||
*/ | ||
destroy(): void; | ||
/** | ||
* Callback methods. | ||
*/ | ||
protected onBefore(_: Offset, __: Element | null): boolean | void; | ||
protected onStep(_: number): void; | ||
protected onAfter(_: Offset, __: Element | null): void; | ||
protected onCancel(): void; | ||
protected onComplete(_: boolean): void; | ||
/** | ||
* Start scrolling animation. | ||
*/ | ||
protected start(opts: Options): void; | ||
/** | ||
* Handle each frame of the animation. | ||
*/ | ||
protected loop: (time: number) => void; | ||
/** | ||
* Handle the completion of scrolling animation. | ||
*/ | ||
protected complete(): void; | ||
/** | ||
* Callback function and method call. | ||
*/ | ||
protected hook(options: Options, type: 'before' | 'after' | 'step' | 'cancel' | 'complete', ...args: any[]): any; | ||
/** | ||
* Bind events of container element. | ||
*/ | ||
protected bind(click: boolean, stop: boolean): void; | ||
/** | ||
* Unbind events of container element. | ||
*/ | ||
protected unbind(click: boolean, stop: boolean): void; | ||
/** | ||
* Handling of container click event. | ||
*/ | ||
protected handleClick: (e: Event) => void; | ||
/** | ||
* Handling of container stop events. | ||
*/ | ||
protected handleStop: (e: Event) => void; | ||
} |
Oops, something went wrong.