ngx-scrollreveal
Version:
Angular directives for ScrollReveal : a JavaScript library for easily animating elements as they enter/leave the viewport.
118 lines (117 loc) • 4.93 kB
TypeScript
import { ElementRef } from '@angular/core';
import { NgsRevealConfig } from './ngs-reveal-config';
import { WindowService } from './window.service';
import { Observable } from 'rxjs';
/**
* Type that represents the target that can be passed to `ScrollReveal().reveal()`.
*/
export declare type NgsRevealTarget = string | HTMLElement | HTMLCollection | Array<any>;
/**
* Basic interface to represent `ScrollReveal` object.
*/
export interface NgsScrollReveal {
/**
* Controls whether or not to output help messages to the console when unexpected things occur at runtime.
*/
debug?: boolean;
/**
* When `ScrollReveal` is instantiated on unsupported or disabled browsers,
* a non-operational instance is created with a `noop` property that returns `true`
*/
noop: boolean;
/**
* Returns the version of `ScrollReveal` currently loaded on the page.
*/
version?: string;
/**
* When non-resetting reveal animations complete, `ScrollReveal` will remove that elements event listeners, generated styles and metadata.
* In some cases (such as asynchronous sequences), you may not want this behavior.
* @param target the related element
*/
clean(target: NgsRevealTarget): void;
/**
* Reverses the effects of all `reveal()` calls, removing all generated styles and event listeners, and clears the `ScrollReveal` store.
*/
destroy(): void;
/**
* Invokes all previous `reveal()` calls (with the appropriate arguments), to capture any new elements added to the DOM.
*/
sync(): void;
/**
* Registers the target element(s) with ScrollReveal, generates animation styles,
* and attaches event listeners to manage when styles are applied.
* @param target element to reveal
* @param options optionbs to use to reveal
* @param syncing whether or not to sync newly added elements (through an asyn call for e.g) with DOM
*/
reveal(target: NgsRevealTarget, options?: NgsRevealConfig, syncing?: boolean): void;
isSupported(): boolean;
}
/**
* Marker interface to indicate that an object (typically `window`) has `scrollreveal` property.
*/
export interface NgsHasScrollReveal {
scrollReveal: NgsScrollReveal;
}
/**
* Service to inject in directives to use ScrollReveal JS.
* It delegates the work to SR, when DOM manipulation is possible (i.e app is not running in a web worker for e.g).
* If not possible, most methods simply do nothing, as DOM elements are not available anyway.
*/
export declare class NgsRevealService {
private sr;
private window;
private config;
private beforeRevealSource;
private afterRevealSource;
private beforeResetSource;
private afterResetSource;
/**
* Observable to subscribe to and get notified before an element is revealed.
*/
beforeReveal$: Observable<HTMLElement>;
/**
* Observable to subscribe to and get notified after an element is revealed.
*/
afterReveal$: Observable<HTMLElement>;
/**
* Observable to subscribe to and get notified before an element is reset.
*/
beforeReset$: Observable<HTMLElement>;
/**
* Observable to subscribe to and get notified after an element is reset.
*/
afterReset$: Observable<HTMLElement>;
constructor(config: NgsRevealConfig, windowService: WindowService);
/**
* Initializes Cookie Consent with the provided configuration.
* @param config the configuration object
*/
init(config: NgsRevealConfig): void;
/**
* Gets the current configuration used by ScrollReveal.
*/
getConfig(): NgsRevealConfig;
/**
* Method to reveal a single DOM element.
* @param elementRef a reference to the element to reveal
* @param config (optional) custom configuration to use when revealing this element
*/
reveal(elementRef: ElementRef<HTMLElement>, config?: NgsRevealConfig): void;
/**
* Method to reveal a set of DOM elements.
* @param parentElementRef the parent DOM element encaspulating the child elements to reveal
* @param selector a list of CSS selectors (comma-separated) that identifies child elements to reveal
* @param interval (optional) interval in milliseconds, to animate child elemnts sequentially
* @param config (optional) custom configuration to use when revealing this set of elements
*/
revealSet(parentElementRef: ElementRef<HTMLElement>, selector: string, interval?: number, config?: NgsRevealConfig): void;
/**
* Method to synchronize and consider newly added child elements (for e.g when child elements were added asynchronously to parent DOM) .
*/
sync(): void;
/**
* Reverses the effects of all `reveal()` calls, removing all generated styles and event listeners, and clears the `ScrollReveal` store.
*/
destroy(): void;
}