mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
fixed issue with color controllers on scrolling pages. Fixes #37
This commit is contained in:
parent
0aec885446
commit
6f0fcb64f5
@ -194,10 +194,9 @@ class ColorController extends Controller {
|
|||||||
function setSV(e) {
|
function setSV(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const w = dom.getWidth(_this.__saturation_field);
|
const fieldRect = _this.__saturation_field.getBoundingClientRect();
|
||||||
const o = dom.getOffset(_this.__saturation_field);
|
let s = (e.clientX - fieldRect.left) / (fieldRect.right - fieldRect.left);
|
||||||
let s = (e.clientX - o.left + document.body.scrollLeft) / w;
|
let v = 1 - (e.clientY - fieldRect.top) / (fieldRect.bottom - fieldRect.top);
|
||||||
let v = 1 - (e.clientY - o.top + document.body.scrollTop) / w;
|
|
||||||
|
|
||||||
if (v > 1) {
|
if (v > 1) {
|
||||||
v = 1;
|
v = 1;
|
||||||
@ -223,9 +222,8 @@ class ColorController extends Controller {
|
|||||||
function setH(e) {
|
function setH(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const s = dom.getHeight(_this.__hue_field);
|
const fieldRect = _this.__hue_field.getBoundingClientRect();
|
||||||
const o = dom.getOffset(_this.__hue_field);
|
let h = 1 - (e.clientY - fieldRect.top) / (fieldRect.bottom - fieldRect.top);
|
||||||
let h = 1 - (e.clientY - o.top + document.body.scrollTop) / s;
|
|
||||||
|
|
||||||
if (h > 1) {
|
if (h > 1) {
|
||||||
h = 1;
|
h = 1;
|
||||||
|
@ -62,11 +62,10 @@ class NumberControllerSlider extends NumberController {
|
|||||||
function onMouseDrag(e) {
|
function onMouseDrag(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const offset = dom.getOffset(_this.__background);
|
const bgRect = _this.__background.getBoundingClientRect();
|
||||||
const width = dom.getWidth(_this.__background);
|
|
||||||
|
|
||||||
_this.setValue(
|
_this.setValue(
|
||||||
map(e.clientX, offset.left, offset.left + width, _this.__min, _this.__max)
|
map(e.clientX, bgRect.left, bgRect.right, _this.__min, _this.__max)
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user