Шутка "Обратная гравитация"

This commit is contained in:
2024-03-21 20:14:33 +04:00
parent ca1a01a06e
commit bf90f3d4c2
7 changed files with 120 additions and 8 deletions
+35
View File
@@ -0,0 +1,35 @@
import {Joke, JokeSettings} from '../joke';
import $ from 'jquery';
/**
* **Шаблон**
*
* Описание
*
* @author Kozhilya
*/
export class TemplateJoke extends Joke<TemplateJokeSettings> {
id = '';
title = '';
description = '';
_settings = new TemplateJokeSettings();
/**
* Запуск шутки
*/
start(): void {
}
}
/**
* Класс настроек для шутки ""
*/
export class TemplateJokeSettings implements JokeSettings {
enabled: boolean = true;
chance: number = 100;
}
+40
View File
@@ -0,0 +1,40 @@
import {Joke, JokeSettings} from '../joke';
/**
* **Обратная гравитация**
*
* Скролл в обратную сторону (крутишь вверх, а крутится вниз)
*
* @author Идея: Alex_63
* @author Реализация: Kozhilya
*/
export class InvertedScrollJoke extends Joke<InvertedScrollJokeSettings> {
id = 'inverted_scroll';
title = 'Обратная гравитация';
description = 'Скролл в обратную сторону';
_settings = new InvertedScrollJokeSettings();
/**
* Запуск шутки
*/
start(): void {
// let lastScroll = window.scrollY;
document.addEventListener('wheel', (e) => {
e.preventDefault();
scrollBy(0, -e.deltaY);
}, {passive: false});
}
}
/**
* Класс настроек для шутки "Обратная гравитация"
*/
export class InvertedScrollJokeSettings implements JokeSettings {
enabled: boolean = true;
chance: number = 10;
}
+2
View File
@@ -8,6 +8,7 @@ import {CrazyLettersJoke} from './jokes/crazy_letters';
import {LetterChaosJoke} from './jokes/letter_chaos';
import {CursorEffectsJoke} from './jokes/cursor';
import {StupidTitleJoke} from './jokes/stupid_title';
import {InvertedScrollJoke} from './jokes/inverted_scroll';
declare global {
interface Window { AprilJokes: JokerClass; }
@@ -32,6 +33,7 @@ window.AprilJokes = ((jokes: JokeList): JokerClass => {
LetterChaosJoke,
CursorEffectsJoke,
StupidTitleJoke,
InvertedScrollJoke,
]);
interface JokeList extends Array<new () => Joke<JokeSettings>> {}