function usePositioner(_ref, deps) {
    var width = _ref.width,
      _ref$columnWidth = _ref.columnWidth,
      columnWidth = _ref$columnWidth === void 0 ? 200 : _ref$columnWidth,
      _ref$columnGutter = _ref.columnGutter,
      columnGutter = _ref$columnGutter === void 0 ? 0 : _ref$columnGutter,
      rowGutter = _ref.rowGutter,
      columnCount = _ref.columnCount

    if (deps === void 0) {
      deps = emptyArr$1
    }

    var initPositioner = function initPositioner() {
      var _getColumns = getColumns(
          width,
          columnWidth,
          columnGutter,
          columnCount
        ),
        computedColumnWidth = _getColumns[0],
        computedColumnCount = _getColumns[1]

      return createPositioner(
        computedColumnCount,
        computedColumnWidth,
        columnGutter,
        rowGutter !== null && rowGutter !== void 0 ? rowGutter : columnGutter
      )
    }

    var positionerRef = React.useRef()
    if (positionerRef.current === undefined)
      positionerRef.current = initPositioner()
    var prevDeps = React.useRef(deps)
    var opts = [width, columnWidth, columnGutter, rowGutter, columnCount]
    var prevOpts = React.useRef(opts)
    var optsChanged = !opts.every(function (item, i) {
      return prevOpts.current[i] === item
    })

    if (typeof process !== 'undefined' && 'production' !== 'production') {
      if (deps.length !== prevDeps.current.length) {
        throw new Error(
          'usePositioner(): The length of your dependencies array changed.'
        )
      }
    } // Create a new positioner when the dependencies or sizes change
    // Thanks to https://github.com/khmm12 for pointing this out
    // https://github.com/jaredLunde/masonic/pull/41

    if (
      optsChanged ||
      !deps.every(function (item, i) {
        return prevDeps.current[i] === item
      })
    ) {
      var prevPositioner = positionerRef.current
      var positioner = initPositioner()
      prevDeps.current = deps
      prevOpts.current = opts

      if (optsChanged) {
        var cacheSize = prevPositioner.size()

        for (var _index = 0; _index < cacheSize; _index++) {
          var pos = prevPositioner.get(_index)
          positioner.set(_index, pos !== void 0 ? pos.height : 0)
        }
      }

      positionerRef.current = positioner
    }

    return positionerRef.current
  }
/**
   * This hook creates the grid cell positioner and cache required by `useMasonry()`. This is
   * the meat of the grid's layout algorithm, determining which cells to render at a given scroll
   * position, as well as where to place new items in the grid.
   *
   * @param options Properties that determine the number of columns in the grid, as well
   *  as their widths.
   * @param deps This hook will create a new positioner, clearing all existing cached positions,
   *  whenever the dependencies in this list change.
   */
This hook creates the grid cell positioner and cache required by `useMasonry()`. This is
the meat of the grid's layout algorithm, determining which cells to render at a given scroll
position, as well as where to place new items in the grid.

@param options Properties that determine the number of columns in the grid, as well
as their widths.
@param deps This hook will create a new positioner, clearing all existing cached positions,
whenever the dependencies in this list change.
This hook creates the grid cell positioner and cache required by ` useMasonry () ` . This is the meat of the grid ' s layout algorithm determining which cells to render at a given scroll position as well as where to place new items in the grid . @param options Properties that determine the number of columns in the grid as well as their widths . @param deps This hook will create a new positioner clearing all existing cached positions whenever the dependencies in this list change .
function usePositioner(_ref, deps) {
    var width = _ref.width,
      _ref$columnWidth = _ref.columnWidth,
      columnWidth = _ref$columnWidth === void 0 ? 200 : _ref$columnWidth,
      _ref$columnGutter = _ref.columnGutter,
      columnGutter = _ref$columnGutter === void 0 ? 0 : _ref$columnGutter,
      rowGutter = _ref.rowGutter,
      columnCount = _ref.columnCount
    if (deps === void 0) {
      deps = emptyArr$1
    }
    var initPositioner = function initPositioner() {
      var _getColumns = getColumns(
          width,
          columnWidth,
          columnGutter,
          columnCount
        ),
        computedColumnWidth = _getColumns[0],
        computedColumnCount = _getColumns[1]
      return createPositioner(
        computedColumnCount,
        computedColumnWidth,
        columnGutter,
        rowGutter !== null && rowGutter !== void 0 ? rowGutter : columnGutter
      )
    }
    var positionerRef = React.useRef()
    if (positionerRef.current === undefined)
      positionerRef.current = initPositioner()
    var prevDeps = React.useRef(deps)
    var opts = [width, columnWidth, columnGutter, rowGutter, columnCount]
    var prevOpts = React.useRef(opts)
    var optsChanged = !opts.every(function (item, i) {
      return prevOpts.current[i] === item
    })
    if (typeof process !== 'undefined' && 'production' !== 'production') {
      if (deps.length !== prevDeps.current.length) {
        throw new Error(
          'usePositioner(): The length of your dependencies array changed.'
        )
      }
    } 
    if (
      optsChanged ||
      !deps.every(function (item, i) {
        return prevDeps.current[i] === item
      })
    ) {
      var prevPositioner = positionerRef.current
      var positioner = initPositioner()
      prevDeps.current = deps
      prevOpts.current = opts
      if (optsChanged) {
        var cacheSize = prevPositioner.size()
        for (var _index = 0; _index < cacheSize; _index++) {
          var pos = prevPositioner.get(_index)
          positioner.set(_index, pos !== void 0 ? pos.height : 0)
        }
      }
      positionerRef.current = positioner
    }
    return positionerRef.current
  }
function usePositioner ( _ref , deps ) { var width = _ref . width , _ref$columnWidth = _ref . columnWidth , columnWidth = _ref$columnWidth === void 0 ? 200 : _ref$columnWidth , _ref$columnGutter = _ref . columnGutter , columnGutter = _ref$columnGutter === void 0 ? 0 : _ref$columnGutter , rowGutter = _ref . rowGutter , columnCount = _ref . columnCount if ( deps === void 0 ) { deps = emptyArr$1 } var initPositioner = function initPositioner ( ) { var _getColumns = getColumns ( width , columnWidth , columnGutter , columnCount ) , computedColumnWidth = _getColumns [ 0 ] , computedColumnCount = _getColumns [ 1 ] return createPositioner ( computedColumnCount , computedColumnWidth , columnGutter , rowGutter !== null && rowGutter !== void 0 ? rowGutter : columnGutter ) } var positionerRef = React . useRef ( ) if ( positionerRef . current === undefined ) positionerRef . current = initPositioner ( ) var prevDeps = React . useRef ( deps ) var opts = [ width , columnWidth , columnGutter , rowGutter , columnCount ] var prevOpts = React . useRef ( opts ) var optsChanged = ! opts . every ( function ( item , i ) { return prevOpts . current [ i ] === item } ) if ( typeof process !== 'undefined' && 'production' !== 'production' ) { if ( deps . length !== prevDeps . current . length ) { throw new Error ( 'usePositioner(): The length of your dependencies array changed.' ) } } if ( optsChanged || ! deps . every ( function ( item , i ) { return prevDeps . current [ i ] === item } ) ) { var prevPositioner = positionerRef . current var positioner = initPositioner ( ) prevDeps . current = deps prevOpts . current = opts if ( optsChanged ) { var cacheSize = prevPositioner . size ( ) for ( var _index = 0 ; _index < cacheSize ; _index ++ ) { var pos = prevPositioner . get ( _index ) positioner . set ( _index , pos !== void 0 ? pos . height : 0 ) } } positionerRef . current = positioner } return positionerRef . current }
This hook creates the grid cell positioner and cache required by `useMasonry()`.
This hook creates the grid cell positioner and cache required by ` useMasonry () ` .
// Create a new positioner when the dependencies or sizes change // Thanks to https://github.com/khmm12 for pointing this out // https://github.com/jaredLunde/masonic/pull/41