|
36 | 36 |
|
37 | 37 | // stylistic props |
38 | 38 | export let focus: boolean; |
39 | | - export let orientationStart: string; |
| 39 | + export let orientationStart: 'left' | 'right' | 'top' | 'bottom'; |
40 | 40 |
|
41 | 41 | // methods |
42 | 42 | export let moveHandle: (index: number | null, value: number) => void; |
|
87 | 87 | class:selected={isSelected(min, values, precision)} |
88 | 88 | class:in-range={isInRange(min, values, range)} |
89 | 89 | style="{orientationStart}: 0%;" |
| 90 | + data-val={coerceFloat(min, precision)} |
90 | 91 | on:pointerdown={(e) => { |
91 | 92 | labelDown(e); |
92 | 93 | }} |
|
96 | 97 | > |
97 | 98 | {#if all === 'label' || first === 'label'} |
98 | 99 | <span class="pipVal"> |
99 | | - {#if prefix}<span class="pipVal-prefix">{prefix}</span>{/if}{@html formatter( |
100 | | - coerceFloat(min), |
101 | | - 0, |
102 | | - 0 |
103 | | - )}{#if suffix}<span class="pipVal-suffix">{suffix}</span>{/if} |
| 100 | + {#if prefix}<span class="pipVal-prefix">{prefix}</span>{/if} |
| 101 | + {@html formatter(coerceFloat(min, precision), 0, 0)} |
| 102 | + {#if suffix}<span class="pipVal-suffix">{suffix}</span>{/if} |
104 | 103 | </span> |
105 | 104 | {/if} |
106 | 105 | </span> |
107 | 106 | {/if} |
108 | 107 |
|
109 | 108 | {#if (all && rest !== false) || rest} |
110 | 109 | {#each Array(pipCount + 1) as _, i} |
111 | | - {#if getValueFromIndex(i, min, max, pipStep, step) !== min && getValueFromIndex(i, min, max, pipStep, step) !== max} |
| 110 | + {@const val = getValueFromIndex(i, min, max, pipStep, step, precision)} |
| 111 | + {#if val !== min && val !== max} |
112 | 112 | <span |
113 | 113 | class="pip" |
114 | | - class:selected={isSelected( |
115 | | - getValueFromIndex(i, min, max, pipStep, step), |
116 | | - values, |
117 | | - precision |
118 | | - )} |
119 | | - class:in-range={isInRange(getValueFromIndex(i, min, max, pipStep, step), values, range)} |
120 | | - style="{orientationStart}: {valueAsPercent( |
121 | | - getValueFromIndex(i, min, max, pipStep, step), |
122 | | - min, |
123 | | - max |
124 | | - )}%;" |
| 114 | + class:selected={isSelected(val, values, precision)} |
| 115 | + class:in-range={isInRange(val, values, range)} |
| 116 | + style="{orientationStart}: {valueAsPercent(val, min, max, precision)}%;" |
| 117 | + data-val={val} |
125 | 118 | on:pointerdown={(e) => { |
126 | 119 | labelDown(e); |
127 | 120 | }} |
128 | 121 | on:pointerup={(e) => { |
129 | | - labelUp(getValueFromIndex(i, min, max, pipStep, step), e); |
| 122 | + labelUp(val, e); |
130 | 123 | }} |
131 | 124 | > |
132 | 125 | {#if all === 'label' || rest === 'label'} |
133 | 126 | <span class="pipVal"> |
134 | | - {#if prefix}<span class="pipVal-prefix">{prefix}</span>{/if}{@html formatter( |
135 | | - getValueFromIndex(i, min, max, pipStep, step), |
136 | | - i, |
137 | | - valueAsPercent(getValueFromIndex(i, min, max, pipStep, step), min, max, precision) |
138 | | - )}{#if suffix}<span class="pipVal-suffix">{suffix}</span>{/if} |
| 127 | + {#if true || prefix}<span class="pipVal-prefix">{prefix}</span>{/if} |
| 128 | + {@html formatter(val, i, valueAsPercent(val, min, max, precision))} |
| 129 | + {#if true || suffix}<span class="pipVal-suffix">{suffix}</span>{/if} |
139 | 130 | </span> |
140 | 131 | {/if} |
141 | 132 | </span> |
|
149 | 140 | class:selected={isSelected(max, values, precision)} |
150 | 141 | class:in-range={isInRange(max, values, range)} |
151 | 142 | style="{orientationStart}: 100%;" |
| 143 | + data-val={coerceFloat(max, precision)} |
152 | 144 | on:pointerdown={(e) => { |
153 | 145 | labelDown(e); |
154 | 146 | }} |
|
158 | 150 | > |
159 | 151 | {#if all === 'label' || last === 'label'} |
160 | 152 | <span class="pipVal"> |
161 | | - {#if prefix}<span class="pipVal-prefix">{prefix}</span>{/if}{@html formatter( |
162 | | - coerceFloat(max), |
163 | | - pipCount, |
164 | | - 100 |
165 | | - )}{#if suffix}<span class="pipVal-suffix">{suffix}</span>{/if} |
| 153 | + {#if prefix}<span class="pipVal-prefix">{prefix}</span>{/if} |
| 154 | + {@html formatter(coerceFloat(max, precision), pipCount, 100)} |
| 155 | + {#if suffix}<span class="pipVal-suffix">{suffix}</span>{/if} |
166 | 156 | </span> |
167 | 157 | {/if} |
168 | 158 | </span> |
|
223 | 213 | position: absolute; |
224 | 214 | top: 0.4em; |
225 | 215 | transform: translate(-50%, 25%); |
| 216 | + display: inline-flex; |
226 | 217 | } |
227 | 218 |
|
228 | 219 | :global(.rangePips.vertical .pipVal) { |
|
0 commit comments