gadgets.window.scrollTo() method

11 views
Skip to first unread message

Arne Roomann-Kurrik (Google)

unread,
Oct 27, 2008, 11:30:00 PM10/27/08
to OpenSocial - OpenSocial and Gadgets Specification Discussion
If it's not too late for 0.9, I'd like to bring up the idea of a
gadgets.window.scrollTo() method. The function would take a single
string as an argument and instruct the container to scroll the global
viewport so that the element with the corresponding ID (in the
gadget's IFrame) will be visible.

The justification for this proposal came from developing a gadget with
views that greatly exceeded the height of the browser's viewport, and
my desire to include a table of contents to allow users to jump
directly to sections of the content lower in the page (imagine a very
tall "help" page).

Page fragment links and window.scrollTo do not work for this purpose
because many containers use the page fragment for storing information,
and window.scrollTo is limited by the browser's cross-domain policy.

Note that a similar function was proposed earlier here:
http://groups.google.com/group/opensocial-and-gadgets-spec/browse_thread/thread/33c834732265a8a0/d180b7af3fc870bd?lnk=gst&q=scroll+to#d180b7af3fc870bd
but I was unable to reply to the thread (threads close after 30 days
or so of inactivity). To preserve that request, I'd suggest that the
default behavior of gadgets.window.scrollTo be that if a null or empty
string is passed to the method, the container scroll the global
viewport to the top of the rendered page. This would allow developers
to place ("back to top") links in their applications.

~Arne

Scott Seely

unread,
Oct 28, 2008, 12:10:24 PM10/28/08
to opensocial-an...@googlegroups.com
I'm a bit confused on this one. I can have a gadget that has markup like
this:

<a id="top"></a>

And later in the gadget, I can have:

<a href="#top">Go to top</a>

I'm not seeing the scenario where the page fragment link can't be used--
I can always create a link with a well-known ID that is independent of
how I am storing things. Can you give a real world example?

Arne Roomann-Kurrik

unread,
Oct 28, 2008, 5:17:32 PM10/28/08
to opensocial-an...@googlegroups.com
Normally this would be fine, but Shindig makes use of the page fragment to store the security token, making this development style incompatible with quite a few OpenSocial containers.  Now I understand that this is more of an issue with Shindig than the spec, but for convenience, it would be nice to have a cross-domain version of window.scrollTo() available for developers to use, and this would at least give developers on Shindig a workaround for the page fragment problem.

~Arne
--
OpenSocial IRC - irc://irc.freenode.net/opensocial

Scott Seely

unread,
Oct 28, 2008, 5:47:23 PM10/28/08
to opensocial-an...@googlegroups.com

+1

Louis Ryan

unread,
Oct 29, 2008, 12:16:08 PM10/29/08
to opensocial-an...@googlegroups.com
Im +1 on adding the function but I think this is something that needs to be fixed in Shindig anyway because proxied rendering will be adding a large class of content sources as gadgets some of which will be muti-purposed as both websites and gadgets and the need to use gadgets.X for anything will hinder adoption

John Hayes

unread,
Oct 29, 2008, 3:12:14 PM10/29/08
to opensocial-an...@googlegroups.com
-1
 
* Ownership of the fragment identifier should be clarified at the spec-level to be either entirely the container or entirely the developer.
* The opensocial spec is not intended to solve cross-browser incompatibilities. scrollTo is available without fragment navigation as scrollIntoView in IE, Firefox, Opera, and there are several libraries available that make the behavior consistent.
 
John

Arne Roomann-Kurrik

unread,
Oct 29, 2008, 3:47:12 PM10/29/08
to opensocial-an...@googlegroups.com
-1

Interesting, I had done tests with window.scrollTo which failed when the gadget was rendered on a different domain as the container.  scrollIntoView doesn't seem to suffer from this restriction (by testing with http://graargh.returnstrue.com/buh/scrollintoview.xml) so I'm happy using this as a workaround.

You make a good point about ownership of the fragment identifier being specified in the spec.  I'll post a separate thread regarding this.

~Arne

Scott Seely

unread,
Oct 29, 2008, 4:22:34 PM10/29/08
to opensocial-an...@googlegroups.com

Marking this proposal as dead in http://spreadsheets.google.com/ccc?key=pLSOqcf1mK9XQ-OmytqL3Qw&hl=en.

 

I’ll be waiting for the updated thread/proposal.

 

From: opensocial-an...@googlegroups.com [mailto:opensocial-an...@googlegroups.com] On Behalf Of Arne Roomann-Kurrik
Sent: Wednesday, October 29, 2008 12:47 PM
To: opensocial-an...@googlegroups.com
Subject: [opensocial-and-gadgets-spec] Re: gadgets.window.scrollTo() method

 

-1

Reply all
Reply to author
Forward
0 new messages