gilbitron / flexmasonry

A lightweight masonry (cascading grid layout) library powered by flexbox.
https://flexmasonry.now.sh
MIT License
429 stars 24 forks source link

Typescript types #11

Open tremby opened 2 years ago

tremby commented 2 years ago

I'm no expert, and there may be problems with this, but here's what I'm using. It might be a starting point.

type FlexMasonryOptions = {
  responsive?: boolean;
  breakpointCols?: {
    [key: string]: number;
  },
  numCols?: number;
};

declare module 'flexmasonry' {
  function init(targets: string | NodeList, options?: FlexMasonryOptions): this;
  function refresh(target: Element, options?: FlexMasonryOptions): this;
  function refreshAll(options?: FlexMasonryOptions): this;
  function destroyAll(): void;
};
tremby commented 2 years ago

Actually it doesn't seem to be ES6-compatible in the dist version. So I'm declaring and importing flexmasonry/src/flexmasonry.js instead.