소스 검색

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);

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.