From 1f6e4f3a3749b4c0aaf3e85b88d929c0a24db4f9 Mon Sep 17 00:00:00 2001 From: Elliott Marquez Date: Wed, 27 Sep 2023 14:27:08 -0700 Subject: [PATCH] fix(slider): slider knob has size to drag on ios safari fixes #5016 PiperOrigin-RevId: 568960672 --- slider/internal/_slider.scss | 38 +++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/slider/internal/_slider.scss b/slider/internal/_slider.scss index a1ac7939217..c6c8a77e275 100644 --- a/slider/internal/_slider.scss +++ b/slider/internal/_slider.scss @@ -430,13 +430,41 @@ $_md-sys-shape: tokens.md-sys-shape-values(); ::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; - // note, this is sized to align with thumb but is 0 width so that - // fine adjustments are possible - block-size: var(--_state-layer-size); - inline-size: var(--_state-layer-size); - transform: scaleX(0); + // note, this is sized to align with thumb + block-size: var(--_handle-height); + inline-size: var(--_handle-width); opacity: 0; z-index: 2; + // Webkit on iOS requires some size to the thumb. We want to make this the + // same as --_handle-size but also be centered on the handle. + --_x-translate: calc( + (0.5 - var(--_start-fraction, 0)) * var(--_handle-width) + ); + } + + // native input range knob size for safari – it needs a size that's nonzero + input.start::-webkit-slider-thumb { + transform: translateX(var(--_x-translate)); + } + + input.end::-webkit-slider-thumb { + transform: translateX(calc(-1 * var(--_x-translate))); + } + + @each $_rtl-selectors + in _get-rtl-selectors('input.start', '::-webkit-slider-thumb') + { + #{$_rtl-selectors} { + transform: translateX(calc(-1 * var(--_x-translate))); + } + } + + @each $_rtl-selectors + in _get-rtl-selectors('input.end', '::-webkit-slider-thumb') + { + #{$_rtl-selectors} { + transform: translateX(var(--_x-translate)); + } } ::-moz-range-thumb {