Closed Bug 659549 Opened 13 years ago Closed 13 years ago

Tab bar scrolling using arrow buttons should use mozRequestAnimationFrame

Categories

(Toolkit :: UI Widgets, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla7

People

(Reporter: ventnor.bugzilla, Assigned: ventnor.bugzilla)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch Patch (obsolete) — Splinter Review
A while ago we adopted the tab smooth scrolling animation to our animation API, when a tab was selected offscreen. However, the scrolling used when you hold down the arrow buttons on either side was not updated, thus making it seem jerky in comparison.

We should update that animation too.
Comment on attachment 534976 [details] [diff] [review]
Patch

Huh, the new bug form no longer lets you mark attachments as patches.
Attachment #534976 - Flags: review?(dao)
Attachment #534976 - Attachment is patch: true
Comment on attachment 534976 [details] [diff] [review]
Patch

>+      <field name="_arrowSmoothScroll"><![CDATA[({

"_arrowSmoothScrollAnim" or just "_arrowScrollAnim" for consistency with _scrollAnim?

>+        stop: function arrowSmoothScroll_stop() {
>+          window.removeEventListener("MozBeforePaint", this, false);
>+          this.scrollbox.scrollByIndex(this.scrollbox._scrollIndex);
>+          this.scrollbox._scrollIndex = 0;

I think I'd prefer to keep the scrollByIndex call and _scrollIndex = 0 in the _stopScroll method.

>+        handleEvent: function arrowSmoothScroll_handleEvent(event) {
>+          const scrollIndex = this.scrollbox._scrollIndex;
>+          const timePassed = event.timeStamp - this.lastFrameTime;
>+          this.lastFrameTime = event.timeStamp;
>+          
>+          const scrollDelta = 0.5 * timePassed * scrollIndex;
>+          this.scrollbox.scrollPosition += scrollDelta;
>+
>+          if (scrollIndex != 0)
>+            window.mozRequestAnimationFrame();
>+        }

Why is "if (scrollIndex != 0)" needed?
Assignee: nobody → ventnor.bugzilla
Component: Tabbed Browser → XUL Widgets
Product: Firefox → Toolkit
QA Contact: tabbed.browser → xul.widgets
Severity: normal → enhancement
Version: unspecified → Trunk
Attached patch Patch 2Splinter Review
(In reply to comment #2)
> >+        handleEvent: function arrowSmoothScroll_handleEvent(event) {
> >+          const scrollIndex = this.scrollbox._scrollIndex;
> >+          const timePassed = event.timeStamp - this.lastFrameTime;
> >+          this.lastFrameTime = event.timeStamp;
> >+          
> >+          const scrollDelta = 0.5 * timePassed * scrollIndex;
> >+          this.scrollbox.scrollPosition += scrollDelta;
> >+
> >+          if (scrollIndex != 0)
> >+            window.mozRequestAnimationFrame();
> >+        }
> 
> Why is "if (scrollIndex != 0)" needed?

I thought that would be necessary to stop requesting frames when we stop the scrolling by setting the index to 0. But looking at it again, it does seem unnecessary so I removed it.
Attachment #534976 - Attachment is obsolete: true
Attachment #534976 - Flags: review?(dao)
Attachment #537533 - Flags: review?(dao)
Attachment #537533 - Flags: review?(dao) → review+
http://hg.mozilla.org/mozilla-central/rev/f4321cdcef37
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla7
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: