Browse Source

refactor: default timeout of 6 seconds if timeout not specified

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 4 years ago
parent
commit
12a029fd1b
4 changed files with 9 additions and 6 deletions
  1. 0 0
      dist/toasters.js
  2. 1 2
      example/index.js
  3. 4 4
      src/toasters.js
  4. 4 0
      webpack.config.js

File diff suppressed because it is too large
+ 0 - 0
dist/toasters.js


+ 1 - 2
example/index.js

@@ -1,6 +1,5 @@
 import Toast from "../dist/toasters.js";
 
 new Toast({
-	content: "Hello World",
-	persistant: true
+	content: "Hello World"
 });

+ 4 - 4
src/toasters.js

@@ -4,17 +4,17 @@ let incrementer = 0;
 
 export default class Toast {
 	// should add type checking
-	constructor({ content, persistant, timeout }) {
+	constructor({ content, persistent, timeout }) {
 		this.identifier = `toast-${incrementer}`;
 		incrementer++;
 
 		this.visible = false;
 
 		this.content = content;
-		this.persistant = persistant;
+		this.persistent = persistent;
 		this.timeout = timeout;
 
-		if (!this.persistant) this.startTimer();
+		if (!this.persistent) this.startTimer();
 
 		this.dragListener();
 	}
@@ -29,7 +29,7 @@ export default class Toast {
 	}
 
 	startTimer() {
-		setTimeout(this.clear.bind(this), this.timeout);
+		setTimeout(this.clear.bind(this), this.timeout ? this.timeout : 6000);
 	}
 
 	display() {

+ 4 - 0
webpack.config.js

@@ -16,5 +16,9 @@ module.exports = {
       { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" },
       { test: /\.css$/i, use: [ "style-loader", "css-loader" ] },
     ]
+  },
+  watchOptions: {
+    poll: true,
+    ignored: /node_modules/
   }
 }

Some files were not shown because too many files changed in this diff