How to use the throttle-debounce/debounce function in throttle-debounce

To help you get started, we’ve selected a few throttle-debounce examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zhjing1019 / elementParse / packages / table / src / table-store.js View on Github external
selection: [],
    reserveSelection: false,
    selectable: null,
    currentRow: null,
    hoverRow: null,
    filters: {},
    expandRows: [],
    defaultExpandAll: false,
    selectOnIndeterminate: false,
    treeData: {},
    indent: 16,
    lazy: false,
    lazyTreeNodeMap: {}
  };

  this._toggleAllSelection = debounce(10, function(states) {
    const data = states.data || [];
    if (data.length === 0) return;
    const selection = this.states.selection;
    // when only some rows are selected (but not all), select or deselect all of them
    // depending on the value of selectOnIndeterminate
    const value = states.selectOnIndeterminate ? !states.isAllSelected : !(states.isAllSelected || selection.length);
    let selectionChanged = false;
    data.forEach((item, index) => {
      if (states.selectable) {
        if (states.selectable.call(null, item, index) && toggleRowSelection(states, item, value)) {
          selectionChanged = true;
        }
      } else {
        if (toggleRowSelection(states, item, value)) {
          selectionChanged = true;
        }
github ElemeFE / element / packages / table / src / store / helper.js View on Github external
export function createStore(table, initialState = {}) {
  if (!table) {
    throw new Error('Table is required.');
  }

  const store = new Store();
  store.table = table;
  // fix https://github.com/ElemeFE/element/issues/14075
  // related pr https://github.com/ElemeFE/element/pull/14146
  store.toggleAllSelection = debounce(10, store._toggleAllSelection);
  Object.keys(initialState).forEach(key => {
    store.states[key] = initialState[key];
  });
  return store;
}
github Spdino / vbt-table / src / bigTreeTable / table-body.js View on Github external
tooltip.handleClosePopper()
      }
      const cell = getCell(event)
      if (!cell) return

      const oldHoverState = this.table.hoverState || {}
      this.table.$emit(
        'cell-mouse-leave',
        oldHoverState.row,
        oldHoverState.column,
        oldHoverState.cell,
        event
      )
    },

    handleMouseEnter: debounce(30, function(index) {
      this.store.commit('setHoverRow', index)
    }),

    handleMouseLeave: debounce(30, function() {
      this.store.commit('setHoverRow', null)
    }),

    handleContextMenu(event, row) {
      this.handleEvent(event, row, 'contextmenu')
    },

    handleDoubleClick(event, row) {
      this.handleEvent(event, row, 'dblclick')
    },

    handleClick(event, row) {
github kl2426 / vue-element-bigdata-table / src / vue-element-bigdata-table / table-store.js View on Github external
},

  rowSelectedChanged (states, row) {
    const changed = toggleRowSelection(states, row);
    const selection = states.selection;

    if (changed) {
      const table = this.table;
      table.$emit('selection-change', selection ? selection.slice() : []);
      table.$emit('select', selection, row);
    }

    this.updateAllSelected();
  },

  toggleAllSelection: debounce(10, function (states) {
    const data = states.data || [];
    if (data.length === 0) return;
    const value = !states.isAllSelected;
    const selection = this.states.selection;
    let selectionChanged = false;

    data.forEach((item, index) => {
      if (states.selectable) {
        if (states.selectable.call(null, item, index) && toggleRowSelection(states, item, value)) {
          selectionChanged = true;
        }
      } else {
        if (toggleRowSelection(states, item, value)) {
          selectionChanged = true;
        }
      }
github ElementUI / region-picker / src / components / multiple.vue View on Github external
created() {
    this.debouncedSearch = debounce(300, this.search);
  },
github phylogeny-explorer / explorer / client / src / components / Search / Search.js View on Github external
constructor(props) {
    super(props);
    this.state = {
      value: '',
      items: this.props.items || [],
      loading: false,
    };
    this.search = debounce(600, this.search.bind(this));
  }
github ElemeFE / element / packages / table / src / table-body.js View on Github external
created() {
    this.activateTooltip = debounce(50, tooltip => tooltip.handleShowPopper());
  },
github ElementUI / region-picker / src / components / single.vue View on Github external
created() {
    this.debouncedSearch = debounce(300, this.search);
  },
github Spdino / vbt-table / src / bigTreeTable / table-body.js View on Github external
created() {
    this.activateTooltip = debounce(50, tooltip => tooltip.handleShowPopper())
  },
github ElemeFE / element-react / src / tree / Node.jsx View on Github external
componentDidMount(): void {
    const nodeModel = this.props.nodeModel;
    const childrenKey = this.props.options.children || 'children';

    const triggerChange = debounce(20, (...args) => {
      if (this.isDeconstructed) return;
      this.handleSelectChange.apply(this, args);
    });

    this.loadHandler = this.enhanceLoad(nodeModel);
    this.watchers = {
      [this.idGen.next()]: watchPropertyChange(
        nodeModel,
        'indeterminate',
        value => {
          triggerChange(nodeModel.checked, value);
        }
      ),
      [this.idGen.next()]: watchPropertyChange(nodeModel, 'checked', value => {
        triggerChange(value, nodeModel.indeterminate);
      }),

throttle-debounce

Throttle and debounce functions.

MIT
Latest version published 4 months ago

Package Health Score

77 / 100
Full package analysis