Commit Graph

17 Commits

Author SHA1 Message Date
Timo Tijhof 75af9ec9b5 Decrease onresize debounce from 100ms to 10ms
The debounce is trailing, not leading/throttled. This means
the value doesn't decide how often it runs while the user is
resizing. It decides how long after they stop resizing will
it first run.

Given the calculation isn't super expensive, a much lower value
should suffice. The main thing we want is that while the user
is actively resizing and 100s of events are queued up (faster than
JS can process), that we wait until the end of the chain before
computing it (once). If the user actually stops moving, even for
a little bit, that little bit however small should be more than
long enough for a repaint to take place.

Test Plan:
* Open two tabs, one after checking out master, and
  one after checking out this patch. Make sure you are logged-in
  on MW as an administrator user (to get more tabs).
* Verify that `mw.loader.getVersion('skins.vector.js')` returns
  different values from the console for each.
* Resize the window from wide to very narrow and back.
  Before, the tab bar updates relatively late it feels sluggish.
  After, the tab bar appears to update as/while you let go.

Change-Id: If02338559abc71668d0655e8b3be1a5f73e646a9
2019-09-11 19:44:04 +00:00
Timo Tijhof f169c8b3f9 Use mw.util.debounce() in collapsibleTabs.js
Bug: T213426
Depends-On: If370b959b2617d0f506ac3ed344af8c6a667e70d
Change-Id: Ib006a570f9405bbd48bb7e81a3d98b562df22b00
2019-09-11 19:29:46 +00:00
Ed Sanders a4f61a832e CollapsibleTabs: Avoid Sizzle selectors
Change-Id: I199a11602df50f2120dce6f861bb4b6260ab9380
2019-07-01 16:02:07 +01:00
Ed Sanders 7e76377bf8 build: Update eslint-config-wikimedia to 0.11.0
Change-Id: Idae38d2dff51827f7aff510d40b2358bf939b5e2
2019-03-13 23:23:14 +00:00
Ed Sanders 8634a77d0e build: Update linters
Change-Id: I8b99db813f12dc2031b5a1c195e6480f5512792a
2019-01-11 13:03:15 +00:00
Ed Sanders 828452ff27 build: Update eslint-config-wikimedia to 0.9.0
Change-Id: I3ea907f6ef3b6337c1e793668ae889610fc6a635
2018-11-26 23:39:36 +00:00
Ed Sanders b61ad3a9a7 Remove obsolete aliases from closures
Bug: T208951
Change-Id: I6ca9ca80473317e44a10c268c7058bc2cf4d7b58
2018-11-16 15:35:52 +00:00
Ed Sanders 0b7cc4ffce build: Update linters
Change-Id: Ic11eea77b944cfc98e9494a9d215a138f386f1eb
2018-09-09 18:30:26 +00:00
Ed Sanders 8842f744ee build: Update eslint-config-wikimedia 0.4->0.5, eslint 19->20
Change-Id: I61a9bc5567036dfcbc7697276583facbefac8b93
2017-08-25 16:21:21 +01:00
Bartosz Dziewoński 532b9c0eaf collapsibleTabs: Stop the tabs from collapsing back and forth forever
Update the 'expandedWidth' after we expand in case someone was brazen
enough to change the tab's contents after the page load (gasp).

This doesn't prevent a tab from collapsing back and forth once, but at
least it won't continue to do that forever. This should reduce the
issue from completely awful to mildly annoying.

Bug: T71729
Change-Id: I46bd6584c0f2ddebc4aa7d1103cff1715e1510a5
2017-01-13 00:16:45 +00:00
Timo Tijhof 1f26153a5d collapsibleTabs: Clean up and simplify code
* Rename 'rtl' to 'isRTL' and use DOM to compute its value.
* Document code with JSDuck similar to other extensions.
* Remove unused 'prevElement' property. Not used in Vector
  nor anywhere else in Wikimedia Git.
* Make 'boundEvent' property private. Not used anywhere in
  Wikimedia Git outside this file.

* Simplify 'instances' tracking.
  The jQuery object stored in this property wasn't used beyond
  calling each(). Convert to a plain array.
  Preserve and re-use the jQuery object first created
  by collapsibleTabs().

* Simplify calculateTabDistance() by using getElementById() and
  getBoundingClientRect(). Its support includes IE 5.
  The "new" version (since Firefox 3.5 and IE 9) also includes
  'height' and 'width' properties and is supported in all
  browsers supported by the MediaWiki 1.28 startup feature test.

  This helps avoid code in offset() and width(), which is fairly
  expensive in jQuery 1.x.

* moveToCollapsed()
  - Remove redundant jQuery object creation (only caller passes a
    jQuery object already).
  - Remove redundant re-receiving of expContainerSettings inside
    the animate() callback. Already in the main scope.
    Relates to a bunch of patches that work around a problem
    caused by use of remove() instead of detach() in an earlier
    version of the code. Which was only a problem because the
    other settings object was also not used from the main scope.
    (See pre-Gerrit commits 1f93310e and e7900807.)

Change-Id: I48d542580d767df2d17ce4c6668e9e233a0f7902
2016-11-29 02:25:00 +00:00
Timo Tijhof f354aafebc collapsibleTabs: Defer DOM changes via requestAnimiationFrame
Widely supported, unprefixed (over 85%)
http://caniuse.com/#feat=requestanimationframe

Change-Id: I13a73e3ba4f68af86ca77ca8242107ee449b255e
2015-11-19 23:54:42 +00:00
Timo Tijhof 020956d070 collapsibleTabs: Debounce resize event at 100ms instead of 500ms
A delay of 500ms is quite long and is a bad user experience.
Resize should be more responsive than that.

Matches other plugins that do the same thing, such as:
http://www.paulirish.com/2009/throttled-smartresize-jquery-event-handler/

And also more in accordance with RAIL.
https://developers.google.com/web/tools/chrome-devtools/profile/evaluate-performance/rail

Change-Id: I076785f82a7786f16ca4fb1564a4972dd23cc56b
2015-11-19 23:53:17 +00:00
paladox 95ef8f2cc6 Update jscs to 2.1.0
Change-Id: Ibba453510c8e15c3e915d28f7ecf7c296bca7894
2015-10-22 00:38:01 +01:00
Bartosz Dziewoński e4ab0757d9 collapsibleTabs: Don't mix Arrays and jQuery objects for one property
We treat this as a jQuery object throughout the code, but it was
initialized to an array.

Bug: T109259
Change-Id: I44c10683ded05656eb7ca1b4be43ddc4f9281076
2015-08-17 21:42:35 +02:00
James D. Forrester 46c2ae820a test: Make code pass jscs 1.5.0 with Wikimedia code style preset
Change-Id: I385f7d9ca9f641b3ad936605af1f9894a57192e5
2015-02-14 12:45:20 -08:00
Bartosz Dziewoński d28f09df31 Move Vector skin from core
This is the final step of the process described at
<https://www.mediawiki.org/wiki/Separating_skins_from_core_MediaWiki>.

Corresponding core change: Idfc38503.

Change-Id: I84fcf7ce6385b8323544cafe6912a00f1886d20d
2014-08-07 13:38:34 +02:00