-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,43 @@ | ||
import { Effect } from "../types/enum/effect"; | ||
|
||
class Echo implements IEcho { | ||
private defaultOptions: EchoDefaultOptions | ||
private echoEffects: IEchoEffect; | ||
private echoAudio: IEchoAudio; | ||
private echoVibration: IEchoVibration; | ||
|
||
constructor(defaultOptions = {}) { | ||
this.defaultOptions = { | ||
visualEffect: "wave", | ||
visualEffect: Effect.WAVE, | ||
sound: null, | ||
delay: 0, | ||
vibration: false, | ||
duration: 500, | ||
color: "#3498db", | ||
size: 100, | ||
...defaultOptions, | ||
} | ||
|
||
this.echoEffects = new EchoEffects(); | ||
this.echoAudio = new EchoAudio(); | ||
this.echoVibration = new EchoVibration(); | ||
} | ||
|
||
public trigger(element: HTMLElement, options: TriggerOptions): void { | ||
const config = {...this.defaultOptions, ...options}; | ||
|
||
setTimeout(() => { | ||
if(config.visualEffect) | ||
this.echoEffects._createVisualEffect(element, config) | ||
if(config.sound) { | ||
this.echoAudio._playSound(config.sound); | ||
} | ||
if(config.vibration) { | ||
this.echoVibration._triggerVibration(); | ||
} | ||
|
||
}, config.delay) | ||
} | ||
} | ||
|
||
export default Echo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class EchoAudio implements IEchoAudio { | ||
_playSound(soundUrl: string): void { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class EchoError { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class EchoVibration implements IEchoVibration{ | ||
_triggerVibration() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
interface IEchoAudio { | ||
/** | ||
* Проигрывает звук | ||
* @param {string} soundUrl | ||
*/ | ||
_playSound(soundUrl: string): void; | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
interface IEchoVibration { | ||
/** | ||
* Включает вибрацию на мобильных устройствах | ||
*/ | ||
_triggerVibration(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum Effect { | ||
WAVE = "wave", | ||
PULSE = "pulse", | ||
FLASH = "flash" | ||
} |