W3C home > Mailing lists > Public > www-style@w3.org > April 2013

Re: [cssom-view] Add a "smooth" parameter to scrollTo and scrollBy functions

From: Simon Pieters <simonp@opera.com>
Date: Tue, 16 Apr 2013 09:43:59 +0200
To: "www-style list" <www-style@w3.org>, "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: "Nat Duca" <nduca@google.com>, "James Simonsen" <simonjam@chromium.org>, "Tony Gentilcore" <tonyg@google.com>, "Tom Wiltzius" <wiltzius@google.com>
Message-ID: <op.wvmiflgeidj3kv@simons-macbook-pro.local>
On Tue, 19 Mar 2013 18:46:03 +0100, Tab Atkins Jr. <jackalmage@gmail.com>  
wrote:

> I'm forwarding a request from some of our internal engineers here, but
> I think it's a good idea myself. ^_^
>
> Apparently, there has been a significant rise in the number of sites
> desiring "smooth" scrolling when adjusting the scroll position of a
> page.

Do you have URLs to such sites I can look at?

> There are a few ways we could do this.  One early idea was to make a
> CSS property, like scroll-transition, that controlled this.  I don't
> think this is a good idea - I can see good reasons to want both
> instant and smooth scrolling on the same element in different
> circumstances,

Can you elaborate on the good reasons? Do you know of a site that does  
both instant and smooth scrolling on the same element?

> which argues that the decision should be made at the
> scroll site, not the element.
>
> Thus, I propose that we amend the existing scrollTo and scrollBy
> functions in CSSOM View to take a third parameter: an optional
> "smooth" string.  If omitted, the scroll is instant.

CSSOM View has more scrolling members than these. In particular,  
element.scrollIntoView(), which is more complex than scrollTo/scrollBy. If  
we just support smooth scrolling for scrollTo/scrollBy, you still need to  
use offsetTop to know how much to scroll if you want to scroll to a  
particular element.

Also, if you want your links to use smooth scrolling rather than instant  
scrolling, you have to cancel the `click` and run scrollIntoView() (if we  
support that), and also use history.pushState if you want the URL bar to  
show the new fragment (without scrolling to it instantly). This seems like  
a huge overhead and likely to be buggily implemented by authors compared  
to just setting a CSS property asking for smooth scrolling.

-- 
Simon Pieters
Opera Software
Received on Tuesday, 16 April 2013 07:44:31 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:10 UTC