[TOC]
#### 唱片飛入效果

* [ ] 基礎效果實現
~~~
// 全屏播放器效果
<transition name="normal"></transition>
// 迷你播放器效果
<transition name="mini"></transition>
~~~
~~~
.normal-enter-active, &.normal-leave-active
transition: all 0.4s
.top, .bottom
transition: all 0.4s cubic-bezier(0.86, 0.18, 0.82, 1.32)
.normal-enter, &.normal-leave-to
opacity: 0
.top
transform: translate3d(0, -100px, 0)
.bottom
transform: translate3d(0, 100px, 0)
~~~
~~~
.mini-enter-active, &.mini-leave-active
transition: all 0.4s
.mini-enter, &.mini-leave-to
opacity: 0
~~~
* [ ] 擴展效果
~~~
<div class="player" v-show="playList.length > 0">
<!-- 全屏播放器 -->
<transition name="normal"
@enter="enter"
@after-enter="afterEnter"
@leave="leave"
@after-leave="afterLeave"
>
<div class="normal-player" v-show="fullScreen">
~~~
* [ ] 圖示

```
import { PlayerMixin } from 'utils/mixin'
import animations from 'create-keyframe-animation'
methods: {
// 動畫即將出現,設置動畫結束位置
enter (el, done) {
// 動畫即將開始,設置動畫初始坐標
const { x, y, scale } = this._getPosAndScale()
// 定義動畫
let animation = {
0: {
transform: `translate3d(${x}px,${y}px,0) scale(${scale})`
},
60: {
transform: `translate3d(0,0,0) scale(1.1)`
},
100: {
transform: `translate3d(0,0,0) scale(1)`
}
}
// 執行動畫
animations.registerAnimation({
name: 'move',
animation,
presets: {
duration: 400,
easing: 'linear'
}
})
// 執行動畫,調用done函數跳到afterEnter函數
animations.runAnimation(this.$refs.cdWrapper, 'move', done)
},
afterEnter () {
// 清除動畫
animations.unregisterAnimation('move')
this.$refs.cdWrapper.style.animation = ''
},
// 動畫結束
leave (el, done) {
this.$refs.cdWrapper.style.transition = 'all 0.4s'
const { x, y, scale } = this._getPosAndScale()
this.$refs.cdWrapper.style[transform] = `translate3d(${x}px,${y}px,0) scale(${scale})`
const timer = setTimeout(done, 400)
this.$refs.cdWrapper.addEventListener('transitionend', () => {
clearTimeout(timer)
done()
})
},
// 清除參數
afterLeave () {
this.$refs.cdWrapper.style.transition = ''
this.$refs.cdWrapper.style[transform] = ''
},
// 動畫初始位置
_getPosAndScale () {
const targetWidth = 40 // 迷你播放球寬度
const paddingLeft = 40 // 迷你播放器距離左邊偏移
const paddingBottom = 30 // 迷你播放球距離底部偏移
const paddingTop = 80 // 頂部導航寬度
const width = window.innerWidth * 0.8 // 大播放球寬度80%
const scale = targetWidth / width // 初始縮放比例
const x = -(window.innerWidth / 2 - paddingLeft) // 迷你播放器初始X坐標
// 迷你播放球初始Y坐標
const y = window.innerHeight - paddingTop - width / 2 - paddingBottom
return {
x,
y,
scale
}
}
}
```
- 起步
- 環境搭建
- mock數據
- 基礎
- 生命周期
- 過濾器
- 過渡動畫
- keyframes動畫
- 動畫JS鉤子
- 路由
- 導航守衛
- 全局守衛
- 監聽器
- 自定義組件
- 獲取焦點
- mixins
- mixins抽離vuex
- 國際化
- 動態組件
- Dom
- 擴展
- 安裝devTools
- scss
- Nuxt引用多個UI庫
- vuex
- vuex命名空間
- vuex定義
- cli
- 安裝與卸載
- 環境變量
- 雜項
- Mock數據
- FeHelper
- git
- 反向代理
- 本地存儲
- stylus
- 常用mixins
- jsonp
- 配置
- mock配置
- 跨域配置
- 自定義路徑
- px2rem
- 代理后端請求
- 常用算法
- 字母排序城市數據
- 倒計時
- 通訊錄數據結構
- 請求
- axios防止多次請求
- 封裝axios請求
- axios使用
- 封裝axios
- 插件
- BetterScroll
- 高德定位
- polyfill
- fastClick
- LazyLoad
- storageCache
- moment
- keyFrameAnimation
- vueSwiper
- 組件
- Loading組件
- header組件
- 仿有道App導航
- SupportIcon
- 仿餓了么購物車跳動
- 購物車小球緩動
- 小球飛入購物車
- 仿音樂歌手列表
- 唱片飛入效果
- 搜索組件
- 仿美團PC搜索框
- 頁面布局
- stickyFooter
- 背景色漸變
- 背景虛化
- Ui組件
- CubeUi
- CreateApi
- tab滑屏切換
- 索引列表
- BScroll
- BScroll左右聯動導航
- vant
- 函數庫
- 常用Dom函數庫
- axios封裝
- 格式化音樂播放時長
- 搜索節流
- time格式化
- JS基礎
- window對象中的高度
- JS中的寬高
- 常用正則
- nuxt
- nuxtVuex
- 監聽頁面滾動
- 監聽body滾動
- 監聽局部滾動