成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

年終活動(dòng)h5動(dòng)畫總結(jié)

betacat / 3334人閱讀

摘要:年終活動(dòng)動(dòng)畫總結(jié)戳這里采用的插件,即可滿足大多數(shù),手機(jī)的兼容性問題。人移動(dòng)切換,添加類控制移動(dòng)和暫停,以及切換背景人物。監(jiān)聽動(dòng)畫結(jié)束時(shí)機(jī)橋的出現(xiàn)配合屬性實(shí)現(xiàn)。不添加會(huì)影響自身頁數(shù)的判斷動(dòng)畫總結(jié)別人寫的真牛自己只會(huì)。

年終活動(dòng)h5動(dòng)畫總結(jié)

戳這里----♂--github--

css3 + react-id-swiper + react + redux + saga  
采用postcss的Autoprefixer插件,即可滿足大多數(shù)oppo,vivo手機(jī)的兼容性問題。

1. 動(dòng)畫相關(guān)主要內(nèi)容:

流星

閃爍星星

字的晃動(dòng)

人的移動(dòng)(動(dòng)畫 + 監(jiān)聽動(dòng)畫結(jié)束時(shí)間)

橋的鋪墊

開啟旅程按鈕縮放

旋轉(zhuǎn)(+ 兼容)

react-id-swiper

swiper配合css3實(shí)現(xiàn)切換

2. css3動(dòng)畫語法

animation

animation-name
animation-duration
animation-timing-function  速度曲線
animation-delay
animation-iteration-count
animation-direction
play-state    
fill-mode  

transform

transform 屬性向元素應(yīng)用 2D 或 3D 轉(zhuǎn)換。該屬性允許我們對(duì)元素進(jìn)行旋轉(zhuǎn)、縮放、移動(dòng)或傾斜。
其中 transform-origin (屬性改變被轉(zhuǎn)換元素的中心)。

transition

三者區(qū)別:  animation  動(dòng)畫,關(guān)鍵幀,往復(fù)性。  transition  過渡, 屬性,觸發(fā)動(dòng)作,一過性。  transform 變換, 復(fù)雜的變換參數(shù)。
3. 示例 https://github.com/hytStart/R...

流星

改變位置translate3d,透明度opacity和大小scale。  
流星尾巴采用偽元素元素:after旋轉(zhuǎn)-45deg(旋轉(zhuǎn)基點(diǎn)為左transform-origin: left;);采用border可以實(shí)現(xiàn),靠近頭部越亮,靠近尾部越暗。

.star {
    display: block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #FFF;
    top: 10px;
    left: 200px;
    position: relative;
    animation: star-ani 6s infinite ease-out;
    box-shadow: 0 0 5px 5px rgba(255, 255, 255, .3);
    opacity: 1;
}
.star:after {
    content: "";
    display: block;
    top: 0px;
    left: 40%;
    border: 0px solid #fff;
    border-width: 0px 90px 2px 90px;
    border-color: transparent transparent transparent rgba(255, 255, 255, .3);
    transform: rotate(-45deg) translate3d(1px, 3px, 0);
    box-shadow: 0 0 1px 0 rgba(255, 255, 255, .1);
    transform-origin: left;
}

@keyframes star-ani {
    0% {
        opacity: 0;
        transform: scale(0) rotate(0) translate3d(0, 0, 0);
    }
    50% {
        opacity: 1;
        transform: scale(1) rotate(0) translate3d(-100px, 100px, 0);
    }
    100% {
        opacity: 0;
        transform: scale(1) rotate(0) translate3d(-200px, 200px, 0);
    }
}

閃爍星星

改變透明度

.shine {
    background: url("../../../../images/action/icon-star1.png") no-repeat center;
    background-size: 100%;
    width: 30px;
    height: 40px;
    position: absolute;
    top: 90px;
    left: 100px;
    opacity: 0;
    animation: opacity-change 0.5s ease-in-out infinite;
}

@keyframes opacity-change {
    0% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

分為兩段動(dòng)畫,下降和上升。translateY改變即可。

.text-item-0 {
    position: absolute;
    width: 25px;
    height: 75px;
    top: 60px;
    left: 100px;
    background: url("../../../../images/action/S-start.png") no-repeat center;
    background-size: 100%;
    animation: letter-0 1.5s ease-in-out both, letter-0-1 2.0s ease-in-out 1.5s both;
}

@keyframes letter-0 {
    0% {
        transform: translateY(0)
    }
    50% {
        transform: translateY(80px)
    }
    100% {
        transform: translateY(0px)
    }
}
@keyframes letter-0-1 {
    0% {
        opacity: 1;
    }
    100% {
        top: -80px;
        opacity: 0;
    }
}

人移動(dòng)

切換dom,添加類控制移動(dòng)和暫停,以及切換背景人物。監(jiān)聽animationend事件。

jsx
{
    peopleMove ?
        
{ this.start2 = start2 }} /> :
} css .people { width: 20px; height: 64px; position: absolute; left: 10px; top: 130px; background: url("../../../../images/action/people.png") no-repeat center; background-size: 100%; opacity: 0; animation: peopleUp 1s ease-in-out 0.5s both; } .people_move { background: url("../../../../images/action/people_moveleft.gif"); background-size: 100% 100%; background-position: center; background-repeat: no-repeat; width: 20px; height: 64px; position: absolute; left: 10px; top: 130px; opacity: 1; animation: PeopleMove 1.5s linear 0s both; } .people_paused { width: 20px; height: 64px; background: url("../../../../images/action/people.png"); background-size: 100% 100%; background-position: center; background-repeat: no-repeat; animation-play-state: paused; } @keyframes peopleUp { 0% { opacity: 0; } 100% { opacity: 1; } } @keyframes PeopleMove { 0% { left: 10px; top: 130px; } 100% { top: 20px; left: 180px; background-size: 100% 100%; background-position: center; background-repeat: no-repeat; } } // 監(jiān)聽動(dòng)畫結(jié)束時(shí)機(jī) componentDidUpdate() { const { peopleMove } = this.state if (peopleMove) { this.start2.addEventListener("animationend", this.end) this.start2.addEventListener("webkitAnimationEnd", this.end) this.start2.addEventListener("mozAnimationEnd", this.end) this.start2.addEventListener("oAnimationEnd", this.end) } }

橋的出現(xiàn)

配合background-size: cover;屬性實(shí)現(xiàn)。

.brige {
    width: 0px;
    background: url("../../../../images/action/bridge.png");
    background-size: cover;
    background-repeat: no-repeat;
    height: 100px;
    position: absolute;
    top: 40px;
    left: 30px;
    animation: BridgeFadeIn 3s linear both;
    opacity: 0;
}

@keyframes BridgeFadeIn {
    0% {
        width: 0px;
        opacity: 0;
    }
    100% {
        width: 200px;
        opacity: 1;
    }
}

漸變大(開始旅程)

利用transform scale2D 縮放轉(zhuǎn)換。

.icon-ciecle {
    display: block;
    position: absolute;
    left: 100px;
    top: 80px;
    width: 30px;
    height: 30px;
    background: url("../../../../images/action/icon-light.png") no-repeat center;
    background-size: 100%; 
    animation: warn 1.2s ease-in-out 0s infinite both;
}

@keyframes warn {
    0% {
        transform: scale(0.1);
        opacity: 0.0;
    }
    25% {
        transform: scale(0.2);
        opacity: 0.3;
    }
    50% {
        transform: scale(0.4);
        opacity: 0.5;
    }
    75% {
        transform: scale(0.6);
        opacity: 0.7;
    }
    100% {
        transform: scale(0.8);
        opacity: 0.0;
    }
}

旋轉(zhuǎn)

ios的animation-play-state: paused;不起作用,且animation動(dòng)畫不可寫在新增類里,必須寫在一個(gè)類里。(測(cè)試中發(fā)現(xiàn),這里有疑問。)

.music_img {
    width: 40px;
    height: 40px;
    display: block;
    position: absolute;
    left: 100px;
    top: 80px;
    animation: rotating 3s linear infinite;
    animation-play-state: running;
}
.rotate-pause {
    animation-play-state: paused;
}

@keyframes rotating {
    0% {
        transform: rotate(0deg);
     }
    100% { 
    transform: rotate(360deg);
     }
}

react-id-swiper

Swiper的react版本,基本api都支持,具實(shí)驗(yàn)?zāi)繙y(cè)相當(dāng)于Swiper v4。

不一定通過api。也可以通過重寫css實(shí)現(xiàn)。

重寫css切換效果的話,會(huì)影響它本身的動(dòng)畫效果,所以可通過添加不可滑動(dòng)來控制。

1. 
.swiper-wrapper {
    transition-delay: 1.6s;
}
2. 
noSwiping: true,
noSwipingClass: "stop-swiping",

Swiper實(shí)現(xiàn)的迷宮切換

1.swiper的effect屬性與控制背景圖片的opacity,利用時(shí)間差實(shí)現(xiàn)最終效果。包括迷宮的切換,背包男的出現(xiàn)與消失,彈窗的出現(xiàn)與消失。  
2.swiper屬性的activeIndex,可以得到滑動(dòng)到第幾頁,通過改變dom或者改變類,控制第幾頁動(dòng)畫的發(fā)生。

// 根據(jù)activeIndex拿到的頁數(shù),控制該頁數(shù)state的改變,通過切換dom和添加類的方式,達(dá)到進(jìn)場(chǎng)與退場(chǎng)的動(dòng)畫效果。
// 添加類stop-swiping控制不可滑動(dòng),動(dòng)畫完成后,才可繼續(xù)滑動(dòng)下一頁。
const mazeStyle = classNames({
    [styles["maze-1"]]: true,
    [styles["maze-out"]]: firstMazeOut,
})
const peopleStyle = classNames({
    [styles["people-1"]]: true,
    [styles["people-out"]]: firstMazeOut,
})
const popCardStyle = classNames({
    [styles["pop-card-container"]]: true,
    [styles["pop-card-out"]]: firstMazeOut,
})
{
    firstMazeIn ?
        
:
// 不添加會(huì)影響swiper自身頁數(shù)的判斷 }
4. 動(dòng)畫總結(jié)
別人寫的真牛X,自己只會(huì)opacity,translate
5. 待完善

html2canvas

資源加載

jsbridge使用與注意事項(xiàng)

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/103356.html

相關(guān)文章

  • 年終活動(dòng)h5動(dòng)畫總結(jié)

    摘要:年終活動(dòng)動(dòng)畫總結(jié)戳這里采用的插件,即可滿足大多數(shù),手機(jī)的兼容性問題。人移動(dòng)切換,添加類控制移動(dòng)和暫停,以及切換背景人物。監(jiān)聽動(dòng)畫結(jié)束時(shí)機(jī)橋的出現(xiàn)配合屬性實(shí)現(xiàn)。不添加會(huì)影響自身頁數(shù)的判斷動(dòng)畫總結(jié)別人寫的真牛自己只會(huì)。 年終活動(dòng)h5動(dòng)畫總結(jié) 戳這里----♂--github-- css3 + react-id-swiper + react + redux + saga 采用postcss...

    darry 評(píng)論0 收藏0
  • 2016年終工作總結(jié)

    摘要:由于初版需求及開發(fā)工作都沒有參與,在接手項(xiàng)目后過了遍前端結(jié)構(gòu)發(fā)現(xiàn)所有交互及組件都是現(xiàn)擼,并未使用市面上已有的優(yōu)秀前端框架從我個(gè)人角度理解上出發(fā),后續(xù)需求變更中當(dāng)需要實(shí)現(xiàn)某些常用組件樣式或交互時(shí),基本上都需要現(xiàn)擼或者尋找合適的組件。 2016悄無聲息的過去了,再過不久便是農(nóng)歷新年 這幾天相對(duì)清閑梳理了一下去年所做的工作,希望在新的一年能發(fā)展的更好 今年一共研發(fā)或升級(jí)了五款產(chǎn)品:合伙人、奪...

    hoohack 評(píng)論0 收藏0
  • 記一次游戲H5開發(fā)經(jīng)驗(yàn)

    摘要:為了實(shí)現(xiàn)物體隨機(jī)出現(xiàn)的效果,讓每個(gè)物體隨機(jī)多少秒后開始出現(xiàn)最后一個(gè)物體出現(xiàn)完,多少秒后出現(xiàn)結(jié)束畫面等等,需要理清楚各個(gè)定時(shí)器的關(guān)系,并對(duì)其添加語義化良好的標(biāo)記,及時(shí)對(duì)未完結(jié)的定時(shí)器進(jìn)行清除,防止定時(shí)器帶來的意想不到的問題。 快到年終的時(shí)候做了一個(gè)以游戲形式展示的h5活動(dòng)頁,第一次嘗試使用js寫小游戲,很有趣的過程,很寶貴的經(jīng)驗(yàn)。 效果圖 直接上個(gè)效果的gif圖,游戲的一小部分效果,錄出...

    xingpingz 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<