#237 Add optional useOffset parameter to getCellFromPixel.
This commit is contained in:
parent
1039368121
commit
78803147c6
|
@ -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
5
dist/gridstack.js
vendored
|
@ -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;
|
||||
|
||||
|
|
2
dist/gridstack.min.js
vendored
2
dist/gridstack.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/gridstack.min.map
vendored
2
dist/gridstack.min.map
vendored
File diff suppressed because one or more lines are too long
|
@ -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.
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue