Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drag using keyboard arrow keys. (Angular) #141

Closed
iprasadg opened this issue Jan 2, 2020 · 7 comments
Closed

Drag using keyboard arrow keys. (Angular) #141

iprasadg opened this issue Jan 2, 2020 · 7 comments
Labels
Milestone

Comments

@iprasadg
Copy link

iprasadg commented Jan 2, 2020

For more better user experience I want to drag target on keyboard arrow keys. Is there any way to drag using keyboard arrow keys. I am in the middle of following.

document.addEventListener('keydown', (e) => {
   if (e.keyCode === 38) {
       // I think here I should trigger onDrag, but unable to trigger
   }
 });

Thanks in advance.

@daybrush daybrush added enhancement New feature or request Feature labels Jan 2, 2020
@daybrush
Copy link
Owner

daybrush commented Jan 2, 2020

@iprasadg

I think that's a good idea. I planned to add it later, but it's not easy.

This may seem a bit late, but I will try to do it fast.

@iprasadg
Copy link
Author

iprasadg commented Jan 2, 2020

@daybrush No issues. 👍 Thanks.

@daybrush daybrush added this to the 0.14.0 milestone Jan 6, 2020
@daybrush daybrush modified the milestones: 0.15.0, 0.16.0 Feb 3, 2020
daybrush added a commit that referenced this issue Feb 4, 2020
daybrush added a commit that referenced this issue Feb 4, 2020
daybrush added a commit that referenced this issue Feb 4, 2020
daybrush added a commit that referenced this issue Feb 5, 2020
daybrush added a commit that referenced this issue Feb 5, 2020
daybrush added a commit that referenced this issue Feb 5, 2020
@daybrush daybrush added the WIP label Feb 11, 2020
daybrush added a commit that referenced this issue Feb 20, 2020
…#177)

#141 #142 #172 #173 #179
* fix: fix snap directions

* fix: fix sizeDist for otherDirections

* refactor: fix resizable snap

* refactor: remove checkOneWayDist

* refactor: fix one way resize snap

* refactor: fix snap resize for keepRatio

* refactor: snap resize for [0, 0]

* fix: fix two way direction

* feat: add requestSigns

* fix: fix request snap

* fix: fix request for no request

* fix: fix resize snap for request

* fix: fix snap for scale

* fix: fix size snap for shake problem

* feat: add isDisplaySnapDigit props

* fix: fix package script

* feat: add innerBounds props #172

* feat: add innerBounds feature #172

* feat: add innerBounds feature #172

* fix: fix innerBounds' direction

* fix: fix innerBounds' size offset

* fix: fix bounds for fixed position

* fix: fix parseFloat

* feat: add innerBounds for drag

* feat: add innerBound drag snap

* fix: fix fixedPosition

* refactor: split snappable

* fix: fix innerBound for drag

* fix: fix throttleRotateDrag's work

* fix: fix snapInfo to snapDrag

* refactor: fix snapRotate

* fix: fix throttleRotateDrag snap

* fix: fix rotatable delta

* fix: fix rotatable for innerBounds

* feat: show innerBounds guidelines

* fix: remove useless code
@daybrush daybrush added WIP-complete and removed WIP labels Feb 20, 2020
@daybrush
Copy link
Owner

daybrush commented Mar 4, 2020

@iprasadg

  • moveable 0.15.1
  • react-moveable 0.18.0
  • preact-moveable 0.17.0
  • ngx-moveable 0.11.0
  • svelte-moveable 0.6.0

Added request method.

https://daybrush.com/moveable/release/latest/doc/Moveable.html#request

Draggable

https://daybrush.com/moveable/release/latest/doc/Moveable.Draggable.html#request

Resizable

https://daybrush.com/moveable/release/latest/doc/Moveable.Resizable.html#request

Scalable

https://daybrush.com/moveable/release/latest/doc/Moveable.Scalable.html#request

Rotatable

https://daybrush.com/moveable/release/latest/doc/Moveable.Rotatable.html#request

Applied to the main demo.

https://daybrush.com/moveable/

addControlEvent(controlXElement, value => {
moveable.request("draggable", { x: parseFloat(value), isInstant: true });
});
addControlEvent(controlYElement, value => {
moveable.request("draggable", { y: parseFloat(value), isInstant: true });
});
addControlEvent(controlWElement, value => {
moveable.request("resizable", { offsetWidth: parseFloat(value), isInstant: true });
});
addControlEvent(controlHElement, value => {
moveable.request("resizable", { offsetHeight: parseFloat(value), isInstant: true });
});
addControlEvent(controlRElement, value => {
moveable.request("rotatable", {
deltaRotate: parseFloat(value) - parseFloat(frame.get("transform", "rotate")),
isInstant: true,
});
});

@bxchang04
Copy link

In the main demo, if the keyboard arrow is held down, the feature eventually breaks for me (Chrome, latest ver.).

I think this is a bug. Can you please investigate? Thanks for this new feature!

@prabhatojha
Copy link

On top of keyboard support to drag item, I think it would be better to consider and display Horizontal, Vertical, Element guidelines suggestion. Just like how it does when we drag using Mouse.

Please let me know, if this feature is already there.

@marcosTenorio
Copy link

@daybrush is it possible to apply this request method, or a way to move the element with arrow keys, in this demo https://codesandbox.io/s/react-moveable-demo-jl69c?file=/src/index.js:4834-4840 ?

@xiaopujun
Copy link

moveable.request("draggable", { y: parseFloat(value), isInstant: true });

Hello, is it possible to pass custom parameters to the request API? After passing it can this parameter be received in the onDragEnd event of the Moveable component?
I checked the API documentation you provided and found that I can receive other custom parameters, but I can't seem to receive and process it. Or is there something wrong with the way I'm using it?

Here is my code:

 movableRef?.current?.request("draggable", {
            x: layoutItem!.position![0],
            y: layoutItem!.position![1],
            //this is my custom params
            datas: {backoff: true}
        }, true);
        
        
        
        <Moveable ref={this.movableRef}
                        //...
                          // I want to accept param here. Can it be supported at this time?
                          onDragEnd={this.onDragEnd}
                         //...
                />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants