Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
This file is used to show the current focus of maintainers, your contributions are not limited to these tasks.

- [x] transform to adapt modularity practice (main class maintains `pointers` map only, other imports share map and register hooks)
- [ ] add rotate functionality to `multiPointer_zanZoom`.
- [ ] support multi-element init, add / remove monitoring element and API.
- [ ] prototype `PointeractManager`.
- [x] implement `Swipe` module and event.
- [ ] add rotate functionality to `MultiTouchPanZoom`.
- [ ] prototype `PointeractManager` that supports multi-element init, add / remove monitoring element and API.
5 changes: 3 additions & 2 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { defineConfig } from 'vitepress';
import { groupIconMdPlugin, groupIconVitePlugin } from 'vitepress-plugin-group-icons';
import { ThemeConfig } from 'vitepress-theme-trito';

// https://vitepress.dev/reference/site-config
const inDev = process.env.MODE === 'dev';

export default defineConfig<ThemeConfig>({
cleanUrls: true,
lastUpdated: true,
Expand All @@ -20,7 +21,7 @@ export default defineConfig<ThemeConfig>({
'script',
{
defer: '',
src: 'https://analytics.consensia.cc/script.js',
src: inDev ? '' : 'https://analytics.consensia.cc/script.js',
'data-website-id': 'f4ddf973-093c-4660-bda7-65a511d5b26c',
},
],
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/theme/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
5 changes: 4 additions & 1 deletion docs/components/playground.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
</template>

<script lang="ts" setup>
import { onMounted, reactive, useTemplateRef, onBeforeUnmount } from 'vue';
import {
Click,
Drag,
Expand All @@ -25,6 +24,7 @@ import {
zoomPreset,
panPreset,
} from '@';
import { onMounted, reactive, useTemplateRef, onBeforeUnmount } from 'vue';
import { Coordinates } from '@/types';

function C2C(coords: Coordinates) {
Expand All @@ -34,6 +34,7 @@ function C2C(coords: Coordinates) {
};
}


const square = useTemplateRef('square');
const container = useTemplateRef('container');
const data = reactive({
Expand All @@ -47,6 +48,7 @@ let pointeract: PointeractInterface<
[Click, Drag, MultitouchPanZoom, PreventDefault, WheelPanZoom, Lubricator]
>;


onMounted(() => {
if (!container.value || !square.value) return;
const squareRect = square.value.getBoundingClientRect();
Expand Down Expand Up @@ -88,6 +90,7 @@ onMounted(() => {
});
});


onBeforeUnmount(() => {
pointeract.dispose();
if (streakTimeout) {
Expand Down
4 changes: 2 additions & 2 deletions docs/en/basic/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ All the types shown below are designed to be flexible, they accept:
- an array of module instance types
- nothing (which means no module loaded)

as their type parameters
as their type parameters.

for example:
For example:

```TypeScript
import { Drag, PreventDefault, type Options } from "pointeract";
Expand Down
16 changes: 7 additions & 9 deletions docs/en/basic/use-pointeract.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,24 +136,22 @@ You cannot load a module that is not passed into the Pointeract constructor afte

### Subscribe

Use `on()` to subscribe, the usage is similar to `addEventListener()`, but is fully typed and returns the corresponding unsubscribe function.

Pointeract utilizes native [EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) internally, the events are `CustomEvent`s and event data is stored in `e.detail`.
Use `on()` to subscribe, the usage is similar to `addEventListener()`, but is fully typed and returns the pointeract instance for chaining.

```TypeScript
const hook = (e: typeof pointeract.events.drag) => {
console.log(e.detail);
import type { StdEvents } from 'pointeract';

const hook = (e: StdEvents['drag']) => {
console.log(e);
};
const unsubscribe = pointeract.on('drag', hook);
pointeract.on('drag', hook);
```

### Unsubscribe

Use `off()` or returned unsubscribe functions to unsubscribe, also similar to `removeEventListener()`:
Use `off()` to unsubscribe, also similar to `removeEventListener()`:

```TypeScript
unsubscribe();
// or:
pointeract.off('drag', hook);
```

Expand Down
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"sideEffects": false,
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/types/index.d.ts",
"types": "./dist/index.d.ts",
"unpkg": "./dist/index.js",
"jsdelivr": "./dist/index.js",
"publishConfig": {
Expand All @@ -43,27 +43,27 @@
"test:coverage": "vitest run --coverage",
"check": "vue-tsc && oxfmt --check && oxlint --type-aware",
"dev": "vite",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs"
"docs:dev": "MODE=dev vitepress dev docs",
"docs:build": "MODE=prod vitepress build docs",
"docs:preview": "MODE=prod vitepress preview docs"
},
"devDependencies": {
"@types/node": "^25.3.3",
"@vitest/coverage-v8": "^4.0.18",
"happy-dom": "^20.7.0",
"oxfmt": "^0.35.0",
"oxlint": "^1.50.0",
"oxlint-tsgolint": "^0.15.0",
"terser": "^5.46.0",
"@types/node": "^25.5.0",
"@vitest/coverage-v8": "^4.1.1",
"happy-dom": "^20.8.4",
"oxfmt": "^0.41.0",
"oxlint": "^1.56.0",
"oxlint-tsgolint": "^0.17.1",
"terser": "^5.46.1",
"tsc-alias": "^1.8.16",
"typescript": "^5.9.3",
"typescript": "^6.0.2",
"vite": "^7.3.1",
"vitepress": "2.0.0-alpha.16",
"vitepress-plugin-group-icons": "^1.7.1",
"vitepress-theme-trito": "^1.0.6",
"vitest": "^4.0.18",
"vue": "^3.5.29",
"vue-tsc": "^3.2.5"
"vitepress-theme-trito": "^1.1.0",
"vitest": "^4.1.1",
"vue": "^3.5.30",
"vue-tsc": "^3.2.6"
},
"packageManager": "pnpm@10.29.3"
}
Loading
Loading