Skip to content

Commit

Permalink
fix: remove use shared and change mouse-menu type file
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-kfd committed Mar 5, 2024
1 parent ace4fae commit 4a40c66
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
10 changes: 9 additions & 1 deletion packages/img-zoom/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { DirectiveHook, App, ObjectDirective } from 'vue';
import { createIdDom } from '../shared';
import './img-zoom.scss';

const groupMap = {} as Record<string, GroupItem[]>;

function createIdDom (tag: string, id: string, innerText?: string) {
const el = document.createElement(tag);
el.setAttribute('id', id);
if (innerText) {
el.innerText = innerText;
}
return el;
}

export interface GroupItem {
title?: string,
imgSrc: string
Expand Down
8 changes: 7 additions & 1 deletion packages/mouse-menu/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { App, DirectiveBinding, createVNode, render, ComponentPublicInstance, ObjectDirective } from 'vue';
import type { CustomMouseMenuOptions, TouchListenFn, PreventCheckFn, ContextMenuListenFn } from './types';
import MouseMenu from './mouse-menu.vue';
import { createClassDom } from '../shared';

function createClassDom (tag: string, className: string, innerText?: string) {
let el = document.createElement(tag);
el.setAttribute('class', className);
if (innerText) el.innerText = innerText;
return el;
}

MouseMenu.install = (app: App): void => {
app.component(MouseMenu.name, MouseMenu);
Expand Down
2 changes: 1 addition & 1 deletion packages/mouse-menu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "右键菜单组件",
"main": "dist/index.js",
"module": "dist/index.es.js",
"types": "index.ts",
"types": "types.ts",
"author": "leon-kfd",
"license": "ISC",
"repository": {
Expand Down
2 changes: 2 additions & 0 deletions packages/mouse-menu/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ export type CustomMouseMenuOptions = {
export type ContextMenuListenFn = (e: MouseEvent) => void
export type TouchListenFn = (e: TouchEvent) => void
export type PreventCheckFn = (e?: TouchEvent, el?: HTMLElement) => boolean

export type CustomMouseMenu = (options: CustomMouseMenuOptions) => any
16 changes: 15 additions & 1 deletion packages/to-drag/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import { DirectiveHook, App, DirectiveBinding, ObjectDirective } from 'vue';
import { getComputedStyleList } from '../shared';

function getComputedStyleList (el: HTMLElement, names: string[], formatToNumber = false) {
const results: Record<string, string | number> = {};
const styles = window.getComputedStyle(el);
names.map(name => {
let result: string | number = styles[name as any];
if (formatToNumber) {
const match = result.match(/\d+/);
if (match) result = ~~match[0];
}
results[name] = result;
});
return results;
}

export interface ToDragOptions {
isAbsolute?: boolean,
adsorbOffset: number,
Expand Down

0 comments on commit 4a40c66

Please sign in to comment.