Skip to content

Commit d0deded

Browse files
authored
Merge pull request #185 from simeydotme/copilot/fix-be1021b5-67a0-4595-9618-36cb02a1ea8b
Fix pip label clicks with prefix/suffix not moving handle to correct value
2 parents 721bafc + 523246d commit d0deded

File tree

10 files changed

+357
-58
lines changed

10 files changed

+357
-58
lines changed

dist/range-slider-pips.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
2-
* svelte-range-slider-pips ~ 4.0.8
2+
* svelte-range-slider-pips ~ 4.1.0
33
* Multi-Thumb, Accessible, Beautiful Range Slider with Pips
44
* Project home: https://simeydotme.github.io/svelte-range-slider-pips/
55
* © 2025 Simon Goellner <simey.me@gmail.com> ~ MPL-2.0 License
6-
* Published: 3/10/2025
6+
* Published: 6/10/2025
77
*/
88
(function (global, factory) {
99
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -1993,8 +1993,8 @@
19931993
let html_tag;
19941994
let raw_value = /*formatter*/ ctx[16](/*val*/ ctx[37], /*i*/ ctx[39], valueAsPercent(/*val*/ ctx[37], /*min*/ ctx[1], /*max*/ ctx[2], /*precision*/ ctx[17])) + "";
19951995
let t1;
1996-
let if_block0 = create_if_block_8$1(ctx);
1997-
let if_block1 = create_if_block_7$1(ctx);
1996+
let if_block0 = /*prefix*/ ctx[14] && create_if_block_8$1(ctx);
1997+
let if_block1 = /*suffix*/ ctx[15] && create_if_block_7$1(ctx);
19981998

19991999
return {
20002000
c() {
@@ -2016,26 +2016,32 @@
20162016
if (if_block1) if_block1.m(span, null);
20172017
},
20182018
p(ctx, dirty) {
2019-
{
2019+
if (/*prefix*/ ctx[14]) {
20202020
if (if_block0) {
20212021
if_block0.p(ctx, dirty);
20222022
} else {
20232023
if_block0 = create_if_block_8$1(ctx);
20242024
if_block0.c();
20252025
if_block0.m(span, t0);
20262026
}
2027+
} else if (if_block0) {
2028+
if_block0.d(1);
2029+
if_block0 = null;
20272030
}
20282031

20292032
if (dirty[0] & /*formatter, min, max, finalPipStep, step, precision*/ 2293774 && raw_value !== (raw_value = /*formatter*/ ctx[16](/*val*/ ctx[37], /*i*/ ctx[39], valueAsPercent(/*val*/ ctx[37], /*min*/ ctx[1], /*max*/ ctx[2], /*precision*/ ctx[17])) + "")) html_tag.p(raw_value);
20302033

2031-
{
2034+
if (/*suffix*/ ctx[15]) {
20322035
if (if_block1) {
20332036
if_block1.p(ctx, dirty);
20342037
} else {
20352038
if_block1 = create_if_block_7$1(ctx);
20362039
if_block1.c();
20372040
if_block1.m(span, null);
20382041
}
2042+
} else if (if_block1) {
2043+
if_block1.d(1);
2044+
if_block1 = null;
20392045
}
20402046
},
20412047
d(detaching) {
@@ -2049,7 +2055,7 @@
20492055
};
20502056
}
20512057

2052-
// (137:14) {#if true || prefix}
2058+
// (137:14) {#if prefix}
20532059
function create_if_block_8$1(ctx) {
20542060
let span;
20552061
let t;
@@ -2075,7 +2081,7 @@
20752081
};
20762082
}
20772083

2078-
// (139:14) {#if true || suffix}
2084+
// (139:14) {#if suffix}
20792085
function create_if_block_7$1(ctx) {
20802086
let span;
20812087
let t;
@@ -4561,7 +4567,7 @@
45614567

45624568
// for touch devices we want the handle to instantly
45634569
// move to the position touched for more responsive feeling
4564-
if (event.type === 'touchstart' && !target.matches('.rsPipVal')) {
4570+
if (event.type === 'touchstart' && !target.closest('.rsPipVal')) {
45654571
handleInteract(clientPos);
45664572
}
45674573
}
@@ -4634,7 +4640,7 @@
46344640

46354641
// don't trigger interact if the target is a handle (no need) or
46364642
// if the target is a label (we want to move to that value from rangePips)
4637-
if (!targetIsHandle(target) && !target.matches('.rsPipVal')) {
4643+
if (!targetIsHandle(target) && !target.closest('.rsPipVal')) {
46384644
handleInteract(normalisedClient(event));
46394645
}
46404646
}

dist/range-slider-pips.mjs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
2-
* svelte-range-slider-pips ~ 4.0.8
2+
* svelte-range-slider-pips ~ 4.1.0
33
* Multi-Thumb, Accessible, Beautiful Range Slider with Pips
44
* Project home: https://simeydotme.github.io/svelte-range-slider-pips/
55
* © 2025 Simon Goellner <simey.me@gmail.com> ~ MPL-2.0 License
6-
* Published: 3/10/2025
6+
* Published: 6/10/2025
77
*/
88
/** @returns {void} */
99
function noop() {}
@@ -1987,8 +1987,8 @@ function create_if_block_6$1(ctx) {
19871987
let html_tag;
19881988
let raw_value = /*formatter*/ ctx[16](/*val*/ ctx[37], /*i*/ ctx[39], valueAsPercent(/*val*/ ctx[37], /*min*/ ctx[1], /*max*/ ctx[2], /*precision*/ ctx[17])) + "";
19891989
let t1;
1990-
let if_block0 = create_if_block_8$1(ctx);
1991-
let if_block1 = create_if_block_7$1(ctx);
1990+
let if_block0 = /*prefix*/ ctx[14] && create_if_block_8$1(ctx);
1991+
let if_block1 = /*suffix*/ ctx[15] && create_if_block_7$1(ctx);
19921992

19931993
return {
19941994
c() {
@@ -2010,26 +2010,32 @@ function create_if_block_6$1(ctx) {
20102010
if (if_block1) if_block1.m(span, null);
20112011
},
20122012
p(ctx, dirty) {
2013-
{
2013+
if (/*prefix*/ ctx[14]) {
20142014
if (if_block0) {
20152015
if_block0.p(ctx, dirty);
20162016
} else {
20172017
if_block0 = create_if_block_8$1(ctx);
20182018
if_block0.c();
20192019
if_block0.m(span, t0);
20202020
}
2021+
} else if (if_block0) {
2022+
if_block0.d(1);
2023+
if_block0 = null;
20212024
}
20222025

20232026
if (dirty[0] & /*formatter, min, max, finalPipStep, step, precision*/ 2293774 && raw_value !== (raw_value = /*formatter*/ ctx[16](/*val*/ ctx[37], /*i*/ ctx[39], valueAsPercent(/*val*/ ctx[37], /*min*/ ctx[1], /*max*/ ctx[2], /*precision*/ ctx[17])) + "")) html_tag.p(raw_value);
20242027

2025-
{
2028+
if (/*suffix*/ ctx[15]) {
20262029
if (if_block1) {
20272030
if_block1.p(ctx, dirty);
20282031
} else {
20292032
if_block1 = create_if_block_7$1(ctx);
20302033
if_block1.c();
20312034
if_block1.m(span, null);
20322035
}
2036+
} else if (if_block1) {
2037+
if_block1.d(1);
2038+
if_block1 = null;
20332039
}
20342040
},
20352041
d(detaching) {
@@ -2043,7 +2049,7 @@ function create_if_block_6$1(ctx) {
20432049
};
20442050
}
20452051

2046-
// (137:14) {#if true || prefix}
2052+
// (137:14) {#if prefix}
20472053
function create_if_block_8$1(ctx) {
20482054
let span;
20492055
let t;
@@ -2069,7 +2075,7 @@ function create_if_block_8$1(ctx) {
20692075
};
20702076
}
20712077

2072-
// (139:14) {#if true || suffix}
2078+
// (139:14) {#if suffix}
20732079
function create_if_block_7$1(ctx) {
20742080
let span;
20752081
let t;
@@ -4555,7 +4561,7 @@ function instance($$self, $$props, $$invalidate) {
45554561

45564562
// for touch devices we want the handle to instantly
45574563
// move to the position touched for more responsive feeling
4558-
if (event.type === 'touchstart' && !target.matches('.rsPipVal')) {
4564+
if (event.type === 'touchstart' && !target.closest('.rsPipVal')) {
45594565
handleInteract(clientPos);
45604566
}
45614567
}
@@ -4628,7 +4634,7 @@ function instance($$self, $$props, $$invalidate) {
46284634

46294635
// don't trigger interact if the target is a handle (no need) or
46304636
// if the target is a label (we want to move to that value from rangePips)
4631-
if (!targetIsHandle(target) && !target.matches('.rsPipVal')) {
4637+
if (!targetIsHandle(target) && !target.closest('.rsPipVal')) {
46324638
handleInteract(normalisedClient(event));
46334639
}
46344640
}

dist/svelte/components/RangePips.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ function labelUp(pipValue, event) {
121121
>
122122
{#if all === 'label' || rest === 'label'}
123123
<span class="rsPipVal">
124-
{#if true || prefix}<span class="rsPipValPrefix">{prefix}</span>{/if}
124+
{#if prefix}<span class="rsPipValPrefix">{prefix}</span>{/if}
125125
{@html formatter(val, i, valueAsPercent(val, min, max, precision))}
126-
{#if true || suffix}<span class="rsPipValSuffix">{suffix}</span>{/if}
126+
{#if suffix}<span class="rsPipValSuffix">{suffix}</span>{/if}
127127
</span>
128128
{/if}
129129
</span>

dist/svelte/components/RangeSlider.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ function sliderInteractStart(event) {
440440
handleActivated = true;
441441
handlePressed = true;
442442
activeHandle = getClosestHandle(clientPos);
443-
if (event.type === "touchstart" && !target.matches(".rsPipVal")) {
443+
if (event.type === "touchstart" && !target.closest(".rsPipVal")) {
444444
handleInteract(clientPos);
445445
}
446446
}
@@ -477,7 +477,7 @@ function bodyMouseUp(event) {
477477
if (handleActivated) {
478478
if (slider && (target === slider || slider.contains(target))) {
479479
focus = true;
480-
if (!targetIsHandle(target) && !target.matches(".rsPipVal")) {
480+
if (!targetIsHandle(target) && !target.closest(".rsPipVal")) {
481481
handleInteract(normalisedClient(event));
482482
}
483483
}

package-lock.json

Lines changed: 4 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelte-range-slider-pips",
3-
"version": "4.0.8",
3+
"version": "4.1.0",
44
"description": "Multi-Thumb, Accessible, Beautiful Range Slider with Pips",
55
"repository": {
66
"type": "git",

src/lib/components/RangePips.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@
159159
>
160160
{#if all === 'label' || rest === 'label'}
161161
<span class="rsPipVal">
162-
{#if true || prefix}<span class="rsPipValPrefix">{prefix}</span>{/if}
162+
{#if prefix}<span class="rsPipValPrefix">{prefix}</span>{/if}
163163
{@html formatter(val, i, valueAsPercent(val, min, max, precision))}
164-
{#if true || suffix}<span class="rsPipValSuffix">{suffix}</span>{/if}
164+
{#if suffix}<span class="rsPipValSuffix">{suffix}</span>{/if}
165165
</span>
166166
{/if}
167167
</span>

src/lib/components/RangeSlider.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@
672672
activeHandle = getClosestHandle(clientPos);
673673
// for touch devices we want the handle to instantly
674674
// move to the position touched for more responsive feeling
675-
if (event.type === 'touchstart' && !target.matches('.rsPipVal')) {
675+
if (event.type === 'touchstart' && !target.closest('.rsPipVal')) {
676676
handleInteract(clientPos);
677677
}
678678
}
@@ -740,7 +740,7 @@
740740
focus = true;
741741
// don't trigger interact if the target is a handle (no need) or
742742
// if the target is a label (we want to move to that value from rangePips)
743-
if (!targetIsHandle(target) && !target.matches('.rsPipVal')) {
743+
if (!targetIsHandle(target) && !target.closest('.rsPipVal')) {
744744
handleInteract(normalisedClient(event));
745745
}
746746
}

0 commit comments

Comments
 (0)