文章

AOS (Animate on Scroll) Libraries in 2025

  Best AOS (Animate on Scroll) Libraries in 2025 # animation # css # frontend # html Scroll animations can make your website more engaging, but which animate on scroll library should you use? Some are too heavy, others lack flexibility. After testing the top options, here’s my ranking of the best AOS libraries—and why  Trig.js  is the #1 choice. 🔍  Top AOS Libraries Compared Library Performance Ease of Use File Size Best For 1. Trig.js Ultra-fast (CSS-based) Easiest setup ~4KB Advanced Control 2. AOS.js Good Easy ~6KB Basic animations 3. ScrollTrigger (GSAP) High but heavy Complex 100KB+ Advanced control 4. Sal.js Fast Simple ~3KB AOS alternative 5. WOW.js OK Easy ~7KB Animate.css users 6. Lenis Smooth Moderate Medium Smooth scrolling 7. Locomotive Scroll Smooth Moderate Large Full-page scroll effects

basic HTTP auth protect drupal cms part

file       .htaccess   AuthType Basic AuthName "restricted area" AuthUserFile C:\wamp64\www\cms\web\.htpasswd require valid-user file .htpasswd generate by online generator

call drupal api with Apache HTTP auth (basic)

  <?php // API endpoint $apiUrl = 'http://localhost/cms/web/api/articles' ; // HTTP Basic Authentication credentials $username = 'xxxx' ; $password = 'yyyyyy' ; // Initialize cURL session $ch = curl_init (); // Set cURL options curl_setopt ($ch, CURLOPT_URL , $apiUrl); curl_setopt ($ch, CURLOPT_RETURNTRANSFER , true ); curl_setopt ($ch, CURLOPT_HTTPAUTH , CURLAUTH_BASIC ); curl_setopt ($ch, CURLOPT_USERPWD , " $username : $password " ); // Execute cURL request $response = curl_exec ($ch); // Check for cURL errors if ( curl_errno ($ch)) {     http_response_code ( 500 );     echo json_encode ([ 'error' => 'cURL Error: ' . curl_error ($ch)]);     curl_close ($ch);     exit ; } // Get HTTP status code $httpCode = curl_getinfo ($ch, CURLINFO_HTTP_CODE ); // Close cURL session curl_close ($ch); // Check HTTP response code if ($httpCode !== 200 ) {     http_response_code ($httpCode);     echo...

create_attribute()

   Drupal 中的 create_attribute 是一個非常有用的 Twig 函數,主要用於在 Twig 模板中創建和操作 HTML 屬性。它讓你能夠更靈活地為 HTML 元素添加、修改或移除屬性,例如 class、id、style 等。這對於動態生成 HTML 結構非常有幫助。✨ 簡潔說明 (Simplest Explain) 📝 create_attribute 是一個 Twig 函數,用於在 Drupal 模板中建立一個可以讓你輕鬆添加或修改 HTML 屬性的物件。你可以用它來添加 classes、設定 id 或其他屬性。 詳細說明 (Detailed Explain) 📜 create_attribute 函數在 Drupal 8.3.x 版本中引入,它讓你可以在 Twig 模板中建立一個 Attribute 物件。這個物件提供了一系列方法來方便地管理 HTML 屬性,而無需直接進行字串拼接,從而減少錯誤並提高程式碼的可讀性。 主要用途和功能: 創建一個空的 Attribute 物件: 你可以直接調用  create_attribute()  來創建一個空的物件,然後再透過其方法添加屬性。 範例: twig {% set my_attribute = create_attribute() %} {# 之後可以對 my_attribute 使用 addClass(), setAttribute() 等方法 #} 創建並初始化一個 Attribute 物件: 你也可以傳入一個屬性陣列來直接創建並初始化一個  Attribute  物件。 範例: twig <div {{ create_attribute({ 'class' : [ 'region' , 'region--header' ], 'id' : 'main-region' }) }} > {{ content }} </ div > 這會渲染成: html < div class = "region region--header" id = "main-region" > {{ content }} ...