destroy-the-text 1.0.11 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -38
- package/dist/DTTSounds.d.ts +9 -0
- package/dist/DTTSounds.d.ts.map +1 -0
- package/dist/DTTSounds.js +38 -0
- package/dist/DestroyTheText.d.ts +19 -0
- package/dist/DestroyTheText.d.ts.map +1 -0
- package/dist/DestroyTheText.js +156 -0
- package/dist/Letra.d.ts +11 -0
- package/dist/Letra.d.ts.map +1 -0
- package/dist/Letra.js +40 -0
- package/dist/Pixel.d.ts +11 -0
- package/dist/Pixel.d.ts.map +1 -0
- package/dist/Pixel.js +32 -0
- package/dist/index.d.ts +6 -22
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -11203
- package/dist/styles.d.ts +2 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +47 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/package.json +32 -29
- package/dist/sounds/effect1.mp3 +0 -0
- package/dist/sounds/effect2.mp3 +0 -0
- package/dist/sounds/effect3.mp3 +0 -0
- package/dist/sounds/gun.mp3 +0 -0
- package/src/ts/index.ts +0 -368
- package/src/ts/sounds/effect1.mp3 +0 -0
- package/src/ts/sounds/effect2.mp3 +0 -0
- package/src/ts/sounds/effect3.mp3 +0 -0
- package/src/ts/sounds/gun.mp3 +0 -0
- package/tsconfig.json +0 -14
- package/tslint.json +0 -90
- package/webpack.dev.config.js +0 -86
package/README.md
CHANGED
|
@@ -1,38 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Destroy any text of your website. Easy to use. And very useless
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
# destroy-the-text
|
|
2
|
+
|
|
3
|
+
Destroy any text of your website. Easy to use. And very useless.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i destroy-the-text --save
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
import { DestroyTheText, Tool } from "destroy-the-text";
|
|
15
|
+
|
|
16
|
+
// Simple example
|
|
17
|
+
new DestroyTheText({
|
|
18
|
+
textId: "example_1",
|
|
19
|
+
arma: Tool.gun
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Options
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
new DestroyTheText({
|
|
27
|
+
textId: "example_2",
|
|
28
|
+
text: ["Example with special hand", "Example with big gun"],
|
|
29
|
+
armas: [Tool.specialHand, Tool.bigGun]
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
new DestroyTheText({
|
|
35
|
+
textId: "example_3",
|
|
36
|
+
arma: Tool.specialHand,
|
|
37
|
+
callbackEnd: () => location.href = "./"
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Tools
|
|
42
|
+
|
|
43
|
+
- **Gun** (`Tool.gun`) - Click to shoot letters with pixel effects
|
|
44
|
+
- **BigGun** (`Tool.bigGun`) - Hover to destroy letters automatically
|
|
45
|
+
- **Hand** (`Tool.hand`) - Click to grab letters and make them fall
|
|
46
|
+
- **SpecialHand** (`Tool.specialHand`) - Hover to grab letters and make them fall
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
### DestroyTheText
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
new DestroyTheText(options: DestroyTheTextOptions)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### DestroyTheTextOptions
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
{
|
|
60
|
+
textId: string; // ID of the element to destroy
|
|
61
|
+
arma: Tool; // Tool to use for destruction
|
|
62
|
+
text?: string[]; // Array of sequential texts
|
|
63
|
+
armas?: Tool[]; // Array of sequential tools
|
|
64
|
+
activate?: () => void; // Callback when destruction starts
|
|
65
|
+
callbackEnd?: () => void; // Callback when destruction ends
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### DTTSounds
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
DTTSounds.setGun(paths: string[]) // Set gun sound effects
|
|
73
|
+
DTTSounds.setEffects(paths: string[]) // Set hand sound effects
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DTTSounds.d.ts","sourceRoot":"","sources":["../src/DTTSounds.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;UACN,MAAM,EAAE;aACL,MAAM,EAAE;kBAET,MAAM,EAAE;sBAMJ,MAAM,EAAE;;;CA2B7B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const DTTSounds = {
|
|
2
|
+
guns: [],
|
|
3
|
+
effects: [],
|
|
4
|
+
setGun(paths) {
|
|
5
|
+
paths.forEach(path => {
|
|
6
|
+
this.guns.push(path);
|
|
7
|
+
});
|
|
8
|
+
},
|
|
9
|
+
setEffects(paths) {
|
|
10
|
+
paths.forEach(path => {
|
|
11
|
+
this.effects.push(path);
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
playGun() {
|
|
15
|
+
if (this.guns.length === 0)
|
|
16
|
+
return;
|
|
17
|
+
const randomIndex = Math.floor(Math.random() * this.guns.length);
|
|
18
|
+
try {
|
|
19
|
+
new Audio(this.guns[randomIndex]).play();
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
console.warn('Could not play gun sound:', e);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
playEffect() {
|
|
26
|
+
if (this.effects.length === 0)
|
|
27
|
+
return;
|
|
28
|
+
const randomIndex = Math.floor(Math.random() * this.effects.length);
|
|
29
|
+
try {
|
|
30
|
+
const audio = new Audio(this.effects[randomIndex]);
|
|
31
|
+
audio.volume = 0.3;
|
|
32
|
+
audio.play();
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.warn('Could not play effect sound:', e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DestroyTheTextOptions } from "./types";
|
|
2
|
+
export declare class DestroyTheText {
|
|
3
|
+
private container;
|
|
4
|
+
private callback;
|
|
5
|
+
private started;
|
|
6
|
+
private count;
|
|
7
|
+
private callbackEnd;
|
|
8
|
+
private listWords;
|
|
9
|
+
private text;
|
|
10
|
+
private arma;
|
|
11
|
+
private originalTagName;
|
|
12
|
+
private originalClass;
|
|
13
|
+
private armas;
|
|
14
|
+
constructor(params: DestroyTheTextOptions);
|
|
15
|
+
private buildLetters;
|
|
16
|
+
private attachEventListener;
|
|
17
|
+
private destrozar;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=DestroyTheText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DestroyTheText.d.ts","sourceRoot":"","sources":["../src/DestroyTheText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAQtD,qBAAa,cAAc;IACvB,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,WAAW,CAA0C;IAC7D,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,IAAI,CAA4B;IACxC,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,eAAe,CAAc;IACrC,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,KAAK,CAA4B;gBAE7B,MAAM,EAAE,qBAAqB;IAuCzC,OAAO,CAAC,YAAY;IAoCpB,OAAO,CAAC,mBAAmB;IA6B3B,OAAO,CAAC,SAAS;CAiEpB"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Tool } from "./types";
|
|
2
|
+
import { Pixel } from "./Pixel";
|
|
3
|
+
import { Letra } from "./Letra";
|
|
4
|
+
import { DTTSounds } from "./DTTSounds";
|
|
5
|
+
// @ts-ignore - jQuery require
|
|
6
|
+
const $ = require("jquery");
|
|
7
|
+
export class DestroyTheText {
|
|
8
|
+
constructor(params) {
|
|
9
|
+
this.started = false;
|
|
10
|
+
this.count = 0;
|
|
11
|
+
this.listWords = [];
|
|
12
|
+
this.originalTagName = "";
|
|
13
|
+
this.originalClass = "";
|
|
14
|
+
this.callback = params.activate;
|
|
15
|
+
this.callbackEnd = params.callbackEnd;
|
|
16
|
+
const elem = $("#" + params.textId)[0];
|
|
17
|
+
if (elem === undefined) {
|
|
18
|
+
console.log("Element " + params.textId + " does not exist");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
this.originalTagName = elem.tagName;
|
|
22
|
+
this.originalClass = elem.className;
|
|
23
|
+
this.container = $(document.createElement("div"));
|
|
24
|
+
this.container.attr("id", params.textId);
|
|
25
|
+
this.container.addClass(this.originalClass);
|
|
26
|
+
this.arma = params.arma;
|
|
27
|
+
this.armas = params.armas;
|
|
28
|
+
if (this.armas !== undefined) {
|
|
29
|
+
this.arma = this.armas[0];
|
|
30
|
+
this.armas.shift();
|
|
31
|
+
}
|
|
32
|
+
let text = $("#" + params.textId).html();
|
|
33
|
+
if (params.text !== undefined && params.text.length !== 0) {
|
|
34
|
+
this.text = params.text;
|
|
35
|
+
text = params.text[0];
|
|
36
|
+
params.text.shift();
|
|
37
|
+
}
|
|
38
|
+
this.container.css("text-align", $(elem).css("text-align"));
|
|
39
|
+
this.container.css("margin", $(elem).css("margin"));
|
|
40
|
+
this.buildLetters(text, elem);
|
|
41
|
+
$("#" + params.textId).replaceWith(this.container);
|
|
42
|
+
}
|
|
43
|
+
buildLetters(text, elem) {
|
|
44
|
+
let countWords = 0;
|
|
45
|
+
let lastWord = $(document.createElement("div"));
|
|
46
|
+
lastWord.css("display", "inline-block");
|
|
47
|
+
lastWord.attr("id", "word" + countWords);
|
|
48
|
+
for (let i = 0; i < text.length; i++) {
|
|
49
|
+
const letter = $(document.createElement(this.originalTagName));
|
|
50
|
+
this.listWords.push({ id: i, letter });
|
|
51
|
+
letter.html(text[i]);
|
|
52
|
+
letter.css("color", elem.style.color);
|
|
53
|
+
const fontSize = $(elem).css("font-size");
|
|
54
|
+
letter.css("font-size", fontSize);
|
|
55
|
+
lastWord.append(letter);
|
|
56
|
+
if (!$(lastWord.attr("id")).length) {
|
|
57
|
+
this.container.append(lastWord);
|
|
58
|
+
}
|
|
59
|
+
letter.addClass("letterEffect");
|
|
60
|
+
if (text[i] === " ") {
|
|
61
|
+
letter.html(" ");
|
|
62
|
+
countWords++;
|
|
63
|
+
lastWord = $(document.createElement("div"));
|
|
64
|
+
lastWord.attr("id", "word" + countWords);
|
|
65
|
+
lastWord.css("display", "inline-block");
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
this.count++;
|
|
69
|
+
this.attachEventListener(letter);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
attachEventListener(letter) {
|
|
73
|
+
switch (this.arma) {
|
|
74
|
+
case Tool.gun:
|
|
75
|
+
letter.click((e) => {
|
|
76
|
+
this.destrozar(letter, e);
|
|
77
|
+
});
|
|
78
|
+
break;
|
|
79
|
+
case Tool.bigGun:
|
|
80
|
+
$(letter).mouseenter((e) => {
|
|
81
|
+
this.destrozar(letter, e);
|
|
82
|
+
});
|
|
83
|
+
break;
|
|
84
|
+
case Tool.hand:
|
|
85
|
+
letter.click((e) => {
|
|
86
|
+
this.destrozar(letter, e, Tool.hand);
|
|
87
|
+
});
|
|
88
|
+
break;
|
|
89
|
+
case Tool.all:
|
|
90
|
+
case Tool.specialHand:
|
|
91
|
+
$(letter).mouseenter((e) => {
|
|
92
|
+
this.destrozar(letter, e, Tool.hand);
|
|
93
|
+
});
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
destrozar(letter, e, arma) {
|
|
98
|
+
if (!this.started) {
|
|
99
|
+
this.started = true;
|
|
100
|
+
if (this.callback) {
|
|
101
|
+
this.callback();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (letter.hasClass("oculto")) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
$("#mouse").addClass("mouseOver");
|
|
108
|
+
setTimeout(() => {
|
|
109
|
+
$("#mouse").removeClass("mouseOver");
|
|
110
|
+
}, 100);
|
|
111
|
+
const puntos = $("#puntos");
|
|
112
|
+
if (puntos.length) {
|
|
113
|
+
puntos.html(+puntos.html() + 1);
|
|
114
|
+
}
|
|
115
|
+
if (this.count === 1) {
|
|
116
|
+
if (this.callbackEnd) {
|
|
117
|
+
if (arma === Tool.hand) {
|
|
118
|
+
setTimeout(() => {
|
|
119
|
+
this.callbackEnd(this.container);
|
|
120
|
+
}, 1500);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
this.callbackEnd(this.container);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (this.text !== undefined && this.text.length !== 0) {
|
|
127
|
+
const newContainer = $(document.createElement(this.originalTagName));
|
|
128
|
+
let newText = "";
|
|
129
|
+
newContainer.html(newText);
|
|
130
|
+
newContainer.addClass(this.originalClass);
|
|
131
|
+
newContainer.html(this.text[0]);
|
|
132
|
+
newContainer.attr("id", this.container.attr("id"));
|
|
133
|
+
this.container.replaceWith(newContainer);
|
|
134
|
+
new DestroyTheText({
|
|
135
|
+
textId: this.container.attr("id"),
|
|
136
|
+
text: this.text,
|
|
137
|
+
arma: this.arma,
|
|
138
|
+
armas: this.armas,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
this.count--;
|
|
143
|
+
letter.addClass("oculto");
|
|
144
|
+
if (arma === Tool.hand) {
|
|
145
|
+
new Letra(e.pageX, e.pageY, letter);
|
|
146
|
+
DTTSounds.playEffect();
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const n = 3;
|
|
150
|
+
for (let j = 0; j < n; j++) {
|
|
151
|
+
new Pixel(e.pageX, e.pageY, letter.parent().css("color"));
|
|
152
|
+
}
|
|
153
|
+
DTTSounds.playGun();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
package/dist/Letra.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class Letra {
|
|
2
|
+
private x;
|
|
3
|
+
private y;
|
|
4
|
+
private container;
|
|
5
|
+
private direction;
|
|
6
|
+
private gravitySpeed;
|
|
7
|
+
constructor(x: number, y: number, container: any);
|
|
8
|
+
private gravity;
|
|
9
|
+
private getPositiveOrNegative;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=Letra.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Letra.d.ts","sourceRoot":"","sources":["../src/Letra.ts"],"names":[],"mappings":"AAAA,qBAAa,KAAK;IACd,OAAO,CAAC,CAAC,CAAS;IAClB,OAAO,CAAC,CAAC,CAAS;IAClB,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,YAAY,CAAa;gBAErB,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG;IAiChD,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,qBAAqB;CAGhC"}
|
package/dist/Letra.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export class Letra {
|
|
2
|
+
constructor(x, y, container) {
|
|
3
|
+
this.gravitySpeed = 0;
|
|
4
|
+
// @ts-ignore - jQuery require
|
|
5
|
+
const $ = require("jquery");
|
|
6
|
+
this.container = container.clone();
|
|
7
|
+
this.container.removeClass("oculto");
|
|
8
|
+
this.container.addClass("absolute");
|
|
9
|
+
this.x = x;
|
|
10
|
+
this.y = y;
|
|
11
|
+
this.container.css("color", container.parent().css("color"));
|
|
12
|
+
this.container.css("left", this.x + "px");
|
|
13
|
+
this.container.css("top", this.y + "px");
|
|
14
|
+
let fontSize = container.css("font-size");
|
|
15
|
+
if (fontSize === undefined) {
|
|
16
|
+
fontSize = container.parent().css("font-size");
|
|
17
|
+
}
|
|
18
|
+
if (fontSize !== undefined) {
|
|
19
|
+
this.container.css("font-size", fontSize);
|
|
20
|
+
this.container.css("margin-top", "-" + fontSize);
|
|
21
|
+
}
|
|
22
|
+
$("body").append(this.container);
|
|
23
|
+
const interval = setInterval(() => this.gravity(), 1);
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
clearInterval(interval);
|
|
26
|
+
this.container.remove();
|
|
27
|
+
}, 3000);
|
|
28
|
+
this.direction = { x: this.getPositiveOrNegative() * Math.random(), y: 0 };
|
|
29
|
+
}
|
|
30
|
+
gravity() {
|
|
31
|
+
this.container.css("left", this.x + "px");
|
|
32
|
+
this.container.css("top", this.y + "px");
|
|
33
|
+
this.gravitySpeed += 0.01;
|
|
34
|
+
this.y += this.gravitySpeed;
|
|
35
|
+
this.x += this.direction.x;
|
|
36
|
+
}
|
|
37
|
+
getPositiveOrNegative() {
|
|
38
|
+
return Math.floor(Math.random() * 2) === 0 ? -1 : 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
package/dist/Pixel.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class Pixel {
|
|
2
|
+
private x;
|
|
3
|
+
private y;
|
|
4
|
+
private container;
|
|
5
|
+
private direction;
|
|
6
|
+
private gravitySpeed;
|
|
7
|
+
constructor(x: number, y: number, color: string);
|
|
8
|
+
private gravity;
|
|
9
|
+
private getPositiveOrNegative;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=Pixel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pixel.d.ts","sourceRoot":"","sources":["../src/Pixel.ts"],"names":[],"mappings":"AAAA,qBAAa,KAAK;IACd,OAAO,CAAC,CAAC,CAAS;IAClB,OAAO,CAAC,CAAC,CAAS;IAClB,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,YAAY,CAAa;gBAErB,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAuB/C,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,qBAAqB;CAGhC"}
|
package/dist/Pixel.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class Pixel {
|
|
2
|
+
constructor(x, y, color) {
|
|
3
|
+
this.gravitySpeed = 0;
|
|
4
|
+
const length = 25;
|
|
5
|
+
this.x = x;
|
|
6
|
+
this.y = y + this.getPositiveOrNegative() * Math.floor(Math.random() * length);
|
|
7
|
+
// @ts-ignore - jQuery require
|
|
8
|
+
const $ = require("jquery");
|
|
9
|
+
this.container = $(document.createElement("div"));
|
|
10
|
+
this.container.addClass("pixel");
|
|
11
|
+
this.container.css("background", color);
|
|
12
|
+
this.container.css("left", this.x + "px");
|
|
13
|
+
this.container.css("top", this.y + "px");
|
|
14
|
+
$("body").append(this.container);
|
|
15
|
+
const interval = setInterval(() => this.gravity(), 1);
|
|
16
|
+
setTimeout(() => {
|
|
17
|
+
clearInterval(interval);
|
|
18
|
+
this.container.remove();
|
|
19
|
+
}, 3000);
|
|
20
|
+
this.direction = { x: this.getPositiveOrNegative() * Math.random(), y: 0 };
|
|
21
|
+
}
|
|
22
|
+
gravity() {
|
|
23
|
+
this.container.css("left", this.x + "px");
|
|
24
|
+
this.container.css("top", this.y + "px");
|
|
25
|
+
this.gravitySpeed += 0.01;
|
|
26
|
+
this.y += this.gravitySpeed;
|
|
27
|
+
this.x += this.direction.x;
|
|
28
|
+
}
|
|
29
|
+
getPositiveOrNegative() {
|
|
30
|
+
return Math.floor(Math.random() * 2) === 0 ? -1 : 1;
|
|
31
|
+
}
|
|
32
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
export declare class DestroyTheText {
|
|
9
|
-
private container;
|
|
10
|
-
private callback;
|
|
11
|
-
private started;
|
|
12
|
-
private count;
|
|
13
|
-
private callbackEnd;
|
|
14
|
-
private listWords;
|
|
15
|
-
private text;
|
|
16
|
-
private arma;
|
|
17
|
-
private originalTagName;
|
|
18
|
-
private originalClass;
|
|
19
|
-
private armas;
|
|
20
|
-
constructor(params: any);
|
|
21
|
-
private destrozar;
|
|
22
|
-
}
|
|
1
|
+
export { DestroyTheText } from "./DestroyTheText";
|
|
2
|
+
export { Tool } from "./types";
|
|
3
|
+
export type { DestroyTheTextOptions } from "./types";
|
|
4
|
+
export { DTTSounds } from "./DTTSounds";
|
|
5
|
+
export { addStyles } from "./styles";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC"}
|