Giter Site home page Giter Site logo

Comments (17)

bierik avatar bierik commented on July 17, 2024 2

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.

bierik avatar bierik commented on July 17, 2024 1

@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.

bierik avatar bierik commented on July 17, 2024 1

@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.

bierik avatar bierik commented on July 17, 2024 1

Maybe closed thru #27

from cypress-drag-drop.

bierik avatar bierik commented on July 17, 2024

@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.

bierik avatar bierik commented on July 17, 2024

@Kamar-Meddah Any update here?

from cypress-drag-drop.

tobiasbueschel avatar tobiasbueschel commented on July 17, 2024

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.

Kamar-Meddah avatar Kamar-Meddah commented on July 17, 2024

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.

bierik avatar bierik commented on July 17, 2024

@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.

bierik avatar bierik commented on July 17, 2024

@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.

Kamar-Meddah avatar Kamar-Meddah commented on July 17, 2024

@bierik think of it as translate(x,y) in css

from cypress-drag-drop.

Kamar-Meddah avatar Kamar-Meddah commented on July 17, 2024

@bierik yes that's it

from cypress-drag-drop.

bierik avatar bierik commented on July 17, 2024

@Kamar-Meddah What do you think about my suggestion? Would this help?

from cypress-drag-drop.

Kamar-Meddah avatar Kamar-Meddah commented on July 17, 2024

@Kamar-Meddah What do you think about my suggestion? Would this help?

yes a lot

from cypress-drag-drop.

nnaidenov avatar nnaidenov commented on July 17, 2024

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.

lucidity-joe avatar lucidity-joe commented on July 17, 2024

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.

bierik avatar bierik commented on July 17, 2024

@lucidity-joe According to my tests, this is working.
Example with center
image
Example with left
image
You may want to try the newest version.

from cypress-drag-drop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.