daybrush / moveable

Moveable! Draggable! Resizable! Scalable! Rotatable! Warpable! Pinchable! Groupable! Snappable!
https://daybrush.com/moveable/
MIT License
10.08k stars 618 forks source link

[BUG] resize could go outside the configured boundaries #253

Closed ctf0 closed 4 years ago

ctf0 commented 4 years ago

Environments

Description

movable .on('drag', ({target, left, top}) => { target.style.left = left < 0 ? 0 : left + 'px' target.style.top = top < 0 ? 0 : top + 'px' }) .on('resize', ({target, width, height, drag}) => { target.style.width = width + 'px' target.style.height = height + 'px' target.style.left = drag.left + 'px' target.style.top = drag.top + 'px' }) .on('rotate', ({target, delta}) => { let current = rotate + delta

    if (current > 180 || current < -180) {
        return false
    }

    target.style.transform = `rotate(${(Math.round(current))})deg`
})
daybrush commented 4 years ago

@ctf0 Since this is 50% to 50% transform-origin, I think it might be different.

ctf0 commented 4 years ago

@daybrush could u plz elaborate ?!!

daybrush commented 4 years ago

@ctf0

Oh. Sorry.

I am confused with the issue below. https://github.com/daybrush/moveable/issues/254

It's duplicate of #235 .

daybrush commented 4 years ago

@ctf0

moveable's new version is released. Check it again.

ctf0 commented 4 years ago

nothing changed unfortunately 😢

daybrush commented 4 years ago

@ctf0

I'm not sure why?

Add this code:

.on("resizeStart", ({ setOrigin }) => {
    setOrigin(["%", "%"]);
})

If not, wouldn't you give me a test address?

ctf0 commented 4 years ago

for the rotated example, it no longer flickers, but now the boundaries are calculated incorrectly.

still, i will prepare a demo and add it today, thank you for ur help.

ctf0 commented 4 years ago

https://jsfiddle.net/muah003/w2x9q04r/9/

daybrush commented 4 years ago

@ctf0

moveable's new version is released.

ctf0 commented 4 years ago

awesome, much appreciated.

btw is there a way to stop the resize once the boundaries are meet instead of the current ? as it flickers a little bit which kinda looks like the box is struggling to whether to resize or not.

daybrush commented 4 years ago

@ctf0

How about using max-width or max-height?

ctf0 commented 4 years ago

oh okay, will give it a go, thanx for the headsup