vue-lazy-input

A VueJs directive for lazily binding @input events
1,835
Install
npm install vue-lazy-input
Latest Version:1.1.0
Vue:2
License:WTFPL
Last Updated:Jul 11, 2023
Links: GitHub  ·  npm
Maintainer: undefinederror

vue-lazy-input

A Vue.js directive for lazily binding @input events (v-model)

<input type="range" v-model="val" v-lazy-input:debounce="700"/>

Table of contents


Installation

bundler

npm i --save vue-lazy-input

browser
  <script src="https://unpkg.com/lodash/lodash.min.js"></script><!-- dependency -->
  <script src="https://unpkg.com/vue-lazy-input"></script>

What it does

It wraps existing @input event listeners bound on a custom component or DOM element with either lodash debounce or throttle.

v-lazy-input must be coupled with either a v-model directive or an @input event listener, or both. On its own it does nothing.


Syntax

v-lazy-input:[type]="duration"

type is either debounce, throttle or sync (fires immediately), default is debounce.

duration is a number, default is 500.

Hence v-lazy-input with no type nor duration is equivalent to v-lazy-input:debounce="500"


Example usage

<template>
  <input type="range" v-model="val" v-lazy-input:debounce="700"/>
</template>

<!-- with global registration -->
<script>
import VueLazyInput from 'vue-lazy-input'
import Vue from 'vue'
Vue.use(VueLazyInput)

export default {
  data(){
    return {
      val:42
    }
  }
}
</script>

<!-- with local registration -->
<script>
import {lazyInput} from 'vue-lazy-input'
import Vue from 'vue'

export default {
  data(){
    return {
      val:42
    }
  },
  directives:{
    lazyInput
  }
}
</script>

Related Packages

vue-click

Vue plugin for advanced click directive.

18,512 33
@tanstack/vue-pacer

Vue adapter for TanStack Pacer

425 793
tiny-debounce

tiny debounce function alternative to lodash.debounce

953,243
babel-plugin-jsx-v-model

JSX v-model transform

3,509,004 155
vue-throttle-event

rAF-throttled DOM event handling for Vue 3 composable

1,883 19

Version History

Version Released Vue License
1.1.0 ^2.6.10 WTFPL
1.0.5 ^2.6.10 WTFPL
1.0.4 ^2.6.10 WTFPL
1.0.3 ^2.6.10 WTFPL
1.0.2 ^2.6.10 MIT