Commit graph

14 commits

Author SHA1 Message Date
thiemowmde c45b92209c Drop RTL scroll type detection, obsolete since 2023
According to https://www.mediawiki.org/wiki/Compatibility we can:
* Ignore Internet Explorer as well as "Edge legacy" (before it
  switched to Chromium) entirely.
* Ignore old Opera (Presto, before it switched to Chromium).
* Ignore Chrome and Chromium-based browsers that are more than
  3 years old.

According to https://github.com/othree/jquery.rtl-scroll-type
* Firefox and Safari always followed the web standard.
* The "reverse" type was only ever relevant in IE.
* The "default" type was only relevant in old Chrome and
  Chromium-based browsers, before the engine was changed to follow
  the web standard.

According to https://chromestatus.com/feature/5759578031521792 this
happened in version 85, June 2020.

The only edge-case I can think of is that we want to support some
niche browser that – for some reason – still uses Chromium 84 or
older. But according to https://www.mediawiki.org/wiki/Compatibility
we are at 88+ already, everywhere.

It appears like we can safely remove two types, which means only
the web standard behavior (a.k.a. "negative") is left.

No pressure merging this. This patch can as well sit here for
another year. ;-)

Bug: T352169
Change-Id: Ifdedfd6d16abc87576df9807a55cd1b8a7d185db
2024-03-12 18:41:54 +01:00
thiemowmde 346846f16c Work around rounding errors in RTL scroll type detection
This is closely related to Ied0b974 which fixed a similar, if not
the same rounding issue.

Note the following might be different depending on e.g. the
operating system. My Ubuntu+Chromium shows the following behavior:
* The RTL scroll type is correctly detected as "negative" with all
  zoom factors below and up to 100%.
* When the zoom factor is 110%, 125%, or 150% the scrollLeft value
  is not 0 but something like 0.909090876 or 0.200000002.
* It's 0 again at 175% and 200%.
* Bad at 250%. Good at 300%. Bad at 400%. And so on. No rhyme or
  reason.

The current Firefox version also ends in the "negative" branch, but
doesn't have the same rounding errors. It's always a perfect 0 in
Firefox.

This makes it look like a bug in Chrome's engine. We don't know how
old it is, but based on the information in T352169 it might be a
relatively new bug that didn't exist when this code was originally
written in 2016 (see I7c903c2).

For reference, this is what's supposed to happen here: Browsers with
the scroll type "negative" (which are apparently all current Chrome
and Firefox versions) won't allow scrollLeft to be a positive number
on an RTL page. When you scroll to the left in such browsers the
numbers get negative. The detection code tries to set the number to
+1 anyway. We expect the browser to ignore this invalid call and
still report the previous 0.

This mostly works in Chrome as well. For example, setting scrollLeft
to +100 wont set it to +100 but to … some random number between >=0
and <1, depending on the current zoom factor? o_O?

I suspect we can remove this detection code entirely, or at least
change the default to "negative". But this needs more testing with
more browsers. Let's start with this tiny fix.

Bug: T352169
Change-Id: I22cbb8881578e96165097d4fcc812baadc22d7fa
2024-02-28 14:03:32 +01:00
thiemowmde e505805adb Remove $dummy element after determineRtlScrollType call
This updates the code a little bit to be closer to the current
version of https://github.com/othree/jquery.rtl-scroll-type
without actually changing anything (for now).

I tried copy-pasting the current version to see if that helps with
T352169, but it doesn't make a difference.

The only actual change is that the dummy element is removed when
it's not needed any more.

Change-Id: Ibdd064e228fa9464a8652ce9a8a9ac388662f29d
2024-02-09 12:26:15 +01:00
thiemowmde 7e152e9f7c Drop obsolete special case for Google Chrome before version 60
The version numbers mentioned in the comment are from the V8 engine.
The last Google Chrome version to use a 5.x version of the V8 engine
was Google Chrome version 59. That was 8 years ago. See T168299.

Our official support matrix asks for 3 years.
https://www.mediawiki.org/wiki/Compatibility#Browser_support_matrix

Notice how there is no version number in the code despite the comment
explaining that it shouldn't be used in later versions.

According to my local tests this is not a full fix for T352169, but
notably improves the situation. I can still see the bad behavior
described in T352169, but only in a narrow region on the right side
of the slider. Removing the obsolete browser detection is necessary
to unblock further investigation.

Making the dummy text a bit longer also makes an actual difference.
To keep this patch as minimal as possible all I do is to add a single
character.

Bug: T352169
Change-Id: I56f3c1969ce4f164f4319e5038d0f97527e6b1c0
2024-02-07 17:29:19 +01:00
thiemowmde 99c0064e34 Make use of the /i feature instead of .toLowerCase()
Depends-On: I8a101781bb47612deabb0f2a06a398ac13e860e6
Change-Id: Id738c409cca89c1783290578f42c92e2c8b0cac3
2024-01-31 19:34:59 +00:00
thiemowmde 8eff7a7455 Replace switch with a map in util class
Change-Id: If569e34f032ecda261f7970d5ef1e59efc55d56c
2023-08-24 10:59:26 +02:00
Adam Wight b900446572 Migrate JS to ES6
Reintroduces IIFE closures in test files because variables were
declared in the global namespace, and "const" now causes hard errors.

Bug: T339323
Change-Id: I69e9d7a29591137f185f3e5ab02dea590ec4dff6
2023-06-23 08:01:31 +02:00
Ed Sanders 64effa6e42 Move var declarations inline
Change-Id: If1256b01f6ac8237c79b5ba62f20ad65f1dc7691
2021-10-07 14:55:44 +01:00
Adam Wight 8132e43a20 Migrate Slider module to packageFiles
Change-Id: Idf1cc799ab37ec8f49b3a28d161b6cd53090f707
2020-11-19 09:13:45 +00:00
Thiemo Kreuz 4ac1ff57f1 Remove closure wrappers from all JavaScript code
These are not needed any more, because the code runs in a
seperate scope anyway.

Change-Id: I939a06102f194a0c98021accb2f62be73dd0562f
2020-11-18 11:16:04 +01:00
Ed Sanders e62f46dd80 Remove obsolete aliases from closures
Bug: T208951
Change-Id: Icf10ea6bbc09542e69c0cd583a4ee4f2f76a3f43
2018-11-16 16:33:52 +00:00
WMDE-Fisch 7c58766b48 Update scroll type detection
Port of a fix in the original source:
1c6d684503

Change-Id: I2d53e467b79d586efc079a15ebc0a52382352f9e
2017-08-06 23:49:48 +02:00
WMDE-Fisch 553e48e65a Move scrollType detection to utils
Change-Id: I465e0b74a7d7a6682b22bdd6e7aafb794bce9b24
2017-07-14 10:19:28 +00:00
WMDE-Fisch 31b9fe31ef Convert touch events to mouse events on pointers
This will make the pointers work on touch devices. The events responsible
for the touch drag and move are converted to mouse actions that will
trigger the draggable.

When using Chrome on touch devices and zooming the offset of elements
calculated by jQuery is wrong. There is a workaround that seems to work
and also seems to not break behavior with normal browsers and on other
devices. Since this only seems to be a problem in Chrome the fix will
only applied to Chrome browsers to avoid performance los on others.

Also introduced a script file for static utility methods.

Bug: T164249
Change-Id: I245f77eb836afded249f3b5ebb7129dab08d0017
2017-05-08 12:55:31 +02:00