Merge commit 'ae95373f794fb8977d95e7e8715f1c59ba141bc3'

This commit is contained in:
d 2016-02-22 10:59:27 -05:00
commit 43c400db8c
6 changed files with 13 additions and 9 deletions

View file

@ -453,6 +453,7 @@ Changes
- add `setGridWidth` method ([#227](https://github.com/troolee/gridstack.js/issues/227))
- add `removable`/`removeTimeout`
- add `detachGrid` parameter to `destroy` method ([#216](https://github.com/troolee/gridstack.js/issues/216))
- add `useOffset` parameter to `getCellFromPixel` method ([#237](https://github.com/troolee/gridstack.js/issues/237))
#### v0.2.4 (2016-02-15)

5
dist/gridstack.js vendored
View file

@ -1300,8 +1300,9 @@
return Math.ceil(o.outerWidth() / o.attr('data-gs-width'));
};
GridStack.prototype.getCellFromPixel = function(position) {
var containerPos = this.container.position();
GridStack.prototype.getCellFromPixel = function(position, useOffset) {
var containerPos = (typeof useOffset != 'undefined' && useOffset) ?
this.container.offset() : this.container.position();
var relativeLeft = position.left - containerPos.left;
var relativeTop = position.top - containerPos.top;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -28,7 +28,7 @@ gridstack.js API
- [enable()](#enable)
- [enableMove(doEnable, includeNewWidgets)](#enablemovedoenable-includenewwidgets)
- [enableResize(doEnable, includeNewWidgets)](#enableresizedoenable-includenewwidgets)
- [getCellFromPixel(position)](#getcellfrompixelposition)
- [getCellFromPixel(position[, useOffset])](#getcellfrompixelposition-useoffset)
- [isAreaEmpty(x, y, width, height)](#isareaemptyx-y-width-height)
- [locked(el, val)](#lockedel-val)
- [makeWidget(el)](#makewidgetel)
@ -262,13 +262,14 @@ Enables/disables widget resizing. `includeNewWidgets` will force new widgets to
grid.resizable(this.container.children('.' + this.opts.itemClass), doEnable);
```
### getCellFromPixel(position)
### getCellFromPixel(position[, useOffset])
Get the position of the cell under a pixel on screen.
Parameters :
- `position` - the position of the pixel to resolve in absolute coordinates, as an object with `top` and `left`properties
- `position` - the position of the pixel to resolve in absolute coordinates, as an object with `top` and `left` properties
- `useOffset` - if `true`, value will be based on offset vs position (Optional. Default `false`). Useful when grid is within `position: relative` element.
Returns an object with properties `x` and `y` i.e. the column and row in the grid.

View file

@ -1300,8 +1300,9 @@
return Math.ceil(o.outerWidth() / o.attr('data-gs-width'));
};
GridStack.prototype.getCellFromPixel = function(position) {
var containerPos = this.container.position();
GridStack.prototype.getCellFromPixel = function(position, useOffset) {
var containerPos = (typeof useOffset != 'undefined' && useOffset) ?
this.container.offset() : this.container.position();
var relativeLeft = position.left - containerPos.left;
var relativeTop = position.top - containerPos.top;