On Fri, May 23, 2014 at 3:47 AM, Robert O'Callahan <[email protected]> wrote: > >> One use case that has come up for us in FirefoxOS is the ability to >> add a few elements to the top of a page, shifting down the contents of >> the page, but then make that transparent to the user by adjusting the >> scroll position accordingly. >> >> That isn't possible with APZ since the user might be actively >> scrolling and so if we just do something like >> >> div.scrollTop += hightOfNewContent; >> >> then the newly set scroll position will be based off of an old value >> which has already changed on the compositing thread. >> >> Basically we need an API like >> >> div.addToScrollPosition(hightOfNewContent); > > > On the viewport, we have scrollBy. CSSOM doesn't define that on elements but > it should. I guess they should both take an optional ScrollOptions > parameter. > >> div.smoothScrollTo(pos, n); // does a smooth scroll over n ms. > > > Better to not take a duration parameter if there isn't a clear use-case. (Or > is there?) > >> div.setScrollPosition(pos); // ensures that the next time we paint, we >> paint at scroll position pos > > > scrollLeft/scrollTop do this. Though I think elements should have the same > scrollTo method that Window does, as well.
I guess what I'm arguing is that smooth-scrolling vs. instant scrolling shouldn't be a per-element CSS property, but rather a per-callsite API argument. It seems to me that it will be the case that for a given element you'll sometimes want to do smooth scrolling operations and sometimes instant operations. For example in a list of emails you might want to enable smooth-scrolling down 50 emails, but if additional emails come in, you want to be able to add to the top of the list and atomically "add to scroll scroll position" to compensate for the added elements. I'm not sure if that means treating the current .scrollBy() and .scrollLeft/.scrollTop API as instant (and make sure it applies to elements in addition to windows) and adding smooth scrolling versions. Or if we should add wholly new API which is more explicit about if it intends to perform smooth vs. instant scrolling. The only use-case I could see for the CSS property would be as a way to indicate if a <a href="#..."> should perform an instant or a smooth scroll. / Jonas _______________________________________________ dev-platform mailing list [email protected] https://lists.mozilla.org/listinfo/dev-platform

