Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

feat(jqLite): Add offset method to jqLite #3799

Closed
wants to merge 1 commit into from

Conversation

steelsojka
Copy link

Add offset method to jqLite as a getter only to retrieve element
position.

@jeffbcross
Copy link
Contributor

PR Checklist (Minor Feature)

  • Contributor signed CLA now or in the past (if you just signed, leave a comment here with your real name for cross reference)
  • Feature improves existing core functionality
  • API is compatible with existing Angular apis and relevant standards (if applicable)
  • PR doesn't contain a breaking change
  • PR contains unit tests
  • PR contains e2e tests (if suitable)
  • PR contains documentation update
  • PR passes all tests on Travis (sanity)
  • PR passes all tests on ci.angularjs.org (cross-browser compatibility)
  • PR is rebased against recent master
  • PR is squashed into one commit per logical change
  • PR's commit messages are descriptive and allows us to autogenerate release notes (required commit message format)
  • All changes requested in review have been implemented

@jeffbcross
Copy link
Contributor

@steelsojka I've added this to the post-1.2 milestone, which means it will likely get reviewed after 1.2 has been released. In the meantime, would you mind squashing your commits into one commit? See our Contributor Guidelines for more info.

@steelsojka
Copy link
Author

No problem. I will get to it here sometime later today.
On Aug 29, 2013 1:09 PM, "Jeff Cross" notifications@github.com wrote:

@steelsojka https://github.com/steelsojka I've added this to the
post-1.2 milestone, which means it will likely get reviewed after 1.2 has
been released. In the meantime, would you mind squashing your commits into
one commit? See our Contributor Guidelineshttp://docs.angularjs.org/misc/contributefor more info.


Reply to this email directly or view it on GitHubhttps://github.com//pull/3799#issuecomment-23510406
.

Add the method offset to jqlite to retrieve the elements top and left
position. Using the method as a setter is not supported.
@caitp
Copy link
Contributor

caitp commented Sep 20, 2013

+1 on this ... angular-ui/bootstrap#1049 is sort of related. It would really be ideal to put everything from the $position service to somewhere more central, and the best place for it would be jqlite, so that we could leverage more robust jQuery implementations otherwise.

I'd personally really like to see a few other common DOM helpers added into jqlite, just to make life a bit easier for ui-bootstrap developers. I realize fully well that core angular wouldn't have much of a use for them, but it would be a big deal for directives when we can't depend on jquery being available. height, width and offset are all good additions to jqlite, and shouldn't make it grow too much.


I suppose I may write a patch to provide height() and width() real quick, and hope for some post-1.2 review as well. Patch in #4078

@muszek
Copy link

muszek commented Jan 27, 2014

What's the status of this issue?

@steelsojka
Copy link
Author

I think it's still ready to go. I don't think it's to high priority right now is my guess, since you can just include jQuery.

@timraymond
Copy link
Contributor

@steelsojka It looks like this needs a rebase

@enapupe
Copy link

enapupe commented Mar 17, 2015

Why is this not merged yet?


documentElem = doc.documentElement;

if ( typeof element.getBoundingClientRect !== undefined ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the if is necessary anymore; we even dropped it in jQuery and Angular supports fewer browsers.

@mgol
Copy link
Member

mgol commented Apr 20, 2016

This PR has been lying here in the backlog for almost 2 years now and we haven't seen huge demand for this method among Angular users so we decided to not add this method. It's always hard to decide what to include and what not but jqLite's goal is mainly to include methods needed for core Angular to work; if people want more methods from jQuery they can include jQuery directly.

With custom jQuery compilations (you can e.g. exclude ajax, deferred, callbacks modules etc. as Angular apps shouldn't need them) the final size is smaller than the full file. For example, when compiling the current master, the full gzipped size is 30 KB but if you exclude some modules via:

grunt custom:-ajax,-callbacks,-css/showHide,-deferred,-deprecated,-dimensions,-effects,-event/alias,-event/focusin,-offset,-queue,-serialize

you'll be down to 20.5 KB gzipped. If you also exclude Sizzle, jQuery selector engine (at the cost of making .find inherit qSA weirdness of handling complex selectors) you're down to 14.5 KB gzipped.

For comparison, Angular.js (without additional modules like route, animate etc.) is 54 KB gipped and jqLite that's included in it is 5 KB gzipped.

Thanks for your efforts!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants