Skip to content

Commit 2a74b40

Browse files
committed
新增 :animation:mask 屬性以及圖片延遲載入的優化,增加過度效果,以提升載入體驗。
1 parent d86f8b2 commit 2a74b40

11 files changed

Lines changed: 238 additions & 130 deletions

File tree

README.en.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Automatic Rendering: Automatically reloads when data changes are detected.
4848
| `:if`<br>`:else-if`<br>`:elif`<br>`:else` | Displays or hides elements based on specified conditions, enabling branching logic. |
4949
| `:model` | Binds data to form elements (e.g., `input`), updating data automatically when input changes. |
5050
| `:hide` | Hides elements based on specific conditions. |
51+
| `:animation` | Specifies transition effects for elements, such as `fade-in` or `expand`, to enhance user experience. |
52+
| `:mask` | Controls block loading animations, supporting `true|false|1|0`, to enhance dynamic visual effects during loading. |
5153
| `:[attr]` | Sets element attributes, such as `ID`, `class`, image source, etc.<br>Examples: `:id`/`:class`/`:src`/`:alt`/`:href`... |
5254
| `@[event]` | Adds event listeners that trigger specified actions upon activation.<br>Examples: `@click`/`@input`/`@mousedown`... |
5355
| `:@[event]` | Sets event handlers for individual elements within loops, allowing different handlers for each element. |

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PDQuickUI (JavaScript Library)
1+
# PDQuickUI
22

33
![](https://img.shields.io/badge/tag-JavaScript%20Library-bb4444) ![](https://img.shields.io/github/size/pardnchiu/PDQuickUI/dist%2FPDQuickUI.js)<br>
44
[![](https://img.shields.io/github/v/release/pardnchiu/PDQuickUI)](https://github.com/pardnchiu/PDQuickUI) [![](https://img.shields.io/npm/v/pdquickui)](https://www.npmjs.com/package/pdquickui) ![](https://img.shields.io/github/license/pardnchiu/PDQuickUI)<br>
@@ -15,7 +15,7 @@
1515
- **清晰的架構**:UI 和資料邏輯分離,維護方便。
1616
- **代碼簡潔**:減少重複代碼,提升可讀性。
1717
- **自動渲染**:監控資料變動並自動更新,減少手動操作。
18-
- **輕量化**功能完整的同時,文件大小控制在 `20kb` 以內
18+
- **輕量化**使用原生 JS 和內建 API 撰寫,無任何外部依賴
1919

2020
## 安裝方式
2121

@@ -48,6 +48,8 @@
4848
| `:if`<br>`:else-if`<br>`:elif`<br>`:else` | 根據條件顯示或隱藏元素,實現分支邏輯。 |
4949
| `:model` | 將資料綁定到表單元素(如 `input`),當輸入變更時自動更新資料。 |
5050
| `:hide` | 根據特定條件隱藏元素。 |
51+
| `:animation` | 用於指定元素的過渡效果,如 `fade-in``expand`,以增強用戶體驗。 |
52+
| `:mask` | 控制區塊載入時的動畫效果,支援 `true|false|1|0`,提升載入動態視覺效果。 |
5153
| `:[attr]` | 設定元素屬性,例如 `ID``class`、圖像來源等。<br>範例:`:id``:class``:src``:alt``:href`... |
5254
| `@[event]` | 添加事件監聽器,當事件觸發時執行指定操作。<br>範例:`@click``@input``@mousedown`... |
5355

dist/PDQuickUI.css

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
*[\:animation="fade-in"],
2+
*[animation="fade-in"] {
3+
opacity: 0;
4+
transition: opacity 0.3s ease-in 0s;
5+
}
6+
7+
*[\:animation="fade-in"].show,
8+
*[animation="fade-in"].show {
9+
opacity: 1;
10+
}
11+
12+
*[\:animation="expand"],
13+
*[animation="expand"] {
14+
min-height: 0;
15+
height: 0;
16+
overflow: hidden;
17+
transition: min-height 0.3s ease-in 0s;
18+
}
19+
20+
*[\:animation="expand"].show,
21+
*[animation="expand"].show {
22+
opacity: 1;
23+
}
24+
25+
*[\:mask="1=true"],
26+
*[mask="true"],
27+
*[\:mask="1"],
28+
*[mask="1"] {
29+
position: relative;
30+
}
31+
32+
*[\:mask="1=true"]::after,
33+
*[mask="true"]::after,
34+
*[\:mask="1"]::after,
35+
*[mask="1"]::after {
36+
content: '';
37+
position: absolute;
38+
top: 0;
39+
left: 0;
40+
right: 0;
41+
bottom: 0;
42+
background: linear-gradient(to right, #e0e0e0 25%, #f0f0f0, #e0e0e0 75%);
43+
/* 使用灰色漸層 */
44+
background-size: 200% 100%;
45+
/* 背景尺寸兩倍寬度 */
46+
animation: loading-animation 1.5s infinite alternate;
47+
/* 來回移動動畫 */
48+
z-index: 10;
49+
transition: 0.3s;
50+
}
51+
52+
*[\:mask="1=true"]::after,
53+
*[mask="true"]::after,
54+
*[\:mask="1"].show::after,
55+
*[mask="1"].show::after {
56+
opacity: 0;
57+
}
58+
59+
@keyframes loading-animation {
60+
0% {
61+
background-position: -100% 0;
62+
}
63+
64+
100% {
65+
background-position: 100% 0;
66+
}
67+
}
68+
69+
img[lazyload]:not([lazyload=""]) {
70+
width: 1rem;
71+
height: 1rem;
72+
border: 0.25rem solid rgba(0, 0, 0, 0.1);
73+
border-top-color: #3498db;
74+
border-radius: 50%;
75+
animation: spin 2s ease-in-out infinite;
76+
}
77+
78+
@keyframes spin {
79+
0% {
80+
transform: rotate(0deg);
81+
}
82+
83+
100% {
84+
transform: rotate(360deg);
85+
}
86+
}
87+
88+
img[src]:not([src=""]) {
89+
width: unset;
90+
height: unset;
91+
border: 0 solid transparent;
92+
border-radius: 0;
93+
animation: none;
94+
transition: width 0.3s;
95+
transition: height 0.3s;
96+
}

dist/PDQuickUI.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/PDQuickUI.module.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)