Visitar URL original
Not receiving correct values from get_cell_from_pixel() · Issue #237 · gridstack/gridstack.js · GitHub
Skip to content

Not receiving correct values from get_cell_from_pixel() #237

Closed

Description

@DeadlyBrad42

I am attempting to use get_cell_from_pixel() to implement dragging and dropping items from another list to add them to my grid, but I'm not getting back the values I expect.

I'm passing in a position relative to the document, but since get_cell_from_pixel() internally compares that against this.container.position() (and since my grid is in a div with position:relative) the calculation is off.

From the name, I had assumed the function worked from a pixel position relative to the document. I was wondering if there was a reason you used this.container.position() instead of this.container.offset()? Or if there is, is it possible to add in an optional argument that would use this.container.offset()? If it's a feature you'd be interested in adding, I could implement it and create the PR myself if you'd like.

Activity

  1. added this to the v0.2.5 milestone on Feb 19, 2016
  2. added a commit that references this issue on Feb 22, 2016
  3. radiolips commented on Feb 22, 2016

    @radiolips
    Member

    @DeadlyBrad42 - apologies for the very long delay, but we're giving gridstack more attention now, and, as such, have added in the parameter you've recommended. getCellFromPixel now takes in an optional second parameter to use offset rather than position. Thanks for the suggestion to do this and recommendation to use offset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions