Warning: Undefined array key "language" in /volume1/web/blog_view.php on line 69 Warning: Undefined array key "lan_code" in /volume1/web/blog_view.php on line 71 Warning: Undefined array key "lan" in /volume1/web/blog_view.php on line 72 Warning: Undefined array key "lan" in /volume1/web/blog_view.php on line 74 Warning: Trying to access array offset on value of type null in /volume1/web/blog_view.php on line 74 Warning: Undefined array key "lan" in /volume1/web/blog_view.php on line 74 Warning: Trying to access array offset on value of type null in /volume1/web/blog_view.php on line 74 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 72 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 79 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 75 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 74 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 73 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 72 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 82 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 81 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 80 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 78 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 77 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 76 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 75 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 82 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 80 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 77 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 74 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 72 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 71 Warning: Trying to access array offset on value of type null in /volume1/web/blog_tree.php on line 80 Warning: Trying to access array offset on value of type null in /volume1/web/put_products.php on line 30 Warning: Attempt to read property "plaintext" on array in /volume1/web/put_products.php on line 33 Warning: Trying to access array offset on value of type null in /volume1/web/put_products.php on line 37 Warning: Trying to access array offset on value of type null in /volume1/web/put_products.php on line 30 Warning: Attempt to read property "plaintext" on array in /volume1/web/put_products.php on line 33 Warning: Trying to access array offset on value of type null in /volume1/web/put_products.php on line 37 Warning: Undefined array key "lan" in /volume1/web/blog_view.php on line 125 Warning: Trying to access array offset on value of type null in /volume1/web/blog_view.php on line 125 Warning: Undefined array key "lan" in /volume1/web/blog_view.php on line 126 Warning: Trying to access array offset on value of type null in /volume1/web/blog_view.php on line 126
要學就學最強的~
SlimWeb 本身已經有載入 GSAP 的相關檔案,所以不管在區塊、頁面、或是部落格文章,你都可以輕鬆地寫出想要的動畫效果,網路上有許多 GSAP 的教學,但有些地方對初學者不太友善,如果找到的教學比較偏向某種特定效果的話,可能會看得霧煞煞,簡單來講先掌握 GSAP 的三種基本方法,你就可以做出不錯的動畫~
首先在建立新的部落格或是頁面,進入原始碼後,按下方的 +JS 按鈕,為這個頁面建立一個JS文件(不用打副檔名)

jQuery(document).ready(function($) { //元素載入後做什麼事寫在這裡~ });
<img id="spider1" class="spider" src="/images/spman.png" alt="蜘蛛人">
希望目標從目前位置移動到何處
jQuery(document).ready(function($) { gsap.to('#spider1', { x: '100%', //沿著x軸往右移動 opacity: 0, //到達移動地點後,透明度為 0 duration: 2, //移動時間為 2 秒 repeat: -1 //一直重複這段動畫 }) });
希望目標從什麼位置回到目前的位置
jQuery(document).ready(function($) { gsap.from('#spider1', { x: '-100%', //沿著x軸往右移動 opacity: 0, //到達移動地點後,透明度為 0 duration: 2, //移動時間為 2 秒 repeat: -1 //一直重複這段動畫 }) });
目前狀態不適合 to 或是 from 時,就使用 fromTo
jQuery(document).ready(function($) { gsap.fromTo('#spider1', { x: '-100%', //第一種狀態在左邊的位置 opacity: 0 //第一種狀態的透明度 },{ x: '100%', //沿著x軸往右移動 opacity: 1, //到達移動地點後,透明度為 1 duration: 4, //移動時間為 4 秒 repeat: -1 //一直重複這段動畫 }) });
讓一直重複的動畫產生倒放的滑順效果
jQuery(document).ready(function($) { gsap.fromTo('#spider1', { x: '-100%', //第一種狀態在左邊的位置 opacity: 0 //第一種狀態的透明度 },{ x: '100%', //沿著x軸往右移動 opacity: 1, //到達移動地點後,透明度為 1 duration: 4, //移動時間為 2 秒 repeat: -1, //一直重複這段動畫 yoyo: true //產生絲滑的倒放效果 }) });
讓你的動畫看起來生動自然,展現GSAP的強悍
gsap.fromTo('#spider1', { x: '-100%', //第一種狀態在左邊的位置 opacity: 0, //第一種狀態的透明度 rotate: -45, //第一種狀態呈現-45度 }, { x: '100%', //沿著x軸往右移動 opacity: 1, //到達移動地點後,透明度為 1 duration: 4, //移動時間為 2 秒 repeat: -1, //一直重複這段動畫 ease: 'bounce.out', //彈跳效果 rotate: 45, //第二種狀態轉45度 yoyo: true //產生絲滑的倒放效果 })
jQuery(document).ready(function($) { play_animation(); }); function play_animate(){ gsap.fromTo('#spider1', { x: '-100%', //第一種狀態在左邊的位置 rotate: -45,//第一種狀態我左旋轉45度 opacity: 0 //第一種狀態的透明度 }, { x: '100%', //沿著x軸往右移動 opacity: 1, //到達移動地點後,透明度為 1 rotate: 45,//往右旋轉45度 duration: 4, //移動時間為 2 秒 repeat: -1, //一直重複這段動畫 ease: 'bounce.out', //彈跳效果 yoyo: true }) }
function play_animate(){ let body = $('body'); //建立一個變數並指向目前HTML的body元素 //檢查是否在編輯模式下 if ($('#tine').length > 0) { body = tinymce.activeEditor.getBody(); //在編輯模式下,將 body 變數指向編輯器內的 body } let spider1 = $('#spider1, body); //定義一個變數 spider 並指向 body 內的 #spider1 gsap.fromTo(spider1, { //將變數放入gsap x: '-100%', //第一種狀態在左邊的位置 rotate: -45,//第一種狀態我左旋轉45度 opacity: 0 //第一種狀態的透明度 }, { x: '100%', //沿著x軸往右移動 opacity: 1, //到達移動地點後,透明度為 1 rotate: 45,//往右旋轉45度 duration: 4, //移動時間為 2 秒 repeat: -1, //一直重複這段動畫 ease: 'bounce.out', //彈跳效果 yoyo: true }) }

.spider { will-change: opacity, left; }
一個在五濁亂世中
不願靠話術生存的工程師
More Related...
TinyMCE/AI 編輯器介紹ChatGPT的資料庫應用由 SlimWeb 打造的創業春天為什麼不用WordPress來架設網站?