Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

Commit

Permalink
feat(SlideGroup): added touch support
Browse files Browse the repository at this point in the history
  • Loading branch information
TheComputerM committed Sep 22, 2020
1 parent 5305b3d commit d18e33b
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
x -= wrapperWidth;
}
let touchStartX;
function touchstart({ touches }) {
touchStartX = x + touches[0].clientX;
}
function touchmove({ touches }) {
x = touchStartX - touches[0].clientX;
}
$: arrowsVisible = wrapperWidth < contentWidth && showArrows;
</script>

Expand All @@ -75,7 +84,11 @@
</slot>
</div>
{/if}
<div class="s-slide-group__wrapper" bind:clientWidth={wrapperWidth}>
<div
class="s-slide-group__wrapper"
on:touchstart={touchstart}
on:touchmove={touchmove}
bind:clientWidth={wrapperWidth}>
<div
class="s-slide-group__content"
style="transform:translate(-{x}px)"
Expand Down

0 comments on commit d18e33b

Please sign in to comment.