




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
第vue實(shí)現(xiàn)旋轉(zhuǎn)木馬動(dòng)畫本文實(shí)例為大家分享了vue實(shí)現(xiàn)旋轉(zhuǎn)木馬動(dòng)畫的具體代碼,供大家參考,具體內(nèi)容如下
圖片數(shù)量可為任意值都能正常處理[1-無(wú)限個(gè)]:
!DOCTYPEhtml
html
head
title/title
metacharset="UTF-8"
metahttp-equiv="Access-Control-Allow-Origin"content="*"
scriptsrc="/npm/vue/dist/vue.js"/script
style
html,body{
font-size:100px;
html,body{
width:100%;
height:100%;
overflow:hidden;
.film-box{
width:100%;
height:100%;
position:relative;
width:100%;
list-style:none;
ulli{
position:absolute;
top:0;
left:0;
z-index:1;
width:0rem;
height:0rem;
text-align:center;
ulli.film-show{
transition:all1s;
width:87rem;
height:50rem;
ulliimg{
/*width:100%;*/
height:100%;
/*左右箭頭*/
.arrow{
position:absolute;
width:100%;
top:50%;
/*opacity:0;*/
z-index:3;
.prev,.next{
position:absolute;
height:5rem;
width:3rem;
border-radius:50%;
top:50%;
margin-top:-56px;
overflow:hidden;
text-decoration:none;
.prev{
left:0;
background:url("./imgs/arrow-left.png")no-repeatlefttop;
background-size:100%100%;
.next{
right:0;
background:url("./imgs/arrow-right.png")no-repeatrighttop;
background-size:100%100%;
.filmindex{
color:#cb2e2e;
font-size:2.4rem;
position:absolute;
bottom:12rem;
left:50%;
transform:translateX(-50%);
/style
/head
body
divid='app'
ulid="slide"
liv-for='(item,index)infilms'
:key='index'
v-bind:class="item.show'film-show':''"
v-bind:
v-bind:data-index='index'
imgv-bind:src="item.image"alt=""
/li
/ul
span{{filmCurrIndex+1+'/'+films.length}}/span
divid="arrow"
ahref="javascript:;"id="arrPrev"@click='last'/a
ahref="javascript:;"id="arrNext"@click='next'/a
/div
/div
/body
script
varvm=newVue({
el:'#app',
data:{
films:[],
filmsHideLeft:'0rem',//控制隱藏圖片是從左上角跳出來(lái)還是從右上角跳出來(lái)
configStart:0,
filmCurrIndex:2,
config:[
"transform":"scale(0.6)",
"top":'5rem',
"left":'-13rem',
"zIndex":2,
"backgroundColor":"#98E0AD"
},//0
"transform":"scale(0.8)",
"top":'3rem',
"left":'13rem',
"zIndex":3,
"backgroundColor":"#BAD1F0"
},//1
"transform":"scale(1)",
"top":'2rem',
"left":'45rem',
"zIndex":4,
"backgroundColor":"#F3DFDE"
},//2
"transform":"scale(0.8)",
"top":'3rem',
"left":'93rem',
"zIndex":3,
"backgroundColor":"#BAD1F0"
},//3
"transform":"scale(0.6)",
"top":'5rem',
"left":'113rem',
"zIndex":2,
"backgroundColor":"#98E0AD"
},//4
lessNum:0,
methods:{
next(){
if(this.lessNum5){
this.nextFilmLessFive();
}else{
this.nextFilm();
last(){
if(this.lessNum5){
this.lastFilmLessFive();
}else{
this.lastFilm();
nextFilm(){
letself=this;
this.filmsHideLeft='185rem';
letcurrShowFirst=parseInt(document.querySelectorAll('.film-show')[0].dataset.index);
//最后一個(gè)位于正中央時(shí)按下一個(gè)不再反應(yīng)
console.log(currShowFirst,self.films.length)
if(currShowFirst+3==self.films.length){
return;
//改變DOM的顯示與隱藏
if(self.configStart==0){
self.films[currShowFirst].show=false;
if(currShowFirst+5=this.films.length-1){//正中央顯示的是倒數(shù)第二張或倒數(shù)第一張時(shí),按下一個(gè)不需要設(shè)置哪張顯示成true
self.films[currShowFirst+5].show=true;
}elseif(self.configStart==1){
self.films[4].show=true;
self.configStart=0;
}elseif(self.configStart==2){
self.films[3].show=true;
self.configStart=1;
console.log(self.films)
self.$nextTick(function(){
//改變DOM的left,top,scale,zIndex,backgroundColor
this.filmCurrIndex=(this.filmCurrIndex+1=this.films.length-1this.films.length-1:this.filmCurrIndex+1);
self.assign();
lastFilm(){
letself=this;
this.filmsHideLeft='0rem';
letcurrShowFirst=parseInt(document.querySelectorAll('.film-show')[0].dataset.index);
if(currShowFirst!==0){
self.films[currShowFirst-1].show=true;
if(currShowFirst+4=this.films.length-1){//正中央顯示的是倒數(shù)第二張或倒數(shù)第一張時(shí),按上一個(gè)不需要設(shè)置哪張顯示成false
self.films[currShowFirst+4].show=false;
}else{
if(self.configStart==0){
self.configStart=1;
self.films[4].show=false;
}elseif(self.configStart==1){
self.configStart=2;
self.films[3].show=false;
}else{
//第一個(gè)位于正中央時(shí)按上一個(gè)不再反應(yīng)
return;
console.log(self.films)
self.$nextTick(function(){
this.filmCurrIndex=(this.filmCurrIndex-1)00:(this.filmCurrIndex-1);
self.assign();
lastFilmLessFive(){
letcurrShowFirst=parseInt(document.querySelectorAll('.film-show')[0].dataset.index);
if(this.lessNum===4){
if(!this.films[0].show){
this.films[0].show=true;
}else{
if(this.configStart===2)return;
if(this.configStart===0){
this.configStart=1;
}elseif(this.configStart===1){
this.configStart=2;
this.films[3].show=false
}elseif(this.lessNum===3){
if(this.configStart===1){
this.configStart=2;
}elseif(this.configStart===0){
this.configStart=1;
}elseif(this.lessNum===2){
if(this.configStart===1){
this.configStart=2;
this.$nextTick(function(){
this.filmCurrIndex=(this.filmCurrIndex-1)00:(this.filmCurrIndex-1);
this.assign();
nextFilmLessFive(){
letcurrShowFirst=parseInt(document.querySelectorAll('.film-show')[0].dataset.index);
if(this.lessNum===4){
if(!this.films[0].show)return;
if(this.configStart===2){
this.configStart=1;
this.films[3].show=true;
}elseif(this.configStart===1){
this.configStart=0;
}else{
this.films[0].show=false;
}elseif(this.lessNum===3){
if(this.configStart===1){
this.configStart=0;
}elseif(this.configStart===2){
this.configStart=1;
}elseif(this.lessNum===2){
if(this.configStart===2){
this.configStart=1;
this.$nextTick(function(){
console.log(this.filmCurrIndex,this.films.length)
this.filmCurrIndex=(this.filmCurrIndex+1=this.films.length-1this.films.length-1:this.filmCurrIndex+1);
this.assign();
assign(){
letself=this;
varlist=document.getElementById("slide").getElementsByClassName("film-show");//拿到所有l(wèi)i
for(vari=0;ilist.length;i++){
letjson=self.config[i+this.configStart];
for(varattrinjson){
list[i].style[attr]=json[attr];
mounted(){
this.films=this.films.concat([
{image:'./imgs/9.jpeg',show:true},
{image:'./imgs/1.jpg',show:true},
{image:'./imgs/2.jpg',show:true},
{image:'./imgs/3.jpg',show:true},
{image:'./imgs/4.jpg',show:true},
//{image:'./imgs/5.jpg',show:false},
//{image:'./imgs/6.jpg',show:false},
//{image:'./imgs/7.jpg',show:false},
//{image:'./imgs/8.jpg',show:false},
this.$nextTick(function(){
this.lessNum=this.films.length;
if(this.lessNum===3){
this.configStart=1;
this.filmCurrIndex=1;
if(this.lessNum===2){
this.configStart=2;
this.filmCurrIndex=0;
if(this.lessNum===1){
this.configStart=2;
this.filmCurrIndex=0;
this.assign();
created(){
letrootWidth=document.documentElement.clientWidth||document.body.clientWidth;
letrootDom=document.querySelector('html');
rootDom.style.fontSize=rootWidth/1920*10+'px';
//功能增強(qiáng)(以上部分已經(jīng)實(shí)現(xiàn)了旋轉(zhuǎn)木馬):
//以下代碼實(shí)現(xiàn)目標(biāo):鼠標(biāo)模擬移動(dòng)端的左滑右滑事件,在左滑右滑中可以切換圖片
(function(){
vartouchDot,flagLeft=true,flagRight=true;
varbodyDom=document.querySelector('body');
bodyDom.addEventListener('mousedown',down,false);
bodyDom.addEventListener('mousemove',move,false);
bodyDom.addEventListen
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年對(duì)外漢語(yǔ)教師資格證考試漢語(yǔ)教材分析試卷
- 2025年自動(dòng)多排鉆項(xiàng)目提案報(bào)告
- 一只流浪貓的故事寫物作文6篇范文
- 環(huán)??萍继貏e聲明證明(5篇)
- 酒店預(yù)訂和住宿服務(wù)協(xié)議及退訂政策說(shuō)明
- 2025年消防安全標(biāo)識(shí)識(shí)別專項(xiàng)培訓(xùn)考試題庫(kù)試題解析
- 2025年軌道結(jié)構(gòu)減振產(chǎn)品項(xiàng)目規(guī)劃申請(qǐng)報(bào)告模板
- 新聞傳媒行業(yè)專業(yè)知識(shí)試題集
- 2025年工業(yè)互聯(lián)網(wǎng)平臺(tái)邊緣計(jì)算硬件架構(gòu)在智能機(jī)器人制造中的應(yīng)用前景報(bào)告
- 2025年藥物配伍指南試題
- 建筑工程施工現(xiàn)場(chǎng)質(zhì)量及安全管理流程圖措施體系落實(shí)計(jì)劃
- 混凝土減水劑測(cè)試指標(biāo)培訓(xùn)課件
- 山東中醫(yī)藥大學(xué)內(nèi)經(jīng)選讀(專升本)期末復(fù)習(xí)題
- 醫(yī)療保險(xiǎn)基本政策培訓(xùn)PPT
- 連云港師范高等??茖W(xué)校輔導(dǎo)員考試題庫(kù)
- 2023年湖北黃岡市檢察機(jī)關(guān)招聘雇員制檢察輔助人員50人高頻考點(diǎn)題庫(kù)(共500題含答案解析)模擬練習(xí)試卷
- 《國(guó)有企業(yè)招投標(biāo)及采購(gòu)管理辦法》
- 05G525-吊車軌道聯(lián)結(jié)及車擋(適用于鋼吊車梁)課件
- TQGCML 757-2023 硫酸鈣晶須規(guī)程
- 計(jì)數(shù)型MSA分析表
- 軍校招生政治考核表格式-雙面打印
評(píng)論
0/150
提交評(píng)論