Comments (17)
So to not mix the concept of .drag
with our new approach. I would suggest providing a child command that looks like this:
cy.get('.sourceitem').move({ x: 200, y: 20 })
. Because the target element makes no sense in that case, right?
from cypress-drag-drop.
@Kamar-Meddah So you mean when grabbing an element with cy.get('.sourceitem').drag('.targetitem', { x: 200, y: 20 })
means that you drag the source element and move it 200px in x direction and 20px in y direction relative to the position of the sourceitem. Am I understanding this correctly?
from cypress-drag-drop.
@Kamar-Meddah @nnaidenov @tobiasbueschel I opened a PR implementing the move
feature: #27
Please feel free to try out if it suits your needs. I would also appreciate feedback and comments in the PR. Thank you all.
from cypress-drag-drop.
Maybe closed thru #27
from cypress-drag-drop.
@Kamar-Meddah thank you for the improvement proposal.
According to the cypress docs it is possible to pass coordinates to the trigger method: https://docs.cypress.io/api/commands/trigger.html#Coordinates
But the coordinates are always relative to the top left corner. But in your example, you pass the position relative to the bottom left.
Do you have a concrete use case? Maybe there's an other solution.
from cypress-drag-drop.
@Kamar-Meddah Any update here?
from cypress-drag-drop.
Thanks for raising this @Kamar-Meddah --> I'm also looking for the same functionality. The use case that I have is a calendar element and I want to test that I can drag and drop events in a canvas container.
from cypress-drag-drop.
you're welcome @tobiasbueschel and @bierik your library work greate thx but what i asked you is that instead of using words like (topLeft, top, topRight, left, center, right, bottomLeft, bottom, and bottomRight.)
we use cordinates it doesn't matter if it is relative to the top left corner
from cypress-drag-drop.
@Kamar-Meddah @tobiasbueschel Sorry for the late response.
What about having something like this:
cy.get('.sourceitem').drag('.targetitem', {
x: 30,
y: 60
});
// or
cy.get('.sourceitem').drag('.targetitem', { position: 'topLeft' });
This way we would have a similar behavior of https://docs.cypress.io/api/commands/trigger.html#Syntax.
And when providing both x
, y
and position
an error should be thrown.
from cypress-drag-drop.
@Kamar-Meddah @tobiasbueschel In #11 I am discussing a similar issue. But there we want to control the position where to grab the element. To make this work with both drag
and drop
I would better suggest having something like:
cy.get('.sourceitem').drag('.targetitem', { drag: { x: 30, y: 60 } });
// or
cy.get('.sourceitem').drag('.targetitem', { drag: { position: 'topLeft' } });
// or
cy.get('.sourceitem').drag('.targetitem', { drop: { x: 30, y: 60 } });
// or
cy.get('.sourceitem').drag('.targetitem', { drag: { x: 30, y: 60 }, drop: { x: 30, y: 60 } });
This way we could cover both options.
from cypress-drag-drop.
@bierik think of it as translate(x,y) in css
from cypress-drag-drop.
@bierik yes that's it
from cypress-drag-drop.
@Kamar-Meddah What do you think about my suggestion? Would this help?
from cypress-drag-drop.
@Kamar-Meddah What do you think about my suggestion? Would this help?
yes a lot
from cypress-drag-drop.
I will be very happy to see this functionality. We need this in our projects and for now we need to implement drag and drop with pure Cypress functions.
from cypress-drag-drop.
I am trying to use position as shown in the docs and it does not appear to affect the part of the element cypress is interacting with.
My code is similar to:
cy.get(element).drag(targetElement, { position: 'center' })
Running the test using cypress browser, if I highlight the steps associated with this code it shows the cursor in the 'top' position
from cypress-drag-drop.
@lucidity-joe According to my tests, this is working.
Example with center
Example with left
You may want to try the newest version.
from cypress-drag-drop.
Related Issues (20)
- cypress drag not working with version 2.2.1 HOT 1
- Drag drop 2.2.1 not working with Cypress 10.7.0 HOT 1
- Drag and Drop issue in Iframe
- Drop stopped working after the second drag and drop HOT 3
- Cypress 11 support HOT 10
- Type error when trying to chain drag(...).then(...) HOT 1
- Cypress 12.0.2 not supported HOT 3
- Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.
- Allow specifying a relative position parameter when dragging the source element.
- Support for iFrame
- Publish into github packages
- Can not install with Cypress8.2.0 HOT 1
- Drag and drop is not working HOT 6
- Cypress Typescript error ts(2769) HOT 2
- conflicting dependencies cypress-drag-drop v2.2.4 with cypress v13.0.0 HOT 2
- cypress 13 support HOT 1
- Dragend event is missing HOT 1
- The drag action doesnt work without move the mouse and there is no .then() for drag HOT 1
- Drag and drop doesn't work with pointerup trigger for drop
- move seems to support the position argument although the documentation says otherwise
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cypress-drag-drop.