MCPcopy Index your code
hub / github.com/streamich/react-use / triggerScroll

Function triggerScroll

tests/useWindowScroll.test.tsx:37–45  ·  view source on GitHub ↗
(dimension: 'x' | 'y', value: number)

Source from the content-addressed store, hash-verified

35 }
36
37 function triggerScroll(dimension: 'x' | 'y', value: number) {
38 if (dimension === 'x') {
39 (window.pageXOffset as number) = value;
40 } else if (dimension === 'y') {
41 (window.pageYOffset as number) = value;
42 }
43
44 window.dispatchEvent(new Event('scroll'));
45 }
46
47 it('should return window scroll value at mount time', () => {
48 setWindowScroll(1, 2);

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…