@operato/input 8.0.0-alpha.4 → 8.0.0-alpha.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +107 -0
- package/dist/src/ox-input-color-stops.d.ts +1 -1
- package/dist/src/ox-input-color-stops.js +2 -2
- package/dist/src/ox-input-color-stops.js.map +1 -1
- package/dist/src/ox-input-direction.d.ts +1 -0
- package/dist/src/ox-input-direction.js +37 -4
- package/dist/src/ox-input-direction.js.map +1 -1
- package/dist/src/ox-input-signature.d.ts +4 -2
- package/dist/src/ox-input-signature.js +34 -14
- package/dist/src/ox-input-signature.js.map +1 -1
- package/dist/src/ox-select-floor.d.ts +35 -0
- package/dist/src/ox-select-floor.js +238 -0
- package/dist/src/ox-select-floor.js.map +1 -0
- package/dist/stories/image-for-select-floor.d.ts +1 -0
- package/dist/stories/image-for-select-floor.js +2 -0
- package/dist/stories/image-for-select-floor.js.map +1 -0
- package/dist/stories/ox-input-direction.stories.js +11 -0
- package/dist/stories/ox-input-direction.stories.js.map +1 -1
- package/dist/stories/ox-select-floor.stories.d.ts +45 -0
- package/dist/stories/ox-select-floor.stories.js +166 -0
- package/dist/stories/ox-select-floor.stories.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -15
- package/src/ox-input-color-stops.ts +2 -2
- package/src/ox-input-direction.ts +31 -4
- package/src/ox-input-signature.ts +45 -17
- package/src/ox-select-floor.ts +246 -0
- package/stories/image-for-select-floor.ts +2 -0
- package/stories/ox-input-direction.stories.ts +11 -0
- package/stories/ox-select-floor.stories.ts +197 -0
- package/themes/calendar-theme.css +3 -1
- package/assets/images/icon-editor-gradient-direction.png +0 -0
- package/assets/images/icon-properties-label.png +0 -0
- package/assets/images/icon-properties-line-type.png +0 -0
- package/assets/images/icon-properties-table.png +0 -0
- package/dist/src/ox-zoomable-image.d.ts +0 -17
- package/dist/src/ox-zoomable-image.js +0 -80
- package/dist/src/ox-zoomable-image.js.map +0 -1
- package/src/ox-zoomable-image.ts +0 -75
@@ -70,6 +70,17 @@ const Template: Story<ArgTypes> = ({ name = 'options', value, disabled }: ArgTyp
|
|
70
70
|
?disabled=${disabled}
|
71
71
|
>
|
72
72
|
</ox-input-direction>
|
73
|
+
<br />
|
74
|
+
<ox-input-direction
|
75
|
+
@change=${(e: Event) => {
|
76
|
+
console.log((e.target as HTMLInputElement).value)
|
77
|
+
}}
|
78
|
+
name=${name}
|
79
|
+
.value=${value}
|
80
|
+
?disabled=${disabled}
|
81
|
+
inbound
|
82
|
+
>
|
83
|
+
</ox-input-direction>
|
73
84
|
</div>
|
74
85
|
`
|
75
86
|
|
@@ -0,0 +1,197 @@
|
|
1
|
+
import '../src/ox-select-floor.js'
|
2
|
+
|
3
|
+
import { html, TemplateResult } from 'lit'
|
4
|
+
import { styles as MDTypeScaleStyles } from '@material/web/typography/md-typescale-styles'
|
5
|
+
import { IMAGE } from './image-for-select-floor.js'
|
6
|
+
|
7
|
+
export default {
|
8
|
+
title: 'ox-select-floor',
|
9
|
+
component: 'ox-select-floor',
|
10
|
+
argTypes: {
|
11
|
+
disabled: { control: 'boolean' },
|
12
|
+
value: { control: 'text' },
|
13
|
+
bottomLimit: { control: 'number' },
|
14
|
+
perspective: { control: 'number' },
|
15
|
+
rotateX: { control: 'number' },
|
16
|
+
rotateXForActive: { control: 'number' },
|
17
|
+
interval: { control: 'number' }
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
interface Story<T> {
|
22
|
+
(args: T): TemplateResult
|
23
|
+
args?: Partial<T>
|
24
|
+
argTypes?: Record<string, unknown>
|
25
|
+
}
|
26
|
+
|
27
|
+
interface ArgTypes {
|
28
|
+
value?: string
|
29
|
+
bottomLimit?: number
|
30
|
+
perspective?: number
|
31
|
+
rotateX?: number
|
32
|
+
rotateXForActive?: number
|
33
|
+
disabled?: boolean
|
34
|
+
interval?: number
|
35
|
+
}
|
36
|
+
|
37
|
+
const cards = new Array(10).fill({}).map((_, index) => {
|
38
|
+
return {
|
39
|
+
image: IMAGE,
|
40
|
+
name: index + 1 + '층'
|
41
|
+
}
|
42
|
+
})
|
43
|
+
|
44
|
+
const Template: Story<ArgTypes> = ({
|
45
|
+
value,
|
46
|
+
disabled,
|
47
|
+
bottomLimit = 70,
|
48
|
+
perspective = 1200,
|
49
|
+
rotateX = 60,
|
50
|
+
rotateXForActive = 40,
|
51
|
+
interval = 0
|
52
|
+
}: ArgTypes) => html`
|
53
|
+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet" />
|
54
|
+
|
55
|
+
<link href="/themes/light.css" rel="stylesheet" />
|
56
|
+
<link href="/themes/dark.css" rel="stylesheet" />
|
57
|
+
<link href="/themes/spacing.css" rel="stylesheet" />
|
58
|
+
|
59
|
+
<link
|
60
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
|
61
|
+
rel="stylesheet"
|
62
|
+
/>
|
63
|
+
<link
|
64
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
|
65
|
+
rel="stylesheet"
|
66
|
+
/>
|
67
|
+
<link
|
68
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
|
69
|
+
rel="stylesheet"
|
70
|
+
/>
|
71
|
+
|
72
|
+
<style>
|
73
|
+
${MDTypeScaleStyles.cssText}
|
74
|
+
</style>
|
75
|
+
|
76
|
+
<style>
|
77
|
+
html,
|
78
|
+
body {
|
79
|
+
margin: 0;
|
80
|
+
padding: 0;
|
81
|
+
overflow: hidden;
|
82
|
+
|
83
|
+
overscroll-behavior-y: none;
|
84
|
+
|
85
|
+
/* This is a font-stack that tries to use the system-default sans-serifs first */
|
86
|
+
font-family: Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
87
|
+
line-height: 1.5;
|
88
|
+
-webkit-font-smoothing: antialiased;
|
89
|
+
|
90
|
+
accent-color: var(--md-sys-color-primary);
|
91
|
+
background-color: var(--md-sys-color-background);
|
92
|
+
}
|
93
|
+
|
94
|
+
.container {
|
95
|
+
height: 1000px;
|
96
|
+
text-align: center;
|
97
|
+
padding: 20px;
|
98
|
+
|
99
|
+
background-color: var(--md-sys-color-primary-container);
|
100
|
+
color: var(--md-sys-color-on-primary-container);
|
101
|
+
}
|
102
|
+
|
103
|
+
div[status] {
|
104
|
+
display: flex;
|
105
|
+
position: absolute;
|
106
|
+
right: 0px;
|
107
|
+
bottom: 0px;
|
108
|
+
align-items: center;
|
109
|
+
right: 3%;
|
110
|
+
}
|
111
|
+
|
112
|
+
div[status] > div[content] {
|
113
|
+
display: flex;
|
114
|
+
background-color: #4e5055;
|
115
|
+
color: #fff;
|
116
|
+
padding: 5px 7px;
|
117
|
+
border-radius: 7px;
|
118
|
+
gap: 10px;
|
119
|
+
font-size: 14px;
|
120
|
+
}
|
121
|
+
|
122
|
+
div[status] span {
|
123
|
+
display: flex;
|
124
|
+
align-items: center;
|
125
|
+
width: 48px;
|
126
|
+
}
|
127
|
+
|
128
|
+
div[status] md-icon {
|
129
|
+
width: 20px;
|
130
|
+
height: 20px;
|
131
|
+
margin-right: 4px;
|
132
|
+
border-radius: 5px;
|
133
|
+
font-size: 21px;
|
134
|
+
font-weight: 700;
|
135
|
+
}
|
136
|
+
div[status] md-icon[request] {
|
137
|
+
background-color: #f7f7f7;
|
138
|
+
color: #4e5055;
|
139
|
+
}
|
140
|
+
div[status] md-icon[pass] {
|
141
|
+
background-color: #4bbb4a;
|
142
|
+
}
|
143
|
+
div[status] md-icon[fail] {
|
144
|
+
background-color: #ff4444;
|
145
|
+
}
|
146
|
+
|
147
|
+
span[name] {
|
148
|
+
width: 40px;
|
149
|
+
color: #4e5055;
|
150
|
+
margin-left: 6px;
|
151
|
+
text-align: center;
|
152
|
+
}
|
153
|
+
|
154
|
+
span[name][active] {
|
155
|
+
color: var(--md-sys-color-on-error);
|
156
|
+
background-color: var(--md-sys-color-error);
|
157
|
+
border-radius: 999px;
|
158
|
+
}
|
159
|
+
|
160
|
+
ox-select-floor {
|
161
|
+
--ox-select-floor-rotate-x: ${rotateX}deg;
|
162
|
+
--ox-select-floor-rotate-x-active: ${rotateXForActive}deg;
|
163
|
+
--ox-select-floor-perspective: ${perspective}px;
|
164
|
+
}
|
165
|
+
</style>
|
166
|
+
|
167
|
+
<div class="container md-typescale-body-large-prominent">
|
168
|
+
<ox-select-floor
|
169
|
+
.cards=${cards}
|
170
|
+
.bottomLimit=${bottomLimit}
|
171
|
+
?disabled=${disabled}
|
172
|
+
.interval=${interval}
|
173
|
+
@change=${(e: Event) => console.log(((e as CustomEvent).target as any)!.value)}
|
174
|
+
>
|
175
|
+
${cards.map(
|
176
|
+
({ image, name }, index) =>
|
177
|
+
html`<div slot="template-${index}" status>
|
178
|
+
<div content>
|
179
|
+
<span><md-icon request slot="icon">exclamation</md-icon>100</span>
|
180
|
+
<span><md-icon pass slot="icon">check</md-icon>50</span>
|
181
|
+
<span><md-icon fail slot="icon">close</md-icon>5</span>
|
182
|
+
</div>
|
183
|
+
<span name>${name}</span>
|
184
|
+
</div>`
|
185
|
+
)}
|
186
|
+
</ox-select-floor>
|
187
|
+
</div>
|
188
|
+
`
|
189
|
+
|
190
|
+
export const Regular = Template.bind({})
|
191
|
+
Regular.args = {
|
192
|
+
bottomLimit: 70,
|
193
|
+
perspective: 1200,
|
194
|
+
rotateX: 60,
|
195
|
+
rotateXForActive: 40,
|
196
|
+
interval: 0
|
197
|
+
}
|
@@ -9,7 +9,8 @@ body {
|
|
9
9
|
/* monthly layout */
|
10
10
|
--calendar-monthly-ol-margin: var(--margin-default) 0;
|
11
11
|
--calendar-monthly-ol-top-border: 2px solid var(--md-sys-color-secondary);
|
12
|
-
--calendar-current-
|
12
|
+
--calendar-current-month-background-color: var(--md-sys-color-surface-variant);
|
13
|
+
--calendar-current-month-color: var(--md-sys-color-on-surface);
|
13
14
|
--calendar-monthly-label-align: left;
|
14
15
|
--calendar-monthly-label-padding: var(--padding-narrow) 0;
|
15
16
|
--calendar-monthly-label-color: var(--md-sys-color-secondary);
|
@@ -35,6 +36,7 @@ body {
|
|
35
36
|
--calendar-weekly-ol-margin: var(--margin-default) 0;
|
36
37
|
--calendar-weekly-ol-top-border: 2px solid var(--md-sys-color-secondary);
|
37
38
|
--calendar-current-week-background-color: var(--md-sys-color-surface-variant);
|
39
|
+
--calendar-current-week-color: var(--md-sys-color-on-surface);
|
38
40
|
--calendar-weekly-label-align: center;
|
39
41
|
--calendar-weekly-label-padding: var(--padding-narrow) 0;
|
40
42
|
--calendar-weekly-label-color: var(--md-sys-color-secondary);
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { LitElement } from 'lit';
|
2
|
-
export declare class OxZoomableImage extends LitElement {
|
3
|
-
static styles: import("lit").CSSResult;
|
4
|
-
src: string;
|
5
|
-
image: HTMLImageElement;
|
6
|
-
private scale;
|
7
|
-
private startX;
|
8
|
-
private startY;
|
9
|
-
private x;
|
10
|
-
private y;
|
11
|
-
private dragging;
|
12
|
-
render(): import("lit-html").TemplateResult<1>;
|
13
|
-
private handleWheel;
|
14
|
-
private handleMouseDown;
|
15
|
-
private handleMouseMove;
|
16
|
-
private handleMouseUp;
|
17
|
-
}
|
@@ -1,80 +0,0 @@
|
|
1
|
-
import { __decorate } from "tslib";
|
2
|
-
import { LitElement, html, css } from 'lit';
|
3
|
-
import { customElement, property, query } from 'lit/decorators.js';
|
4
|
-
let OxZoomableImage = class OxZoomableImage extends LitElement {
|
5
|
-
constructor() {
|
6
|
-
super(...arguments);
|
7
|
-
this.src = '';
|
8
|
-
this.scale = 1;
|
9
|
-
this.startX = 0;
|
10
|
-
this.startY = 0;
|
11
|
-
this.x = 0;
|
12
|
-
this.y = 0;
|
13
|
-
this.dragging = false;
|
14
|
-
}
|
15
|
-
static { this.styles = css `
|
16
|
-
:host {
|
17
|
-
display: block;
|
18
|
-
overflow: hidden;
|
19
|
-
position: relative;
|
20
|
-
}
|
21
|
-
|
22
|
-
img {
|
23
|
-
transition: transform 0.25s ease;
|
24
|
-
transform-origin: center;
|
25
|
-
cursor: grab;
|
26
|
-
}
|
27
|
-
`; }
|
28
|
-
render() {
|
29
|
-
return html `
|
30
|
-
<img
|
31
|
-
id="zoomableImage"
|
32
|
-
src="${this.src}"
|
33
|
-
@wheel="${this.handleWheel}"
|
34
|
-
@mousedown="${this.handleMouseDown}"
|
35
|
-
@mousemove="${this.handleMouseMove}"
|
36
|
-
@mouseup="${this.handleMouseUp}"
|
37
|
-
@mouseleave="${this.handleMouseUp}"
|
38
|
-
style="transform: translate(${this.x}px, ${this.y}px) scale(${this.scale});"
|
39
|
-
/>
|
40
|
-
`;
|
41
|
-
}
|
42
|
-
handleWheel(event) {
|
43
|
-
event.preventDefault();
|
44
|
-
const delta = event.deltaY;
|
45
|
-
const zoomIntensity = 0.1;
|
46
|
-
this.scale += delta > 0 ? -zoomIntensity : zoomIntensity;
|
47
|
-
this.scale = Math.max(0.1, Math.min(this.scale, 4));
|
48
|
-
this.requestUpdate();
|
49
|
-
}
|
50
|
-
handleMouseDown(event) {
|
51
|
-
this.startX = event.clientX - this.x;
|
52
|
-
this.startY = event.clientY - this.y;
|
53
|
-
this.dragging = true;
|
54
|
-
const img = this.image;
|
55
|
-
img.style.cursor = 'grabbing';
|
56
|
-
}
|
57
|
-
handleMouseMove(event) {
|
58
|
-
if (!this.dragging)
|
59
|
-
return;
|
60
|
-
this.x = event.clientX - this.startX;
|
61
|
-
this.y = event.clientY - this.startY;
|
62
|
-
this.requestUpdate();
|
63
|
-
}
|
64
|
-
handleMouseUp() {
|
65
|
-
this.dragging = false;
|
66
|
-
const img = this.image;
|
67
|
-
img.style.cursor = 'grab';
|
68
|
-
}
|
69
|
-
};
|
70
|
-
__decorate([
|
71
|
-
property({ type: String })
|
72
|
-
], OxZoomableImage.prototype, "src", void 0);
|
73
|
-
__decorate([
|
74
|
-
query('img')
|
75
|
-
], OxZoomableImage.prototype, "image", void 0);
|
76
|
-
OxZoomableImage = __decorate([
|
77
|
-
customElement('ox-zoomable-image')
|
78
|
-
], OxZoomableImage);
|
79
|
-
export { OxZoomableImage };
|
80
|
-
//# sourceMappingURL=ox-zoomable-image.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ox-zoomable-image.js","sourceRoot":"","sources":["../../src/ox-zoomable-image.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAG3D,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAAxC;;QAeuB,QAAG,GAAG,EAAE,CAAA;QAI5B,UAAK,GAAW,CAAC,CAAA;QACjB,WAAM,GAAW,CAAC,CAAA;QAClB,WAAM,GAAW,CAAC,CAAA;QAClB,MAAC,GAAW,CAAC,CAAA;QACb,MAAC,GAAW,CAAC,CAAA;QACb,aAAQ,GAAY,KAAK,CAAA;IA8CnC,CAAC;aArEQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;GAYlB,AAZY,CAYZ;IAaD,MAAM;QACJ,OAAO,IAAI,CAAA;;;eAGA,IAAI,CAAC,GAAG;kBACL,IAAI,CAAC,WAAW;sBACZ,IAAI,CAAC,eAAe;sBACpB,IAAI,CAAC,eAAe;oBACtB,IAAI,CAAC,aAAa;uBACf,IAAI,CAAC,aAAa;sCACH,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,aAAa,IAAI,CAAC,KAAK;;KAE3E,CAAA;IACH,CAAC;IAEO,WAAW,CAAC,KAAiB;QACnC,KAAK,CAAC,cAAc,EAAE,CAAA;QACtB,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAA;QAC1B,MAAM,aAAa,GAAG,GAAG,CAAA;QACzB,IAAI,CAAC,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAA;QACxD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;QACnD,IAAI,CAAC,aAAa,EAAE,CAAA;IACtB,CAAC;IAEO,eAAe,CAAC,KAAiB;QACvC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAA;QACpC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAA;QACpC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QACpB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAyB,CAAA;QAC1C,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,UAAU,CAAA;IAC/B,CAAC;IAEO,eAAe,CAAC,KAAiB;QACvC,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAM;QAC1B,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAA;QACpC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAA;QACpC,IAAI,CAAC,aAAa,EAAE,CAAA;IACtB,CAAC;IAEO,aAAa;QACnB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;QACrB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAyB,CAAA;QAC1C,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAA;IAC3B,CAAC;;AAtD2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAS;AAEtB;IAAb,KAAK,CAAC,KAAK,CAAC;8CAAyB;AAjB3B,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAsE3B","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\n@customElement('ox-zoomable-image')\nexport class OxZoomableImage extends LitElement {\n static styles = css`\n :host {\n display: block;\n overflow: hidden;\n position: relative;\n }\n\n img {\n transition: transform 0.25s ease;\n transform-origin: center;\n cursor: grab;\n }\n `\n\n @property({ type: String }) src = ''\n\n @query('img') image!: HTMLImageElement\n\n private scale: number = 1\n private startX: number = 0\n private startY: number = 0\n private x: number = 0\n private y: number = 0\n private dragging: boolean = false\n\n render() {\n return html`\n <img\n id=\"zoomableImage\"\n src=\"${this.src}\"\n @wheel=\"${this.handleWheel}\"\n @mousedown=\"${this.handleMouseDown}\"\n @mousemove=\"${this.handleMouseMove}\"\n @mouseup=\"${this.handleMouseUp}\"\n @mouseleave=\"${this.handleMouseUp}\"\n style=\"transform: translate(${this.x}px, ${this.y}px) scale(${this.scale});\"\n />\n `\n }\n\n private handleWheel(event: WheelEvent) {\n event.preventDefault()\n const delta = event.deltaY\n const zoomIntensity = 0.1\n this.scale += delta > 0 ? -zoomIntensity : zoomIntensity\n this.scale = Math.max(0.1, Math.min(this.scale, 4))\n this.requestUpdate()\n }\n\n private handleMouseDown(event: MouseEvent) {\n this.startX = event.clientX - this.x\n this.startY = event.clientY - this.y\n this.dragging = true\n const img = this.image as HTMLImageElement\n img.style.cursor = 'grabbing'\n }\n\n private handleMouseMove(event: MouseEvent) {\n if (!this.dragging) return\n this.x = event.clientX - this.startX\n this.y = event.clientY - this.startY\n this.requestUpdate()\n }\n\n private handleMouseUp() {\n this.dragging = false\n const img = this.image as HTMLImageElement\n img.style.cursor = 'grab'\n }\n}\n"]}
|
package/src/ox-zoomable-image.ts
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
import { LitElement, html, css } from 'lit'
|
2
|
-
import { customElement, property, query } from 'lit/decorators.js'
|
3
|
-
|
4
|
-
@customElement('ox-zoomable-image')
|
5
|
-
export class OxZoomableImage extends LitElement {
|
6
|
-
static styles = css`
|
7
|
-
:host {
|
8
|
-
display: block;
|
9
|
-
overflow: hidden;
|
10
|
-
position: relative;
|
11
|
-
}
|
12
|
-
|
13
|
-
img {
|
14
|
-
transition: transform 0.25s ease;
|
15
|
-
transform-origin: center;
|
16
|
-
cursor: grab;
|
17
|
-
}
|
18
|
-
`
|
19
|
-
|
20
|
-
@property({ type: String }) src = ''
|
21
|
-
|
22
|
-
@query('img') image!: HTMLImageElement
|
23
|
-
|
24
|
-
private scale: number = 1
|
25
|
-
private startX: number = 0
|
26
|
-
private startY: number = 0
|
27
|
-
private x: number = 0
|
28
|
-
private y: number = 0
|
29
|
-
private dragging: boolean = false
|
30
|
-
|
31
|
-
render() {
|
32
|
-
return html`
|
33
|
-
<img
|
34
|
-
id="zoomableImage"
|
35
|
-
src="${this.src}"
|
36
|
-
@wheel="${this.handleWheel}"
|
37
|
-
@mousedown="${this.handleMouseDown}"
|
38
|
-
@mousemove="${this.handleMouseMove}"
|
39
|
-
@mouseup="${this.handleMouseUp}"
|
40
|
-
@mouseleave="${this.handleMouseUp}"
|
41
|
-
style="transform: translate(${this.x}px, ${this.y}px) scale(${this.scale});"
|
42
|
-
/>
|
43
|
-
`
|
44
|
-
}
|
45
|
-
|
46
|
-
private handleWheel(event: WheelEvent) {
|
47
|
-
event.preventDefault()
|
48
|
-
const delta = event.deltaY
|
49
|
-
const zoomIntensity = 0.1
|
50
|
-
this.scale += delta > 0 ? -zoomIntensity : zoomIntensity
|
51
|
-
this.scale = Math.max(0.1, Math.min(this.scale, 4))
|
52
|
-
this.requestUpdate()
|
53
|
-
}
|
54
|
-
|
55
|
-
private handleMouseDown(event: MouseEvent) {
|
56
|
-
this.startX = event.clientX - this.x
|
57
|
-
this.startY = event.clientY - this.y
|
58
|
-
this.dragging = true
|
59
|
-
const img = this.image as HTMLImageElement
|
60
|
-
img.style.cursor = 'grabbing'
|
61
|
-
}
|
62
|
-
|
63
|
-
private handleMouseMove(event: MouseEvent) {
|
64
|
-
if (!this.dragging) return
|
65
|
-
this.x = event.clientX - this.startX
|
66
|
-
this.y = event.clientY - this.startY
|
67
|
-
this.requestUpdate()
|
68
|
-
}
|
69
|
-
|
70
|
-
private handleMouseUp() {
|
71
|
-
this.dragging = false
|
72
|
-
const img = this.image as HTMLImageElement
|
73
|
-
img.style.cursor = 'grab'
|
74
|
-
}
|
75
|
-
}
|