Skip to content

Commit cdee673

Browse files
committed
add data attribute support for layerDepth setting
1 parent 379bd0d commit cdee673

File tree

11 files changed

+46
-12
lines changed

11 files changed

+46
-12
lines changed

dist/esm/constants.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export declare const PUSH_IN_DEFAULT_BREAKPOINTS: number[];
77
export declare const PUSH_IN_LAYER_INDEX_ATTRIBUTE = "data-pushin-layer-index";
88
export declare const PUSH_IN_DEFAULT_ASPECT_RATIO: number[];
99
export declare const PUSH_IN_DEFAULT_TRANSITION_LENGTH = 200;
10+
export declare const PUSH_IN_DEFAULT_LAYER_DEPTH = 1000;

dist/esm/pushInScene.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export declare class PushInScene extends PushInBase {
2525
* - screen-top Start effect when target element top at viewport top.
2626
*/
2727
setAutoStart(): void;
28+
setLayerDepth(): void;
2829
/**
2930
* Setup composition for the scene.
3031
*/

dist/esm/pushin.js

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/pushin.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export interface SceneOptions {
3131
ratio?: number[];
3232
}
3333
export interface SceneSettings {
34-
layerDepth: number;
3534
breakpoints: number[];
3635
inpoints: number[];
3736
layers: LayerOptions[];
37+
layerDepth?: number;
3838
composition?: CompositionOptions;
3939
ratio?: number[];
4040
autoStart?: string;

dist/umd/pushin.js

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/umd/pushin.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/umd/pushin.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ export const PUSH_IN_LAYER_INDEX_ATTRIBUTE = 'data-pushin-layer-index';
1818
export const PUSH_IN_DEFAULT_ASPECT_RATIO = [1, 2];
1919

2020
export const PUSH_IN_DEFAULT_TRANSITION_LENGTH = 200;
21+
22+
export const PUSH_IN_DEFAULT_LAYER_DEPTH = 1000;

src/pushInScene.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
PUSH_IN_FROM_DATA_ATTRIBUTE,
33
PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE,
44
PUSH_IN_DEFAULT_BREAKPOINTS,
5+
PUSH_IN_DEFAULT_LAYER_DEPTH,
56
} from './constants';
67
import { PushInComposition } from './pushInComposition';
78
import { PushInLayer } from './pushInLayer';
@@ -12,7 +13,7 @@ import { LayerOptions, SceneSettings } from './types';
1213

1314
export class PushInScene extends PushInBase {
1415
public layers: PushInLayer[];
15-
public layerDepth: number;
16+
public layerDepth!: number;
1617
public settings: SceneSettings;
1718
public composition?: PushInComposition;
1819
public layerCount!: number;
@@ -24,7 +25,7 @@ export class PushInScene extends PushInBase {
2425
const options = pushin.options?.scene ?? {};
2526

2627
this.settings = {
27-
layerDepth: options?.layerDepth || 1000,
28+
layerDepth: options?.layerDepth,
2829
breakpoints: options?.breakpoints || [],
2930
inpoints: options?.inpoints || [],
3031
composition: pushin.options?.composition,
@@ -33,14 +34,14 @@ export class PushInScene extends PushInBase {
3334
autoStart: pushin.options?.autoStart,
3435
};
3536

36-
this.layerDepth = this.settings.layerDepth;
3737
this.layers = [];
3838
}
3939

4040
/* istanbul ignore next */
4141
start(): void {
4242
this.setContainer();
4343
this.setAutoStart();
44+
this.setLayerDepth();
4445
this.setSceneClasses();
4546
this.setComposition();
4647
this.setBreakpoints();
@@ -88,6 +89,17 @@ export class PushInScene extends PushInBase {
8889
this.settings.autoStart = autoStart;
8990
}
9091

92+
setLayerDepth() {
93+
let layerDepth = this.getNumberOption('layerDepth');
94+
95+
if (layerDepth && typeof layerDepth !== 'number') {
96+
// not yet compatible with array - set to first index if array passed in.
97+
[layerDepth] = layerDepth;
98+
}
99+
100+
this.layerDepth = layerDepth ?? PUSH_IN_DEFAULT_LAYER_DEPTH;
101+
}
102+
91103
/**
92104
* Setup composition for the scene.
93105
*/

0 commit comments

Comments
 (0)