Skip to content

Commit

Permalink
feat: default to not capture the mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
TobbenTM committed May 9, 2024
1 parent 49c17b4 commit 8a04ed2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
16 changes: 8 additions & 8 deletions docs/components/knob.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ const volume = ref(75)
</template>
```

It will automatically lock the pointer to the knob, making sure all mouse movements are registered for the knob value changes.

## Example

<script setup>
Expand Down Expand Up @@ -76,14 +74,14 @@ The component comes with a couple of features that are all adjustable:

### Mouse capture

By default, the knob will capture the mouse pointer to prevent it leaving the position while adjusting the knob.
This can be turned off using the `capture-mouse` prop:
Optionally, you can make the knob capture the mouse pointer to prevent it leaving the position while adjusting the knob.
This can be turned on using the `capture-mouse` prop:

```vue
<template>
<Knob
v-model="volume"
:capture-mouse="false"
:capture-mouse="true"
/>
</template>
```
Expand All @@ -92,7 +90,7 @@ Example:

<Knob
v-model="volume"
:capture-mouse="false"
:capture-mouse="true"
/>

Volume: {{ volume }}
Expand All @@ -107,7 +105,7 @@ Both the key and the intensity can be configured:
<Knob
v-model="volume"
:normal-strength="10"
:fine-strength="0.1"
:fine-strength="1"
fine-key="Control"
/>
</template>
Expand All @@ -118,7 +116,7 @@ Example:
<Knob
v-model="volume"
:normal-strength="10"
:fine-strength="0.1"
:fine-strength="1"
fine-key="Control"
/>

Expand Down Expand Up @@ -147,6 +145,8 @@ Example:
<Knob
v-model="volume"
mouse-behaviour="Velocity"
:normal-strength="2"
:fine-strength="0.5"
/>

Volume: {{ volume }}
Expand Down
10 changes: 4 additions & 6 deletions docs/components/mouse-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ const delta = ref(0)
</template>
```

It will automatically lock the pointer to the element, making sure all mouse movements are registered for the value changes emitted by the control.

## Example

<script setup>
Expand Down Expand Up @@ -93,12 +91,12 @@ The component comes with a couple of features that are all adjustable:

### Mouse capture

By default, the control will capture the mouse pointer to prevent it leaving the position while adjusting.
This can be turned off using the `capture-mouse` prop:
Optionally, you can make the mouse control capture the mouse pointer to prevent it leaving the position while adjusting.
This can be turned on using the `capture-mouse` prop:

```vue
<template>
<MouseControl :capture-mouse="false">
<MouseControl :capture-mouse="true">
<div />
</MouseControl>
</template>
Expand All @@ -107,7 +105,7 @@ This can be turned off using the `capture-mouse` prop:
Example:

<MouseControl
:capture-mouse="false"
:capture-mouse="true"
@change="delta = Math.round($event*10)/10"
@end="delta = ''"
>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Knob.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, nextTick, ref } from 'vue'
import { computed, ref } from 'vue'
import MouseControl from './MouseControl/MouseControl.vue'
import type { MouseBehaviour } from './MouseControl/types'
Expand All @@ -17,7 +17,7 @@ const props = withDefaults(defineProps<{
min: 0,
max: 100,
tabIndex: 0,
captureMouse: true,
captureMouse: false,
})
const emit = defineEmits<{
Expand Down
2 changes: 1 addition & 1 deletion src/components/MouseControl/MouseControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const props = withDefaults(defineProps<{
normalStrength: 1,
fineStrength: 0.1,
fineKey: 'Alt',
captureMouse: true,
captureMouse: false,
behaviour: MouseBehaviour.Flat,
friction: 0.5,
})
Expand Down

0 comments on commit 8a04ed2

Please sign in to comment.