I''m trying to understand the Position object. Specially the various offset methods. From looking at the code I think I may understand them but I wanted to run it by the group to make sure I had a clear understanding. realOffset - This returns the coordinates of the element as if none of the elements on the page are scrollable from the document edge. cumulativeOffset - This returns the coordinates of the element from the document edge (not taking scrolling into account or anything fancy). positionedOffset - This will return the same thing as cumulativeOffset most of the time, but if the element is contained in a positioned element (''absolute'' or ''relative'') then it returns the coordinates from the parentOffset of the element (which is the top-level element that is actually positioned). page - This is the one I really don''t understand. It seems like it is calculating the cumulativeOffset - realOffset. But I can''t figure out the purpose or why it is called "page". Any pointers anyone could give to help me understand these methods. Most of the documentation I have found on the web basically reads the code to me. I am trying to understand what these method really do and why we need them. Eric
I have ... questions about these functions too. I have attempted to use them at different times, obtaining results other than what I expected. However messing round, mixing and matching, etc has yielded me proper results. From what I understand (which is probably not all correct) I see the functions as follows: realOffset - Returns and array in the format of [scrollX, scrollY]. When you have elements positioned within DIV''s that have overflow:auto and the user has scrolled the containing DIV, a scroll offset is created. Depending whether the vertical, horizontal, or both scroll bars have been moved, the values will need to be applied to some absolute positioning calculations (cumulativeOffset). element.top + realOffset(element)[0] and element.top + realOfffset(element)[1]. cumulativeOffset - Positioning of an object as if there were no scroll offsets. IE The position an object has from the document top left corner with out any nested scrolling applied. If you don''t have any scrollable DIV''s (overflow:auto) this will be your exact positioning. positionedOffset - I don''t know for sure. I''m assuming its cumulativeOffset + realOffset. page - ? Most of this is from memory and I didn''t look at the latest source. I didn''t even know there was a "page" function due to the fact that my company has frozen its prototype library for now. Also: www.prototypedoc.com . It is slightly outdated but some of the base functionality is documented heavily through various sites. The first site ( www.sergiopereira.com/articles/prototype.js.html ) was my starting place oh-so-long-ago with Prototype. -Andrew Martinez -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Eric Anderson Sent: Monday, May 15, 2006 10:12 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] Positioning I''m trying to understand the Position object. Specially the various offset methods. From looking at the code I think I may understand them but I wanted to run it by the group to make sure I had a clear understanding. realOffset - This returns the coordinates of the element as if none of the elements on the page are scrollable from the document edge. cumulativeOffset - This returns the coordinates of the element from the document edge (not taking scrolling into account or anything fancy). positionedOffset - This will return the same thing as cumulativeOffset most of the time, but if the element is contained in a positioned element (''absolute'' or ''relative'') then it returns the coordinates from the parentOffset of the element (which is the top-level element that is actually positioned). page - This is the one I really don''t understand. It seems like it is calculating the cumulativeOffset - realOffset. But I can''t figure out the purpose or why it is called "page". Any pointers anyone could give to help me understand these methods. Most of the documentation I have found on the web basically reads the code to me. I am trying to understand what these method really do and why we need them. Eric _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I know there was a discussion about it while ago but I just checked some of the Yahoo''s libs and design patterns and just wondering what are the advantages of using one instead of another ? I only saw yahoo''s examples - didn''t get down to the code.. Have you tried to play with it ? How is it comparing to prototype style ? I would like to know what do you think about it :) greetings, Andrzej _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Andrzej, I have been using the Yahoo! UI connection and drag and drop libraries a bit instead of Prototype.js Partly this is because I had read so many warning about the quality of the Prototype.js library. Partly because I don''t like the enumerable stuff in Prototype.js. I think it makes for ugly JavaScript. Partly because I don''t really like seeing JavaScript hidden under Ruby wrappers in my code. Yes JavaScript is weird but if I want to use JavaScript to do a job then I don''t mind coding in JavaScript. The newest version of Prototype.js has nice Ajax stuff but I haven''t found a way to do what the Yahoo! UI connection "argument" can do. See the Yahoo! UI docs. The Yahoo! UI library has a rediculous requirement that every dragdrop element must have an id. I have to invent dummy ids for sortable list elements. I hope this goes away. The sortable list options in both libraries are not so great. However with the power of the new rjs templates I am using Prototype.js a little bit. Prototype.js is so integrated into the rails way of doing things it might not be good to avoid it all together. With rjs it feels like fighting to avoid Prototype.js. The way my app is set up it is not a problem for the client to download both some Yahoo and Prototype libraries. I might just happily sit on the fence. Peter On 5/17/06, Andrzej Rumpfelt <arumpfelt-2InuVDLKURjVItvQsEIGlw@public.gmane.org> wrote:> > > I know there was a discussion about it while ago but I just checked some of > the Yahoo''s libs and design patterns and just wondering what are the > advantages of using one instead of another ? > I only saw yahoo''s examples - didn''t get down to the code.. Have you tried > to play with it ? How is it comparing to prototype style ? > > I would like to know what do you think about it :) > > greetings, > Andrzej > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >
I don't even know Ruby but I love the Enumeration helpers. For example, $A().without() is something you do often in javascript and I'm happy not to have to write a for-next loop and test values everytime I need to do it. On 18/05/06, Peter Michaux <petermichaux@gmail.com> wrote:> Andrzej, > > I have been using the Yahoo! UI connection and drag and drop libraries > a bit instead of Prototype.js > > Partly this is because I had read so many warning about the quality of > the Prototype.js library. Partly because I don't like the enumerable > stuff in Prototype.js. I think it makes for ugly JavaScript. Partly > because I don't really like seeing JavaScript hidden under Ruby > wrappers in my code. Yes JavaScript is weird but if I want to use > JavaScript to do a job then I don't mind coding in JavaScript. > > The newest version of Prototype.js has nice Ajax stuff but I haven't > found a way to do what the Yahoo! UI connection "argument" can do. See > the Yahoo! UI docs. > > The Yahoo! UI library has a rediculous requirement that every dragdrop > element must have an id. I have to invent dummy ids for sortable list > elements. I hope this goes away. The sortable list options in both > libraries are not so great. > > However with the power of the new rjs templates I am using > Prototype.js a little bit. Prototype.js is so integrated into the > rails way of doing things it might not be good to avoid it all > together. With rjs it feels like fighting to avoid Prototype.js. > > The way my app is set up it is not a problem for the client to > download both some Yahoo and Prototype libraries. I might just happily > sit on the fence. > > Peter > > > On 5/17/06, Andrzej Rumpfelt <arumpfelt@madonet.pl> wrote: > > > > > > I know there was a discussion about it while ago but I just checked some of > > the Yahoo's libs and design patterns and just wondering what are the > > advantages of using one instead of another ? > > I only saw yahoo's examples - didn't get down to the code.. Have you tried > > to play with it ? How is it comparing to prototype style ? > > > > I would like to know what do you think about it :) > > > > greetings, > > Andrzej > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >-- Andrew _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs