aboutsummaryrefslogtreecommitdiffstats
path: root/deprecated-workflow-designer/sdc-workflow-designer-ui/src/app/paletx/core/overlay/scroll/scroll-strategy-options.ts
blob: f6270388ea70b914e5f2c53fb0f0079ed341d9d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
 * @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */
/* tslint:disable:array-type member-access variable-name typedef
 only-arrow-functions directive-class-suffix component-class-suffix
 component-selector no-unused-expression*/
import {Injectable} from '@angular/core';

import {ViewportRuler} from '../position/viewport-ruler';

import {BlockScrollStrategy} from './block-scroll-strategy';
import {CloseScrollStrategy} from './close-scroll-strategy';
import {NoopScrollStrategy} from './noop-scroll-strategy';
import {RepositionScrollStrategy, RepositionScrollStrategyConfig} from './reposition-scroll-strategy';
import {ScrollDispatcher} from './scroll-dispatcher';
// import {ScrollStrategy} from './scroll-strategy';


/**
 * Options for how an overlay will handle scrolling.
 *
 * Users can provide a custom value for `ScrollStrategyOptions` to replace the
 * default behaviors. This class primarily acts as a factory for ScrollStrategy
 * instances.
 */
@Injectable()
export class ScrollStrategyOptions {
  constructor(
		private _scrollDispatcher: ScrollDispatcher,
		private _viewportRuler: ViewportRuler) {}

  /** Do nothing on scroll. */
  noop = () => new NoopScrollStrategy();

  /** Close the overlay as soon as the user scrolls. */
  close = () => new CloseScrollStrategy(this._scrollDispatcher);

  /** Block scrolling. */
  block = () => new BlockScrollStrategy(this._viewportRuler);

  /**
   * Update the overlay's position on scroll.
   * @param config Configuration to be used inside the scroll strategy.
   * Allows debouncing the reposition calls.
   */
  reposition = (config?: RepositionScrollStrategyConfig) =>
		new RepositionScrollStrategy(this._scrollDispatcher, config)
}