Skip to content

Commit

Permalink
Merge pull request #729 from justintaddei/justintaddei/issue544
Browse files Browse the repository at this point in the history
feat: option to stop propagation of waves to parent elements
  • Loading branch information
justintaddei authored Jun 27, 2024
2 parents 4aae618 + 2ddf439 commit 33f8be7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
cache: "pnpm"
- name: Install commitlint
run: |
npm install conventional-changelog-conventionalcommits
npm install commitlint@latest
pnpm add conventional-changelog-conventionalcommits
pnpm add commitlint@latest
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: npx commitlint --last --verbose
run: pnpm exec commitlint --last --verbose

- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
run: pnpm exec commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ After installing and registering the plugin, this is all you need to get started
- [trigger](#trigger)
- [disabled](#disabled)
- [respectDisabledAttribute](#respectdisabledattribute)
- [stopPropagation](#stoppropagation)
- [tagName](#tagname)
- [Using triggers](#using-triggers)
- [Advanced](#advanced)
Expand Down Expand Up @@ -251,6 +252,7 @@ export default {
| [trigger](#trigger) | `"auto"` | `string \| boolean \| "auto"` |
| [disabled](#disabled) | `false` | `boolean` |
| [respectDisabledAttribute](#respectdisabledattribute) | `true` | `boolean` |
| [stopPropagation](#stoppropagation) | `false` | `boolean` |
| [tagName](#tagname) | `"div"` | `string` |

### Details
Expand Down Expand Up @@ -543,6 +545,13 @@ export default {
<button v-wave="{respectDisabledAttribute: false}" disabled>Click me!</button>
```

#### stopPropagation

- **type:** `boolean`
- _default:_ `false`

> Prevents the `pointerdown` event from propagating to parent elements.
#### tagName

- **type:** `string`
Expand Down
1 change: 1 addition & 0 deletions src/__snapshots__/options.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exports[`has documented default options 1`] = `
"finalOpacity": 0.1,
"initialOpacity": 0.2,
"respectDisabledAttribute": true,
"stopPropagation": false,
"tagName": "div",
"trigger": "auto",
}
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const createDirective = (

const options = { ...globalOptions, ...optionMap.get(el) }

if (options.stopPropagation) event.stopPropagation()

if (options.trigger === false) return wave(event, el, options)

if (triggerIsID(options.trigger)) return
Expand Down
9 changes: 9 additions & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ interface IVWaveDirectiveOptions {
* true
*/
respectDisabledAttribute: boolean

/**
* Prevents the pointerdown event from propagating to parent elements
*
* @default
* false
*/
stopPropagation: boolean
}

interface IVWavePluginOptions extends IVWaveDirectiveOptions {
Expand Down Expand Up @@ -136,6 +144,7 @@ const DEFAULT_PLUGIN_OPTIONS: IVWavePluginOptions = {
tagName: 'div',
disabled: false,
respectDisabledAttribute: true,
stopPropagation: false,
}

export { DEFAULT_PLUGIN_OPTIONS, type IVWavePluginOptions, type IVWaveDirectiveOptions }

0 comments on commit 33f8be7

Please sign in to comment.