Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bootstrap compat: support `offset(coordinates)`

References #642
  • Loading branch information...
commit a02f280a73acf1cd03463e87d3652f818244f628 1 parent 9e9682a
@mislav mislav authored
Showing with 13 additions and 1 deletion.
  1. +13 −1 src/zepto.js
View
14 src/zepto.js
@@ -552,7 +552,19 @@ var Zepto = (function() {
this.value = funcArg(this, value, idx, this.value)
})
},
- offset: function(){
+ offset: function(coordinates){
+ if (coordinates) return this.each(function(index){
+ var $this = $(this),
+ coords = funcArg(this, coordinates, index, $this.offset()),
+ parentOffset = $this.offsetParent().offset(),
+ props = {
+ top: coords.top - parentOffset.top,
+ left: coords.left - parentOffset.left
+ }
+
+ if ($this.css('position') == 'static') props['position'] = 'relative'
+ $this.css(props)
+ })
if (this.length==0) return null
var obj = this[0].getBoundingClientRect()
return {
Please sign in to comment.
Something went wrong with that request. Please try again.