Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass $element to offset top/bottom calc funcs #10359

Merged
merged 1 commit into from Dec 24, 2013
Merged

Pass $element to offset top/bottom calc funcs #10359

merged 1 commit into from Dec 24, 2013

Conversation

ixti
Copy link
Contributor

@ixti ixti commented Sep 2, 2013

At the moment to make dynamic top offset calculator on multiple elements, one would write:

$('.my-affix').each(function () {
  var $el = $(this);
  $el.affix({
    offset: {
      top: function () { return $el.offset().top; }
    }
  });
})

This patch will allow to:

$('.my-affix').affix({
  offset: {
    top: function ($el) { return $el.offset().top; }
  }
});

At the moment to make dynamic top offset calculator on multiple elements, one would write:

``` javascript
$('.my-affix').each(function () {
  var $el = $(this);
  $el.affix({
    offset: {
      top: function () { return $el.offset().top; }
    }
  });
})
```

This patch will allow to:

``` javascript
$('.my-affix').affix({
  offset: {
    top: function ($el) { return $el.offset().top; }
  }
});
```
@cvrebert
Copy link
Collaborator

Seems good, it's just gonna have to wait for v3.1.0 since it's a new feature.

@fat
Copy link
Member

fat commented Dec 24, 2013

good w this

@fat
Copy link
Member

fat commented Dec 24, 2013

i feel like the convention would be to call top within the context of the element mb though…

@fat
Copy link
Member

fat commented Dec 24, 2013

$('.my-affix').affix({
  offset: {
    top: function () { return $(this).offset().top; }
  }
});

@fat
Copy link
Member

fat commented Dec 24, 2013

that way is kinda lame though because you can't easily overwrite the top property

@fat
Copy link
Member

fat commented Dec 24, 2013

so i like this pr better i think

fat added a commit that referenced this pull request Dec 24, 2013
Pass $element to offset top/bottom calc funcs
@fat fat merged commit 139b395 into twbs:master Dec 24, 2013
@mdo mdo mentioned this pull request Dec 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants