




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
第vue實(shí)現(xiàn)旋轉(zhuǎn)木馬動(dòng)畫本文實(shí)例為大家分享了vue實(shí)現(xiàn)旋轉(zhuǎn)木馬動(dòng)畫的具體代碼,供大家參考,具體內(nèi)容如下
圖片數(shù)量可為任意值都能正常處理[1-無限個(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',//控制隱藏圖片是從左上角跳出來還是從右上角跳出來
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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 醫(yī)療健康管理在商業(yè)領(lǐng)域的應(yīng)用與挑戰(zhàn)
- 教案檢查工作總結(jié)模版
- 上海 房東租房合同范例
- 紅褐色扁平風(fēng)網(wǎng)絡(luò)安全模板
- 儲(chǔ)罐廠家供貨合同范例
- 產(chǎn)品定制打樣合同范例
- 供銷付款合同范例
- 防溺水安全家長會(huì)發(fā)言稿模版
- 住建部買房合同范例
- 職業(yè)性硬皮病的臨床護(hù)理
- 銀級考試題目p43測試題
- 有限空間作業(yè)及應(yīng)急物資清單
- 思想道德與法治教案第一章:領(lǐng)悟人生真諦把握人生方向
- 61850報(bào)文解析-深瑞版-131016
- 0-6歲兒童隨訪表
- 江西新定額2017土建定額說明及解釋
- 國家電網(wǎng)有限公司十八項(xiàng)電網(wǎng)重大反事故措施(修訂版)-2018版(word文檔良心出品)
- 語文四年級下冊《失落的一角》繪本閱讀 課件(共61張PPT)
- 附件一∶ 教育部專家實(shí)地評估案頭必備材料
- 余甘果的栽培與加工工藝
- 中考英語雙向細(xì)目表
評論
0/150
提交評論