Skip to content

Commit

Permalink
VSc: deactivate hover effects on scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
gdh1995 committed Mar 7, 2020
1 parent 99eeec8 commit 910c54b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
20 changes: 14 additions & 6 deletions content/scroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ var VSc = {
_animate (e: SafeElement | null, d: ScrollByY, a: number): void {
let amount = 0, calibration = 1.0, di: ScrollByY = 0, duration = 0, element: SafeElement | null = null, //
sign = 0, timestamp = 0, totalDelta = 0.0, totalElapsed = 0.0, //
running = 0 as number, next = requestAnimationFrame, timer = TimerID.None;
function animate(newTimestamp: number): void {
running = 0 as number, next = requestAnimationFrame, timer = TimerID.None,
top: SafeElement | null = null,
animate = (newTimestamp: number): void => {
if (!VSc) { toggleStyles(0); return; }
const _this = VSc,
// although timestamp is mono, Firefox adds too many limits to its precision
elapsed = !timestamp ? (newTimestamp = performance.now(), ScrollerNS.Consts.firstTick)
: newTimestamp > timestamp ? newTimestamp - timestamp
: (newTimestamp += ScrollerNS.Consts.tickForUnexpectedTime, ScrollerNS.Consts.tickForUnexpectedTime),
continuous = _this.keyIsDown_ > 0;
if (!_this) { return; }
timestamp = newTimestamp;
totalElapsed += elapsed;
if (amount < ScrollerNS.Consts.AmountLimitToScrollAndWaitRepeatedKeys
Expand Down Expand Up @@ -80,15 +81,21 @@ _animate (e: SafeElement | null, d: ScrollByY, a: number): void {
(notEl ? document : element as NonNullable<typeof element>).dispatchEvent(
new Event("scrollend", {cancelable: false, bubbles: notEl}));
}
toggleStyles(0);
_this._checkCurrent(element);
element = null;
running = 0;
}
}
function startAnimate(): void {
},
startAnimate = (): void => {
timer = TimerID.None;
running = running || next(animate);
}
},
toggleStyles = (scrolling: BOOL): void => {
const el = (scrolling ? top = VDom.SafeEl_(VDom.docEl_unsafe_()) : top
) as TypeToAssert<Element, HTMLElement | SVGElement, "style"> | null;
el && el.style ? el.style.pointerEvents = scrolling ? "none" : "" : 0;
};
this._animate = function (this: typeof VSc, newEl, newDi, newAmount): void {
const math = Math, max = math.max;
amount = max(1, math.abs(newAmount)); calibration = 1.0; di = newDi;
Expand All @@ -105,6 +112,7 @@ _animate (e: SafeElement | null, d: ScrollByY, a: number): void {
this.minDelay_ = (((keyboard[0] + max(keyboard[1], ScrollerNS.Consts.DelayMinDelta)
+ ScrollerNS.Consts.DelayTolerance) / ScrollerNS.Consts.DelayUnitMs) | 0)
* ScrollerNS.Consts.DelayUnitMs;
toggleStyles(1);
startAnimate();
};
this._animate(e, d, a);
Expand Down
5 changes: 5 additions & 0 deletions types/compatibility.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ declare const enum BrowserVer {
MinShadowDOMV0 = 31, // the real version is <= C31; it's prefixed
// mouseEvent.buttons is since C43 but a `buttons` property does no harm on Chrome <= 42
MinUsable$MouseEvent$$constructor = 31, // the real version is <= C31
MinEnsured$onwheel = 31, // even if LEGACY
MinSupported = 32,
MinEnsuredES6Promise = 32, // even if LEGACY
// the 5 below are correct even if EXPERIMENTAL or LEGACY
Expand Down Expand Up @@ -117,6 +118,8 @@ declare const enum BrowserVer {
// even if LEGACY
MinEnsuredES6MethodFunction = 45, // e.g.: `a = { b() {} }`
MinMuted = 45,
// https://www.chromestatus.com/features/5697181675683840
MinNoMousePositionUpdatesWhenScrolling = 45, // replaced by MinRuntimeFlag$UpdateHoverAtBeginFrame
MinMutedInfo = 46,
// even if EXPERIMENTAL or LEGACY
MinAutoDecodeJSURL = 46,
Expand Down Expand Up @@ -435,6 +438,8 @@ declare const enum BrowserVer {
// https://chromium.googlesource.com/chromium/src/+/5e84b7a819637ed4dd8f9c4d11288127663c8267
MinBlockAutoFocusingInCrossOriginFrame = 75,
MinMediaQuery$PrefersColorScheme = 76,
// https://bugs.chromium.org/p/chromium/issues/detail?id=877132
MinRuntimeFlag$UpdateHoverAtBeginFrame = 77, // #update-hover-at-begin-frame is enabled by default
MinChromeFavicon2 = 77, // tested on 77.0.3865.90, chrome://favicon2/ is forbidden to use on extension pages
// https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/h-JwMiPUnuU/sl79aLoLBQAJ
// https://www.chromestatus.com/features/4507242028072960
Expand Down

0 comments on commit 910c54b

Please sign in to comment.