fix slider strange behavior when mouse left

also added / to all res references

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
Victor Seiji Hariki 2022-12-07 13:31:15 -03:00
parent de4823e749
commit 3c0eed68ce
7 changed files with 13 additions and 10 deletions

View file

@ -168,14 +168,17 @@ function createSlider(name, wrapper, options = {}) {
mouse.listen.window.btn.left.ondrag.on((evn) => {
if (evn.initialTarget === overEl) {
phantomRange.value = Math.max(
const newv = Math.max(
options.min,
Math.min(
options.max,
(evn.evn.layerX / wrapper.offsetWidth) * (options.max - options.min) +
((evn.evn.clientX - evn.initialTarget.getBoundingClientRect().left) /
wrapper.offsetWidth) *
(options.max - options.min) +
options.min
)
);
phantomRange.value = newv;
setValue(parseFloat(phantomRange.value));
}
});

View file

@ -37,7 +37,7 @@ const _color_brush_erase_callback = (evn, state, ctx) => {
const colorBrushTool = () =>
toolbar.registerTool(
"res/icons/brush.svg",
"/res/icons/brush.svg",
"Color Brush",
(state, opt) => {
// Draw new cursor immediately

View file

@ -819,7 +819,7 @@ const _dream_onwheel = (evn, state) => {
*/
const dreamTool = () =>
toolbar.registerTool(
"res/icons/image-plus.svg",
"/res/icons/image-plus.svg",
"Dream",
(state, opt) => {
// Draw new cursor immediately
@ -940,7 +940,7 @@ const dreamTool = () =>
{
min: 0,
max: 64,
step: 5,
step: 4,
textStep: 1,
}
).slider;
@ -959,7 +959,7 @@ const dreamTool = () =>
const img2imgTool = () =>
toolbar.registerTool(
"res/icons/image.svg",
"/res/icons/image.svg",
"Img2Img",
(state, opt) => {
// Draw new cursor immediately

View file

@ -1,6 +1,6 @@
const interrogateTool = () =>
toolbar.registerTool(
"res/icons/microscope.svg",
"/res/icons/microscope.svg",
"Interrogate",
(state, opt) => {
// Draw new cursor immediately

View file

@ -61,7 +61,7 @@ const _mask_brush_erase_callback = (evn, state, opacity = 100) => {
const maskBrushTool = () =>
toolbar.registerTool(
"res/icons/paintbrush.svg",
"/res/icons/paintbrush.svg",
"Mask Brush",
(state, opt) => {
// Draw new cursor immediately

View file

@ -1,6 +1,6 @@
const selectTransformTool = () =>
toolbar.registerTool(
"res/icons/box-select.svg",
"/res/icons/box-select.svg",
"Select Image",
(state, opt) => {
// Draw new cursor immediately

View file

@ -1,6 +1,6 @@
const stampTool = () =>
toolbar.registerTool(
"res/icons/file-up.svg",
"/res/icons/file-up.svg",
"Stamp Image",
(state, opt) => {
state.loaded = true;