ソースを参照

feat: reaction to mouseup and toast not removed

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 5 年 前
コミット
16bb9e6ab9
2 ファイル変更9 行追加1 行削除
  1. 0 0
      dist/toasters.js
  2. 9 1
      src/toasters.js

ファイルの差分が大きいため隠しています
+ 0 - 0
dist/toasters.js


+ 9 - 1
src/toasters.js

@@ -51,7 +51,6 @@ export default class Toast {
 
 			const move = ({ pageX }) => {
 				let opacity = 1.2 - Math.abs(pageX - shiftX - initialX) / 100;
-				if (opacity < 0.15) return this.clear();
 				this.element.style.opacity = opacity;
 				this.element.style.left = `${pageX - shiftX - initialX}px`;
 			}
@@ -59,6 +58,15 @@ export default class Toast {
 			window.addEventListener("mousemove", move, false);
 
 			window.addEventListener("mouseup", () => {
+				if (this.element.style.opacity < 0.15) return this.clear();
+				else {
+					this.element.style.opacity = 1;
+					this.element.style.left = 0;
+					this.element.style.transition = "opacity .2s linear, left .2s linear";
+					setTimeout(() => {
+						this.element.style.transition = null;
+					}, 200)
+				}
 				window.removeEventListener("mousemove", move, false);
 			}, false);
 		}, false);

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません