Skip to content

Commit

Permalink
#46 jquery remove and convert to pure javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
AgriyaDev5 committed Feb 3, 2021
1 parent 4740cce commit eaa65b1
Show file tree
Hide file tree
Showing 4 changed files with 251 additions and 190 deletions.
20 changes: 10 additions & 10 deletions src/editor/components/jgraduate/ColorValuePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,16 @@ export default class ColorValuePicker {
*/
function colorChanged (ui, context) {
const all = ui.val('all');
if (context !== red.get(0)) red.val(!isNullish(all) ? all.r : '');
if (context !== green.get(0)) green.val(!isNullish(all) ? all.g : '');
if (context !== blue.get(0)) blue.val(!isNullish(all) ? all.b : '');
if (alpha && context !== alpha.get(0)) alpha.val(!isNullish(all) ? toFixedNumeric((all.a * 100) / 255, alphaPrecision) : '');
if (context !== hue.get(0)) hue.val(!isNullish(all) ? all.h : '');
if (context !== saturation.get(0)) saturation.val(!isNullish(all) ? all.s : '');
if (context !== value.get(0)) value.val(!isNullish(all) ? all.v : '');
if (context !== hex.get(0) && ((bindedHex && context !== bindedHex.get(0)) || !bindedHex)) hex.val(!isNullish(all) ? all.hex : '');
if (bindedHex && context !== bindedHex.get(0) && context !== hex.get(0)) bindedHex.val(!isNullish(all) ? all.hex : '');
if (ahex && context !== ahex.get(0)) ahex.val(!isNullish(all) ? all.ahex.substring(6) : '');
if (context !== red) red.value = (!isNullish(all) ? all.r : '');
if (context !== green) green.value = (!isNullish(all) ? all.g : '');
if (context !== blue) blue.value = (!isNullish(all) ? all.b : '');
if (alpha && context !== alpha) alpha.value = (!isNullish(all) ? toFixedNumeric((all.a * 100) / 255, alphaPrecision) : '');
if (context !== hue) hue.value = (!isNullish(all) ? all.h : '');
if (context !== saturation) saturation.value = (!isNullish(all) ? all.s : '');
if (context !== value) value.value = (!isNullish(all) ? all.v : '');
if (context !== hex && ((bindedHex && context !== bindedHex) || !bindedHex)) hex.value = (!isNullish(all) ? all.hex : '');
if (bindedHex && context !== bindedHex && context !== hex) bindedHex.value = (!isNullish(all) ? all.hex : '');
if (ahex && context !== ahex) ahex.value = (!isNullish(all) ? all.ahex.substring(6) : '');
}
/**
* Unbind all events and null objects.
Expand Down
20 changes: 16 additions & 4 deletions src/editor/components/jgraduate/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
const isNullish = (val) => {
return val === null || val === undefined;
};
function findPos (obj) {
let curleft = 0;
let curtop = 0;
if (obj.offsetParent) {
do {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
return {left: curleft, top: curtop};
}
return {left: curleft, top: curtop};
}
/**
* Encapsulate slider functionality for the ColorMap and ColorBar -
* could be useful to use a jQuery UI draggable for this with certain extensions.
Expand Down Expand Up @@ -39,7 +51,7 @@ export default class Slider {
* @returns {void}
*/
function mouseDown (e) {
const off = bar.offset();
const off = findPos(bar);
offset = {l: off.left | 0, t: off.top | 0};
clearTimeout(timeout);
// using setTimeout for visual updates - once the style is updated the browser will re-render internally allowing the next Javascript to run
Expand Down Expand Up @@ -130,9 +142,9 @@ export default class Slider {
if (arrowH >= barH) arrowOffsetY = (barH >> 1) - (arrowH >> 1);
else arrowOffsetY -= arrowH >> 1;
// set the arrow position based on these offsets
arrow.css({left: arrowOffsetX + 'px', top: arrowOffsetY + 'px'});
// arrow.style.left = arrowOffsetX + 'px';
// arrow.style.top = arrowOffsetY + 'px';
// arrow.css({left: arrowOffsetX + 'px', top: arrowOffsetY + 'px'});
arrow.style.left = arrowOffsetX + 'px';
arrow.style.top = arrowOffsetY + 'px';
});
}

Expand Down
Loading

0 comments on commit eaa65b1

Please sign in to comment.