MCPcopy Create free account
hub / github.com/angular/components / makeScrollable

Function makeScrollable

src/cdk/drag-drop/directives/test-utils.spec.ts:147–161  ·  view source on GitHub ↗
(
  direction: 'vertical' | 'horizontal' = 'vertical',
  element = document.body,
)

Source from the content-addressed store, hash-verified

145 * @returns Function that should be used to clean up after the test is done.
146 */
147export function makeScrollable(
148 direction: 'vertical' | 'horizontal' = 'vertical',
149 element = document.body,
150) {
151 const veryTallElement = document.createElement('div');
152 veryTallElement.style.width = direction === 'vertical' ? '100%' : '4000px';
153 veryTallElement.style.height = direction === 'vertical' ? '2000px' : '5px';
154 element.prepend(veryTallElement);
155 scrollTo(0, 0);
156
157 return () => {
158 scrollTo(0, 0);
159 veryTallElement.remove();
160 };
161}
162
163export function wait(ms: number) {
164 return new Promise(resolve => setTimeout(resolve, ms));

Callers 2

Calls 1

removeMethod · 0.65

Tested by

no test coverage detected