日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

GreenSock GSAP 3.0 最新版 所有内容创建于2020年4月4日

發布時間:2024/8/1 编程问答 63 豆豆
生活随笔 收集整理的這篇文章主要介紹了 GreenSock GSAP 3.0 最新版 所有内容创建于2020年4月4日 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 【1】 tween
    • 【1.1】vars速查表
    • 【1.2】基于函數的動態動畫
    • 【1.3】stagger
    • 【1.4】Sequencing 序列化
    • 【1.5】keyframes 關鍵幀
  • 【3】 timeline
  • 【ease速查表】

【1】 tween

gsap有三個常用的方法來創建一個Tweens對象,Tweens之間是并發的,如無特殊約束則同時觸發:

  • gsap.to(targets, vars={}),to表示從一個HTML元素應有的的默認狀態到目標狀態。
  • gsap.from(targets, vars={}),from表示從目標狀態到一個HTML元素應有的的默認狀態。
  • gsap.fromTo(targets, vars={}),我也沒用過。

第一個參數是一個選擇器,等價于querySelector(targets),這意味著你選擇的可能是一個HTML元素,也有可能是一組。

【1.1】vars速查表

屬性描述
callbackScopeThe scope to be used for all of the callbacks (onStart, onUpdate, onComplete, etc.).
dataAssign arbitrary data to this property (a string, a reference to an object, whatever) and it gets attached to the tween instance itself so that you can reference it later like yourTween.data.
delayAmount of delay before the animation should begin (in seconds).
durationThe duration of the animation (in seconds). Default: 0.5.
easeControls the rate of change during the animation, giving it a specific feel. For example, “elastic” or “strong.inOut”. See the Ease Visualizer for a list of all of the options. ease can be a String (most common) or a function that accepts a progress value between 0 and 1 and returns a converted, similarly normalized value. Default: “power1.out”.
idAllows you to (optionally) assign a unique identifier to your tween instance so that you can find it later with gsap.getById() and it will show up in GSDevTools with that id.
immediateRenderNormally a tween waits to render for the first time until the very next tick (update cycle) unless you specify a delay. Set immediateRender: true to force it to render immediately upon instantiation. Default: false for to() tweens, true for from() and fromTo() tweens.
inheritNormally tweens inherit from their parent timeline’s defaults object (if one is defined), but you can disable this on a per-tween basis by setting inherit: false.
lazyWhen a tween renders for the very first time and reads its starting values, GSAP will try to delay writing of values until the very end of the current “tick” which can improve performance because it avoids the read/write/read/write layout thrashing that browsers dislike. To disable lazy rendering for a particular tween, set lazy: false. In most cases, there’s no need to set lazy. To learn more, watch this video. Default: true (except for zero-duration tweens).
onCompleteA function to call when the animation has completed.
onCompleteParamsAn Array of parameters to pass the onComplete function. For example, gsap.to(".class", {x:100, onComplete:myFunction, onCompleteParams:[“param1”, “param2”]});.
onInterruptA function to call when the animation is interrupted, meaning if/when the tween is killed before it completes. This could happen because its kill() method is called or due to overwriting.
onInterruptParamsAn Array of parameters to pass the onInterrupt function. For example, gsap.to(".class", {x:100, onInterrupt:myFunction, onInterruptParams:[“param1”, “param2”]});.
onRepeatA function to call each time the animation enters a new iteration cycle (repeats). Obviously this only occurs if you set a non-zero repeat.
onRepeatParamsAn Array of parameters to pass the onRepeat function.
onReverseCompleteA function to call when the animation has reached its beginning again from the reverse direction (excluding repeats).
onReverseCompleteParamsAn Array of parameters to pass the onReverseComplete function.
onStartA function to call when the animation begins (when its time changes from 0 to some other value which can happen more than once if the tween is restarted multiple times).
onStartParamsAn Array of parameters to pass the onStart function.
onUpdateA function to call every time the animation updates (on each “tick” that moves its playhead).
onUpdateParamsAn Array of parameters to pass the onUpdate function.
overwriteIf true, all tweens of the same targets will be killed immediately regardless of what properties they affect. If “auto”, when the tween renders for the first time it hunt down any conflicts in active animations (animating the same properties of the same targets) and kill only those parts of the other tweens. Non-conflicting parts remain intact. If false, no overwriting strategies will be employed. Default: false.
pausedIf true, the animation will pause itself immediately upon creation. Default: false.
repeatHow many times the animation should repeat. So repeat: 1 would play a total of two iterations. Default: 0.
repeatDelayAmount of time to wait between repeats (in seconds). Default: 0.
repeatRefreshSetting repeatRefresh: true causes a repeating tween to invalidate() and re-record its starting/ending values internally on each full iteration (not including yoyo’s). This is useful when you use dynamic values (relative, random, or function-based). For example, x: “random(-100, 100)” would get a new random x value on each repeat. duration, delay, and stagger do NOT refresh.
reversedIf true, the animation will start out with its playhead reversed, meaning it will be oriented to move toward its start. Since the playhead begins at a time of 0 anyway, a reversed tween will appear paused initially because its playhead cannot move backward past the start.
runBackwardsIf true, the animation will invert its starting and ending values (this is what a from() tween does internally), though the ease doesn’t get flipped. In other words, you can make a to() tween into a from() by setting runBackwards: true.
staggerIf multiple targets are defined, you can easily stagger the start times for each by setting a value like stagger: 0.1 (for 0.1 seconds between each start time). Or you can get much more advanced staggers by using a stagger object. For more information, see the stagger documentation.
startAtDefines starting values for any properties (even if they’re not animating). For example, startAt: {x: -100, opacity: 0}
yoyoIf true, every other repeat iteration will run in the opposite direction so that the tween appears to go back and forth. This has no affect on the reversed property though. So if repeat is 2 and yoyo is false, it will look like: start - 1 - 2 - 3 - 1 - 2 - 3 - 1 - 2 - 3 - end. But if yoyo is true, it will look like: start - 1 - 2 - 3 - 3 - 2 - 1 - 1 - 2 - 3 - end. Default: false.
yoyoEaseAllows you to alter the ease in the tween’s yoyo phase. Set it to a specific ease like “power2.in” or set it to true to simply invert the tween’s normal ease. Note: GSAP is smart enough to automatically set yoyo: true if you define any yoyoEase, so there’s less code for you to write. Default: false.
keyframesTo animate the targets to various states, use keyframes - an array of vars objects that serve as to() tweens. For example, keyframes: [{x:100, duration:1}, {y:100, duration:0.5}]. All keyframes will be perfectly sequenced back-to-back, but you can define a delay value to add spacing between each step (or a negative delay would create an overlap).

【1.2】基于函數的動態動畫

通過對任意的屬性使用函數來獲得不可思議的動態動畫,我們之前提到,創建tween時使用的css選擇器有可能選擇多個HTML元素,因此,如果我們想為每一個HTML元素應用不同的、有規律變化的動畫就可以使用基于函數的動態動畫。

gsap.to(".class", {x: 100, // 靜態值y: function(index, target, targets) { //function-based valueindex從0到targets.length - 1每一個target都是當前處理的HTML元素return index * 50; },duration: 1 });

【1.3】stagger

這也是一個很常用的屬性,如果你給一組HTML元素應用動畫時,希望他們之間有一個延遲,可以用stagger屬性。

【1.4】Sequencing 序列化

序列化是指,讓某些動畫按順序依次執行,除了使用delay以外,我們十分推薦你使用后面會講到的timeline。

【1.5】keyframes 關鍵幀

如果你打算讓同一個HTML對象依次執行多個動畫的話,使用關鍵幀是一個不錯的選擇。

gsap.to(".class", {keyframes: [{x: 100, duration: 1},{y: 200, duration: 1, delay: 0.5}, //create a 0.5 second gap{rotation: 360, duration: 2} //overlap by 0.25 seconds ], ease: "none"});

上面的代碼會讓.class先執行右平移,延遲0.5s后執行下平移,最后執行旋轉360度,注意,當上一個動作執行完后才會執行下一個,當然你也可以用timeline實現。

【3】 timeline

timeline是tweens的容器,它可以按照添加順序依次執行每一個tweens,這樣我們就可以不用考慮執行順序,交給timeline來處理。

let tl = gsap.timeline(); //create the timeline tl.to(".class1", {x: 100}) //start sequencing.to(".class2", {y: 100, ease: "elastic"}).to(".class3", {rotation: 180});

【ease速查表】

對于下表的所有動畫函數的名稱name都有擴展的,name.in,和name.inout。

名稱描述
none線性
power1形如log函數
power2形如更凸的log函數
power3形如更更凸的log函數
power4形如更更更凸的log函數
back有一個超出目標位置再回來的動作
elastic在目標位置左右搖擺后停下
bounce彈跳
rough亂搖
slow形如中心對稱的sigmoid函數
steps階梯式
circ形如第二象限的圓弧
expo夸張版的circ
sine收斂版的power1
Custom自定義

總結

以上是生活随笔為你收集整理的GreenSock GSAP 3.0 最新版 所有内容创建于2020年4月4日的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产av无码专区亚洲av毛片搜 | 色妇网| 无限资源日本好片 | 亚色图| 男男做爰猛烈啪啪高 | 婷婷视频一区二区三区 | 茄子视频A| 日本一区二区三区久久 | 最全aⅴ番号库网 | 女人叫床很黄很污句子 | 日本一区精品视频 | 六月激情 | 青青草原综合网 | 夜夜躁很很躁日日躁麻豆 | 93看片淫黄大片一级 | 国模无码视频一区 | 欧美黄色片免费看 | 欧美日韩高清不卡 | 欧美日韩一区三区 | 青青草精品在线视频 | 国产黄色免费看 | 成人午夜福利一区二区 | 中文字幕校园春色 | 激情欧美一区 | 女人脱下裤子让男人捅 | 久久不射影院 | 懂色中文一区二区在线播放 | 亚洲黄页 | 性开放网站 | 日韩激情视频网站 | 色婷婷在线观看视频 | 久久久成人精品一区二区三区 | 欧美在线激情 | 久久字幕| 丰满人妻综合一区二区三区 | 国产人妻一区二区三区四区五区六 | 国产一区二区在线视频 | 午夜两性网 | 久久精品国产99 | www.爱爱| 国产美女精品一区二区三区 | 欧美比基尼 | 麻豆黄色片 | 欧美亚洲丝袜 | 99久免费精品视频在线观78 | 欧美一区二区三区爽爽爽 | 欧美黑人三级 | 国产亚洲av在线 | 30一40一50老女人毛片 | 公侵犯人妻中文字慕一区二区 | 91手机视频在线观看 | 狠狠操在线视频 | 在线高清观看免费 | 日韩国产激情 | 久久夜精 | 亚洲成人免费在线观看 | 亚洲国产欧美另类 | yjizz国产 | 日韩av在线看免费观看 | 超碰免费公开在线 | 在线观看国产成人 | 国产极品粉嫩 | 色久天堂 | 国产男女猛烈无遮挡免费观看网站 | 免费网站在线高清观看 | 日韩精品无码一区二区三区久久久 | 日韩色视频在线观看 | 久久免费看少妇高潮v片特黄 | 人人草在线 | 综合伊人久久 | 日韩精品国产一区 | 无码人妻av免费一区二区三区 | 成人天堂av| 麻豆精品视频在线观看 | 久久7777 | 男女乱淫 | 中国免费黄色 | 肉丝美脚视频一区二区 | 午夜影视体验区 | 射射射综合网 | 国产又粗又黄又爽又硬 | 成人在线观看网址 | 午夜免费成人 | 亚洲无限av| 男女做那个的全过程 | 国产精品一区二三区 | a色网站| 国模私拍一区二区三区 | аⅴ资源新版在线天堂 | 影院色原网站 | av在线色 | 四虎影视黄色 | 日韩一区二区在线观看 | 特黄三级又爽又粗又大 | 日韩精品免费一区二区在线观看 | 久久久久久久国产 | 免费看黄色大片 | 亚洲午夜视频在线观看 | 国产高潮流白浆喷水视频 |