Skip to content

Commit

Permalink
Reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
farvellhub committed Oct 3, 2023
1 parent 01ae45d commit f9a90d7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
14 changes: 7 additions & 7 deletions src/events/click.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import State from "../animations/state";
import { State } from "../core";

class Click {
keys: Element[];

constructor( target: string ) {
this.keys = [ ...document.querySelectorAll( `.${target}` ) ];
constructor(target: string) {
this.keys = [...document.querySelectorAll(`.${target}`)];
}

async listen( states: State[]): Promise<void> {
this.keys.forEach(( trigger: Element ) => {
trigger.addEventListener( "click", ( e ) => {
public listen(states: State[]) {
this.keys.forEach((trigger: Element) => {
trigger.addEventListener("click", (e) => {
e.stopPropagation();
states.forEach(( state ) => {
states.forEach((state) => {
state.toggleStates();
});
});
Expand Down
5 changes: 3 additions & 2 deletions src/events/scroll.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import State from "../animations/state";
import State from "../core/state";

// Animate over scroll.
class Scroll {
#offset: number;
#scroll: number;
Expand All @@ -20,7 +21,7 @@ class Scroll {
|| ( this.#scroll >= this.#offset && !this.#isActive ));
}

async listen( states: State[]): Promise<void> {
public listen( states: State[]) {
document.addEventListener( "scroll", () => {
if ( this.controlScroll()) {
states.forEach(( state ) => {
Expand Down
23 changes: 12 additions & 11 deletions src/events/time.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
import State from "../animations/state";
import { State } from "../core/";

// Animate over time.
class Time {
#time: number;
#interval!: NodeJS.Timeout;
#interval: number;

constructor( time: number ) {
constructor(time: number) {
this.#time = time;
}

async once( states: State[]): Promise<void> {
public async once(states: State[]) {
setTimeout(() => {
states.forEach(( state ) => {
states.forEach((state) => {
state.toggleStates();
});
}, this.#time );
}, this.#time);
}

async loop( ...states: State[]): Promise<void> {
public loop(states: State[]) {
this.#interval = setInterval(() => {
states.forEach(( state ) => {
states.forEach((state) => {
state.toggleStates();
});
}, this.#time );
}, this.#time);
}

async clearLoop(): Promise<void> {
clearInterval( this.#interval );
public clearLoop() {
clearInterval(this.#interval);
}
}

Expand Down

0 comments on commit f9a90d7

Please sign in to comment.