From cdd0242f4a088d4647277ddd3f4d59376a97398b Mon Sep 17 00:00:00 2001 From: mertsincan Date: Fri, 16 Apr 2021 10:40:59 +0300 Subject: [PATCH] Fixed #1960 - Touch event is not working on ColorPicker --- src/components/colorpicker/ColorPicker.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/colorpicker/ColorPicker.js b/src/components/colorpicker/ColorPicker.js index 66a39bd8bf..96c9bffba8 100644 --- a/src/components/colorpicker/ColorPicker.js +++ b/src/components/colorpicker/ColorPicker.js @@ -109,7 +109,7 @@ export class ColorPicker extends Component { pickHue(event) { let top = this.hueView.getBoundingClientRect().top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0); this.hsbValue = this.validateHSB({ - h: Math.floor(360 * (150 - Math.max(0, Math.min(150, (event.pageY - top)))) / 150), + h: Math.floor(360 * (150 - Math.max(0, Math.min(150, ((event.pageY || event.changedTouches[0].pageY) - top)))) / 150), s: 100, b: 100 }); @@ -172,8 +172,8 @@ export class ColorPicker extends Component { let rect = this.colorSelector.getBoundingClientRect(); let top = rect.top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0); let left = rect.left + document.body.scrollLeft; - let saturation = Math.floor(100 * (Math.max(0, Math.min(150, (event.pageX - left)))) / 150); - let brightness = Math.floor(100 * (150 - Math.max(0, Math.min(150, (event.pageY - top)))) / 150); + let saturation = Math.floor(100 * (Math.max(0, Math.min(150, ((event.pageX || event.changedTouches[0].pageX)- left)))) / 150); + let brightness = Math.floor(100 * (150 - Math.max(0, Math.min(150, ((event.pageY || event.changedTouches[0].pageY) - top)))) / 150); this.hsbValue = this.validateHSB({ h: this.hsbValue.h, s: saturation,