Skip to content

Commit

Permalink
Merge pull request #54 from dhershman1/development
Browse files Browse the repository at this point in the history
v3.0.0
  • Loading branch information
dhershman1 authored Jun 28, 2021
2 parents 6c0d5ce + 5c84e76 commit 0963380
Show file tree
Hide file tree
Showing 10 changed files with 2,146 additions and 1,188 deletions.
12 changes: 5 additions & 7 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
[
"@babel/preset-env",
{
"targets": {
"browsers": [
"last 1 versions"
]
},
"modules": false
"targets": "defaults"
}
]
],
"exclude": "node_modules/**"
"exclude": [
"node_modules/**",
"dist"
]
}
76 changes: 74 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,76 @@
example.html
tests/
# Stupid Mac Files

.DS_Store

test.html
test-vue3.html

rollup.config.js
exp.js

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

exp.js

# IDE #
.idea/
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Change Log

## v3.0.0

### BREAKING CHANGES

- Lots of code condencing, shouldn't break anything but just in case
- Changed how debouncing `fireonempty` works. It had a bug so I made it a bit more strict to fix this
- Please open issues ASAP if this functionality is not working as expected

### New

- Added new `trim` option and modifier, this allows you to trim inputs that come through
- The value given to your function will **NOT** be the trimmed value, trim is only used for logic to see if things should be ran
- Added `getDirective` function which allows you to create a directive instance at lower levels other than global

### Improved

- Some small code cleanup
- Updated dependencies

## v2.6.0

### New
Expand Down
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![npm](https://img.shields.io/npm/v/vue-debounce.svg?style=flat-square)](https://www.npmjs.com/package/vue-debounce)
[![Downloads](https://img.shields.io/npm/dm/vue-debounce.svg?style=flat-square)](https://www.npmjs.com/package/vue-debounce)
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/dhershman1/vue-debounce.svg?style=flat-square&logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/dhershman1/vue-debounce/context:javascript)

A simple to use directive for debounce solutions

Expand All @@ -16,6 +17,7 @@ It attaches itself to an event for actions
- [Modifiers](#modifiers)
- [Options](#options)
- [Option Defaults](#option-defaults)
- [getDirective Usage](#getdirective-usage)
- [Usage](#usage)
- [Modifier Usage](#modifier-usage)
- [Overwriting Events](#overwriting-events)
Expand Down Expand Up @@ -44,6 +46,7 @@ npm i vue-debounce
- `unlock` : Used to unlock the enter key on a debounced input, useful if you want to use the `lock` option and only want a few debounced inputs unlocked
- `fireonempty` : Use to signify that when that specific input is emptied, you want the function to fire right away
- `cancelonempty` : Use this to specify that when the input is emptied you **DO NOT** want your debounced function to trigger at all
- `trim` : `Boolean` - Tells debounce to trim out white space using the `String.prototype.trim()` function

## Options

Expand All @@ -52,6 +55,7 @@ npm i vue-debounce
- This is given to the `addEventListener` method attached to the element
- `defaultTime` : `String` - Set the default timer for debounce directives that you don't give a time to
- `fireOnEmpty` : `Boolean` - Tells debounce that if the input is empty, then fire the function immediately
- `trim` : `Boolean` - Tells debounce to trim out white space using the `String.prototype.trim()` function

## Option Defaults

Expand All @@ -60,10 +64,24 @@ npm i vue-debounce
lock: false,
listenTo: 'keyup',
defaultTime: '300ms',
fireOnEmpty: false
fireOnEmpty: false,
trim: false
}
```

## getDirective Usage

As of v3.0.0 a new function called `getDirective` is now exported, this allows you to import a function that lets you create the debounce directive at any level in your app instead of just globally.

### Arguments

This function takes in 2 arguments, they are:

- `version` : `String` - This is the version of vue you're using, simply put `'2'` or `'3'` here
- Version automatically defaults to version 2
- This is so that backwards compatibility can still be supported, since I don't have access to the Vue context when you don't install globally
- `opts` : `Object` - This is the options object, use it the same way you would use it if using vue-debounce globally

## Usage

First make sure we tell vue to use it
Expand Down Expand Up @@ -95,6 +113,19 @@ Vue.use(vueDebounce, {
})
```

You can also attach the directive at a component level as of v3:

```js
import { getDirective } from 'vue-debounce'

const component = {
directives: {
// Please see above for arguments you can pass to this function
debounce: getDirective()
}
}
```

Then attach a time:format to the directive, and set the value to the function you want to call and attach it to your input element

Example:
Expand Down
Loading

0 comments on commit 0963380

Please sign in to comment.