Filterizr Documentation

repository·master·Indexed 20 days ago

https://github.com/giotiskl/filterizr

Filterizr is a lightweight JavaScript library and jQuery plugin used to sort, shuffle, search, and apply CSS3-based filters to responsive galleries. Version 2.2.4 supports vanilla JavaScript, CommonJS, and ES6 imports, providing various layout modes such as horizontal, vertical, packed, and same-size arrangements.

Tokens
1.5K
Snippets
8
Records
12
Agent score
71%

What's inside Filterizr

  1. Install Filterizr via npm or yarn

    master

    You can install Filterizr as a dependency using npm or yarn. This provides the main entry point via filterizr.min.js in the ./dist/ directory, which supports CommonJS and ES6 imports.

    npm install filterizr
    yarn add filterizr
  2. Register Filterizr as a jQuery plugin in npm projects

    master

    If you are using npm/yarn and want to use Filterizr as a jQuery plugin, import both jquery and filterizr, then call the static method Filterizr.installAsJQueryPlugin passing the jQuery instance. This extends the $.fn prototype.

    import $ from 'jquery';
    import Filterizr from 'filterizr';
    
    // This will extend the $.fn prototype with Filterizr
    Filterizr.installAsJQueryPlugin($);
    
    $('.filter-container').filterizr('filter', 5); // or any other Filterizr API call
  3. Reference Filterizr distribution files

    master

    The following files are available in the ./dist/ directory:

    • filterizr.min.js: The pure Filterizr JavaScript library (main entry point for npm/ES6/CommonJS).
    • vanilla.filterizr.min.js: Distribution for direct use in <script> tags (exposes global Filterizr).
    • jquery.filterizr.min.js: Distribution for use as a jQuery plugin (extends global jQuery and exposes vanilla Filterizr as a global).
  4. Initialize Filterizr using the default export

    master

    Filterizr is a JavaScript library for sorting, shuffling, and applying CSS3 filters to responsive galleries. You can use the library by importing the default export from the filterizr package and instantiating it with a target container and an options object.

    import Filterizr from 'filterizr';
    
    const filterizr = new Filterizr({
      // options
    }, '#gallery-container');
  5. Initialize Filterizr via the default export

    master

    The Filterizr class is the primary entrypoint for the library. It is exported as the default export from the package. You can import it to initialize and control your image gallery.

    To use it, import the default export and instantiate it with a selector for your gallery container.

    import Filterizr from 'filterizr';
    
    const filterizr = new Filterizr({
      // configuration options go here
    });
  6. Filterizr Core Configuration and State Interfaces

    master

    Filterizr uses a set of TypeScript interfaces to define the configuration options and internal state of the library. When extending or using the library, you will interact with these primary types:

    • Options: The main configuration object for a Filterizr instance.
    • BaseOptions: The foundational configuration properties shared across different Filterizr implementations.
    • RawOptions: A lower-level configuration type, often used when bypassing certain abstractions.
    • RawOptionsCallbacks: Defines the callback functions available within the RawOptions configuration.
    • ContainerLayout: Defines how the container holding the items is laid out.
    • Dimensions: Represents width and height measurements.
    • Position: Represents coordinate data (x, y).
    • SpinnerOptions: Configuration for the loading spinner component.
    • Dictionary: A generic key-value mapping type used within the library.

    Other utility interfaces include Destructible (for objects that can be cleaned up), Resizable (for objects with size-change capabilities), and Styleable (for objects that support CSS styling).

  7. Understand FilterizrState values

    master

    The FilterizrState type represents the current operational state of the Filterizr instance. It can be one of the following four values:

    • 'IDLE': The instance is inactive or waiting for input.
    • 'FILTERING': The instance is currently executing a filtering operation.
    • 'SORTING': The instance is currently executing a sorting operation.
    • 'SHUFFLING': The instance is currently executing a shuffling operation.
    export type FilterizrState = 'IDLE' | 'FILTERING' | 'SORTING' | 'SHUFFLING';
  8. Configure Layout options

    master

    The Layout type defines the available arrangement strategies for the items in the grid. When initializing or updating Filterizr, you can choose from the following layout modes:

    • 'horizontal': Items are arranged horizontally.
    • 'vertical': Items are arranged vertically.
    • 'sameHeight': Items are aligned to have the same height.
    • 'sameWidth': Items are aligned to have the same width.
    • 'sameSize': Items are aligned to have the same dimensions (width and height).
    • 'packed': Items are arranged in a packed/masonry-style layout.
    export type Layout =
      | 'horizontal'
      | 'vertical'
      | 'sameHeight'
      | 'sameWidth'
      | 'sameSize'
      | 'packed';