@operato/input 8.0.0-alpha.19 → 8.0.0-alpha.20
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 +9 -0
- package/dist/src/ox-select-floor.js +13 -14
- package/dist/src/ox-select-floor.js.map +1 -1
- package/dist/stories/ox-select-floor.stories.js +2 -3
- package/dist/stories/ox-select-floor.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/ox-select-floor.ts +14 -14
- package/stories/ox-select-floor.stories.ts +2 -3
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "@operato/input",
|
3
3
|
"description": "Webcomponents for input following open-wc recommendations",
|
4
4
|
"author": "heartyoh@hatiolab.com",
|
5
|
-
"version": "8.0.0-alpha.
|
5
|
+
"version": "8.0.0-alpha.20",
|
6
6
|
"main": "dist/src/index.js",
|
7
7
|
"module": "dist/src/index.js",
|
8
8
|
"license": "MIT",
|
@@ -262,5 +262,5 @@
|
|
262
262
|
"prettier --write"
|
263
263
|
]
|
264
264
|
},
|
265
|
-
"gitHead": "
|
265
|
+
"gitHead": "c8a1305148d5f9190d79f7107001455e46906b8e"
|
266
266
|
}
|
package/src/ox-select-floor.ts
CHANGED
@@ -81,7 +81,7 @@ export class OxSelectFloor extends OxFormField {
|
|
81
81
|
@property({ type: String }) value?: string
|
82
82
|
@property({ type: Number }) bottomLimit = 70
|
83
83
|
|
84
|
-
@state() private selectedIndex =
|
84
|
+
@state() private selectedIndex = -1
|
85
85
|
@state() private activeIndex: number | null = null
|
86
86
|
@query('.carousel-container') private carouselContainer!: HTMLDivElement
|
87
87
|
|
@@ -91,6 +91,7 @@ export class OxSelectFloor extends OxFormField {
|
|
91
91
|
|
92
92
|
render() {
|
93
93
|
const length = this.cards.length
|
94
|
+
const cards = this.cards
|
94
95
|
|
95
96
|
return html`
|
96
97
|
<div
|
@@ -104,28 +105,26 @@ export class OxSelectFloor extends OxFormField {
|
|
104
105
|
@touchmove=${this.handleTouchMove}
|
105
106
|
@touchend=${this.handleTouchEnd}
|
106
107
|
>
|
107
|
-
${
|
108
|
-
const reverse = length - index - 1
|
108
|
+
${cards.map(({ image, name }, index) => {
|
109
109
|
return html`
|
110
110
|
<div
|
111
|
-
class="card ${this.getClassForCard(
|
112
|
-
style="bottom: ${(this.bottomLimit *
|
113
|
-
@click=${() => this.selectCard(
|
114
|
-
@tap=${() => this.toggleActiveCard(
|
111
|
+
class="card ${this.getClassForCard(index)} ${this.isActive(index) ? 'active' : ''}"
|
112
|
+
style="bottom: ${(this.bottomLimit * index) / length}%;"
|
113
|
+
@click=${() => this.selectCard(index)}
|
114
|
+
@tap=${() => this.toggleActiveCard(index)}
|
115
115
|
>
|
116
|
-
<img src="${image}" @load=${(e: Event) => this.adjustCardHeight(e,
|
116
|
+
<img src="${image}" @load=${(e: Event) => this.adjustCardHeight(e, index)} />
|
117
117
|
</div>
|
118
118
|
`
|
119
119
|
})}
|
120
|
-
${
|
121
|
-
const reverse = length - index - 1
|
120
|
+
${cards.map(({ image, name }, index) => {
|
122
121
|
return html`
|
123
122
|
<div
|
124
|
-
style="bottom: ${(this.bottomLimit *
|
125
|
-
@click=${() => this.selectCard(
|
123
|
+
style="bottom: ${(this.bottomLimit * index) / length}%;"
|
124
|
+
@click=${() => this.selectCard(index)}
|
126
125
|
template-container
|
127
126
|
>
|
128
|
-
<slot name="template-${
|
127
|
+
<slot name="template-${index}"></slot>
|
129
128
|
</div>
|
130
129
|
`
|
131
130
|
})}
|
@@ -222,13 +221,14 @@ export class OxSelectFloor extends OxFormField {
|
|
222
221
|
private updateSelectedIndex(newIndex: number) {
|
223
222
|
this.activeIndex = null
|
224
223
|
|
225
|
-
this.selectedIndex = Math.max(
|
224
|
+
this.selectedIndex = Math.max(-1, Math.min(newIndex, this.cards.length - 1))
|
226
225
|
this.scrollToSelectedCard()
|
227
226
|
}
|
228
227
|
|
229
228
|
private scrollToSelectedCard() {
|
230
229
|
const cardHeight = 320
|
231
230
|
const targetScrollTop = this.selectedIndex * cardHeight - (window.innerHeight / 2 - cardHeight / 2)
|
231
|
+
|
232
232
|
this.carouselContainer.scrollTo({ top: targetScrollTop, behavior: 'smooth' })
|
233
233
|
}
|
234
234
|
|
@@ -161,9 +161,8 @@ const Template: Story<ArgTypes> = ({
|
|
161
161
|
|
162
162
|
export const Regular = Template.bind({})
|
163
163
|
Regular.args = {
|
164
|
-
value: '1층',
|
165
164
|
bottomLimit: 70,
|
166
165
|
perspective: 1200,
|
167
|
-
rotateX:
|
168
|
-
rotateXForActive:
|
166
|
+
rotateX: 60,
|
167
|
+
rotateXForActive: 40
|
169
168
|
}
|