Skip to content

Commit

Permalink
remove private properties
Browse files Browse the repository at this point in the history
  • Loading branch information
clementroche committed Feb 22, 2024
1 parent ab1af4a commit 686b354
Show file tree
Hide file tree
Showing 12 changed files with 1,021 additions and 3,677 deletions.
2 changes: 1 addition & 1 deletion packages/lenis/dist/lenis.cjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/lenis/dist/lenis.cjs.js.map

Large diffs are not rendered by default.

1,221 changes: 592 additions & 629 deletions packages/lenis/dist/lenis.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/lenis/dist/lenis.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/lenis/dist/lenis.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/lenis/dist/lenis.mjs.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/lenis/dist/lenis.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/lenis/dist/lenis.umd.js.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions packages/lenis/dist/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export type LenisOptions = {
autoResize?: boolean;
};
export default class Lenis {
#private;
__isSmooth: boolean;
__isScrolling: boolean;
__isStopped: boolean;
__isLocked: boolean;
constructor({ wrapper, content, wheelEventsTarget, eventsTarget, smoothWheel, syncTouch, syncTouchLerp, touchInertiaMultiplier, duration, easing, lerp, infinite, orientation, gestureOrientation, touchMultiplier, wheelMultiplier, normalizeWheel, autoResize, }?: LenisOptions);
destroy(): void;
on(event: string, callback: Function): any;
Expand Down Expand Up @@ -62,6 +65,6 @@ export default class Lenis {
get isLocked(): boolean;
private set isLocked(value);
get className(): string;
private toggleClass;
private toggleClassName;
}
export {};
54 changes: 27 additions & 27 deletions packages/lenis/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export type LenisOptions = {
}

export default class Lenis {
#isSmooth: boolean = false // true if scroll should be animated
#isScrolling: boolean = false // true when scroll is animating
#isStopped: boolean = false // true if user should not be able to scroll - enable/disable programmatically
#isLocked: boolean = false // same as isStopped but enabled/disabled when scroll reaches target
__isSmooth: boolean = false // true if scroll should be animated
__isScrolling: boolean = false // true when scroll is animating
__isStopped: boolean = false // true if user should not be able to scroll - enable/disable programmatically
__isLocked: boolean = false // same as isStopped but enabled/disabled when scroll reaches target

constructor({
wrapper = window,
Expand Down Expand Up @@ -95,7 +95,7 @@ export default class Lenis {
this.animate = new Animate()
this.emitter = new Emitter()
this.dimensions = new Dimensions({ wrapper, content, autoResize })
this.toggleClass('lenis', true)
this.toggleClassName('lenis', true)

this.velocity = 0
this.isLocked = false
Expand Down Expand Up @@ -126,11 +126,11 @@ export default class Lenis {
this.virtualScroll.destroy()
this.dimensions.destroy()

this.toggleClass('lenis', false)
this.toggleClass('lenis-smooth', false)
this.toggleClass('lenis-scrolling', false)
this.toggleClass('lenis-stopped', false)
this.toggleClass('lenis-locked', false)
this.toggleClassName('lenis', false)
this.toggleClassName('lenis-smooth', false)
this.toggleClassName('lenis-scrolling', false)
this.toggleClassName('lenis-stopped', false)
this.toggleClassName('lenis-locked', false)
}

on(event: string, callback: Function) {
Expand Down Expand Up @@ -449,46 +449,46 @@ export default class Lenis {
}

get isSmooth() {
return this.#isSmooth
return this.__isSmooth
}

private set isSmooth(value: boolean) {
if (this.#isSmooth !== value) {
this.#isSmooth = value
this.toggleClass('lenis-smooth', value)
if (this.__isSmooth !== value) {
this.__isSmooth = value
this.toggleClassName('lenis-smooth', value)
}
}

get isScrolling() {
return this.#isScrolling
return this.__isScrolling
}

private set isScrolling(value: boolean) {
if (this.#isScrolling !== value) {
this.#isScrolling = value
this.toggleClass('lenis-scrolling', value)
if (this.__isScrolling !== value) {
this.__isScrolling = value
this.toggleClassName('lenis-scrolling', value)
}
}

get isStopped() {
return this.#isStopped
return this.__isStopped
}

private set isStopped(value: boolean) {
if (this.#isStopped !== value) {
this.#isStopped = value
this.toggleClass('lenis-stopped', value)
if (this.__isStopped !== value) {
this.__isStopped = value
this.toggleClassName('lenis-stopped', value)
}
}

get isLocked() {
return this.#isLocked
return this.__isLocked
}

private set isLocked(value: boolean) {
if (this.#isLocked !== value) {
this.#isLocked = value
this.toggleClass('lenis-locked', value)
if (this.__isLocked !== value) {
this.__isLocked = value
this.toggleClassName('lenis-locked', value)
}
}

Expand All @@ -501,7 +501,7 @@ export default class Lenis {
return className
}

private toggleClass(name: string, value: boolean) {
private toggleClassName(name: string, value: boolean) {
this.rootElement.classList.toggle(name, value)
this.emitter.emit('className change', this)
}
Expand Down
Loading

1 comment on commit 686b354

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"⚡️ Lighthouse report for the changes in this commit:

🟠 Performance: 79
🟢 Accessibility: 96
🟢 Best practices: 100
🟠 SEO: 67
🔴 PWA: 33

Lighthouse ran on https://lenis-rf49x723m-studio-freight.vercel.app/"

Please sign in to comment.