Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
steve-image-carosel-test-page [2022/12/31 00:40] steve.wangsteve-image-carosel-test-page [2023/02/09 23:35] (current) steve.wang
Line 1: Line 1:
-====== Designing Service: Using Research & Empathy to Assist Society 服務設計:研究與同理心創造包容性社會 ====== +====== Designing Service: Using Research & Empathy to Assist Society 服務設計:透過研究與同理心創造包容性社會 ====== 
-=== design and change for assistance and pressure alleviation of the elderlystressed, and general public===+===Design and Change for Assistance and Pressure Alleviation of the ElderlyStressed, and General Public 計畫如何做出改變來協助年長者及社會大眾紓解壓力=== 
 <html> <html>
 <style> <style>
-body { +    body { 
- margin: 0; +        stylemargin: 0; 
- padding: 0; +        stylepadding: 0; 
- /*font: 75%/120% sans-serif;*/ +        style/*font: 75%/120% sans-serif;*/ 
-}+    }
  
 .imageCarosel{ .imageCarosel{
-    overflow:hidden; +        overflow:hidden; 
-    border-width:2px; +        border-width:2px; 
-    border-style:solid; +        border-style:solid; 
-    border-color:black;+        border-color:black
 +        background-color:grey;
 } }
  
 .mainImg{ .mainImg{
-    position:absolute;+        position:absolute
 +        transition-property:left; 
 +        transition-duration: 0.5s; 
 +        transition-delay: 100ms; 
 +        cursor:ew-resize;
 } }
  
 .left{ .left{
-    z-Index:2; +        z-Index:2; 
-    line-height: 34px; +        line-height: 34px; 
-    display: inline-block; +        display: inline-block; 
-    white-space: nowrap; +        white-space: nowrap; 
-      -webkit-transform: scaleX(-1); +          -webkit-transform: scaleX(-1); 
-        transform: scaleX(-1); +            transform: scaleX(-1); 
-    opacity:0.2+        opacity:0.5
-      color: grey; +          color: grey; 
-      background-color:transparent; +          background-color:transparent; 
-      border:none; +          border:none; 
-    }+        }
  
 .left:hover{ .left:hover{
-    opacity:0.8;+        opacity:0.9;
 } }
  
  
 .right{ .right{
-    z-Index:2; +        z-Index:2; 
-    line-height: 34px; +        line-height: 34px; 
-    display: inline-block; +        display: inline-block; 
-    opacity:0.2+        opacity:0.5
-    color: grey; +        color: grey; 
-    background-color:transparent; +        background-color:transparent; 
-      border:none;+          border:none;
 } }
  
 .right:hover{ .right:hover{
-    opacity:0.8;+        opacity:0.9;
 } }
 .arrow{ .arrow{
-    z-Index:3; +        z-Index:3; 
-    line-height: 34px; +        line-height: 34px; 
-    position:absolute; +        position:absolute; 
-    top:50%; +        top:50%; 
-    opacity:0.2; +        opacity:0.2; 
-    color: grey;+        color: grey;
 } }
 /* Make text go to the middle: /* Make text go to the middle:
-https://stackoverflow.com/a/14061404/19515980 + https://stackoverflow.com/a/14061404/19515980 
- + * 
-*/+ */
 /* /*
-.moveLeft{ + .moveLeft{ 
-    transition:4s; + *     transition:4s; 
-    transform:translateX(-3000) + *         transform:translateX(-3000) 
-}+ *         } 
 + * 
 +         .moveRight{ 
 +             transition:4s; 
 +                 transform:translateX(3000) 
 +                 } 
 +                 */
  
-.moveRight{ 
-    transition:4s; 
-    transform:translateX(3000) 
-} 
-*/ 
  
 </style> </style>
Line 122: Line 129:
 let info=[{ let info=[{
     imageSrc:'./what is this.png',     imageSrc:'./what is this.png',
-    potraitSrc:'./measure-potrait.PNG',+    portraitSrc:'./measure-portrait.PNG',
     href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=about-space_invaders',     href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=about-space_invaders',
     description:'hi,hi,hi',     description:'hi,hi,hi',
 },{ },{
     imageSrc:'./steve-color-scrolling.png',     imageSrc:'./steve-color-scrolling.png',
-    potraitSrc:'./homework-potrait.PNG',+    portraitSrc:'./homework-portrait.PNG',
     href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=my_planet',     href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=my_planet',
     description:'hio,hio,hio',     description:'hio,hio,hio',
 },{ },{
     imageSrc:'./steve-drawing-fractals.png',     imageSrc:'./steve-drawing-fractals.png',
-    potraitSrc:'./circuits-potrait.jpg',+    portraitSrc:'./circuits-portrait.jpg',
     href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=agriculture',     href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=agriculture',
     description:'hiv,hiv,hiv',     description:'hiv,hiv,hiv',
Line 139: Line 146:
  
 let info=[{ let info=[{
-    imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?t=1672300658&w=500&h=231&tok=41d240&media=steve-what_is_this.png', +    imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-students.jpg', 
-    potraitSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=steve-measure-potrait.png', +    portraitSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-students.jpg', 
-    href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=about-space_invaders', +    href:'https://renickbell.net/ed/2022service/doku.php?id=about-students', 
-    description:'hi,hi,hi',+    description:'about our students',
 },{ },{
-    imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=steve-color-scrolling.png', +    imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-arduino.jpg', 
-    potraitSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=steve-homework-potrait.png', +    portraitSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-arduino.jpg', 
-    href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=my_planet', +    href:'https://renickbell.net/ed/2022service/doku.php?id=arduino', 
-    description:'hio,hio,hio',+    description:'arduino',
 },{ },{
-    imageSrc:'https://renickbell.net/ed/2022service/doku.php?ns=%3A&image=%3Asteve-drawing-fractals.png&do=media&tab_files=files&tab_details=view', +    imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-simulation.jpg', 
-    potraitSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=steve-circuits-potrait.jpg', +    portraitSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-simulation.jpg', 
-    href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=agriculture', +    href:'https://renickbell.net/ed/2022service/doku.php?id=partner-simulation', 
-    description:'hiv,hiv,hiv',+    description:'simulation of elderly experience', 
 +},{ 
 +    imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-hydra.jpg', 
 +    portraitSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-hydra.jpg', 
 +    href:'https://renickbell.net/ed/2022service/doku.php?id=hydra-practice', 
 +    description:'hydra', 
 +},
 +    imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-visual.jpg', 
 +    portraitSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-visual.jpg', 
 +    href:'https://renickbell.net/ed/2022service/doku.php?id=art-museum', 
 +    description:'visual cues',
 }] }]
  
Line 179: Line 196:
         else if (domLocation=='doku'){         else if (domLocation=='doku'){
             //document.getElementById('dokuwiki__content').appendChild(this.carosel)             //document.getElementById('dokuwiki__content').appendChild(this.carosel)
-            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public').appendChild(this.carosel)+            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public_計畫如何做出改變來協助年長者及社會大眾紓解壓力').appendChild(this.carosel)
         }         }
         else{         else{
Line 190: Line 207:
         }         }
         this.carosel.className='imageCarosel'         this.carosel.className='imageCarosel'
 +        this.carosel.ondragstart=(()=>{return false})
 +        this.carosel.ondrop=(()=>{return false})
         if (domLocation=='body' || domLocation==undefined || domLocation=='main'){         if (domLocation=='body' || domLocation==undefined || domLocation=='main'){
             document.body.appendChild(this.carosel)             document.body.appendChild(this.carosel)
Line 195: Line 214:
         else if (domLocation=='doku'){         else if (domLocation=='doku'){
             //document.getElementById('dokuwiki__content').appendChild(this.carosel)             //document.getElementById('dokuwiki__content').appendChild(this.carosel)
-            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public').appendChild(this.carosel)+            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public_計畫如何做出改變來協助年長者及社會大眾紓解壓力').appendChild(this.carosel)
  }  }
         else{         else{
Line 208: Line 227:
         }         }
         else{         else{
-            this.mainImg1.href=this.info[1].potraitSrc+            this.mainImg1.href=this.info[1].portraitSrc
         }         }
         this.mainImg1.className='mainImg'         this.mainImg1.className='mainImg'
Line 217: Line 236:
         }         }
         else{         else{
-            this.mainImg2.src=this.info[0].potraitSrc+            this.mainImg2.src=this.info[0].portraitSrc
         }         }
         this.mainImg2.className='mainImg'         this.mainImg2.className='mainImg'
         if (domLocation=='main' || domLocation=='doku'){         if (domLocation=='main' || domLocation=='doku'){
             this.mainImg1.style.width='100%'             this.mainImg1.style.width='100%'
-            this.mainImg1.style.height=window.innerHeight-10+'px'+            this.mainImg1.style.height='auto'
             this.mainImg2.style.width='100%'             this.mainImg2.style.width='100%'
-            this.mainImg2.style.height=window.innerHeight-10+'px'+            this.mainImg2.style.height='auto'
         }         }
         this.carosel.appendChild(this.mainImg1)         this.carosel.appendChild(this.mainImg1)
Line 232: Line 251:
         this.centeredImg=this.mainImg2         this.centeredImg=this.mainImg2
         this.caroselSize=sizePoint         this.caroselSize=sizePoint
-        this.correctCenteredImgPosition=new Point(this.centeredImg.getBoundingClientRect().x,this.centeredImg.getBoundingClientRect().y)+        setTimeout(()=>
 +            this.correctCenteredImgPosition=new Point(this.carosel.style.left.slice(0,this.carosel.style.left.length-2),this.carosel.style.top.slice(0,this.carosel.style.left.length-2)) 
 +        },100)
         this.imageCaroselNumber=carosels.length         this.imageCaroselNumber=carosels.length
         this.queue=[]         this.queue=[]
Line 258: Line 279:
         this.right.style.top='50%'         this.right.style.top='50%'
         let arrowSizes=browserZoomLevel/2         let arrowSizes=browserZoomLevel/2
-        if (arrowSizes<84){+        if (arrowSizes<84 && deviceOrientation=='landscape'){
             arrowSizes=84             arrowSizes=84
         }         }
-        else if (arrowSizes>100){+        else if (arrowSizes>100 && deviceOrientation=='landscape'){
             arrowSizes=100             arrowSizes=100
 +        }
 +        else if (deviceOrientation=='portrait'){
 +            console.log('acknowledged')
 +            arrowSizes=browserZoomLevel/6
         }         }
         this.right.style.width=arrowSizes+'px'         this.right.style.width=arrowSizes+'px'
Line 317: Line 342:
         this.queue.forEach((x,i)=>{         this.queue.forEach((x,i)=>{
             if (x!='quickRight'&& x!='quickLeft'){             if (x!='quickRight'&& x!='quickLeft'){
-                this.queue=[...safeSplice(this.queue,this.queue.length-i-1,i),action,...safeSplice(queue,i,0)]+                this.queue=[...safeSplice(this.queue,this.queue.length-i-1,i),action,...safeSplice(this.queue,i,0)]
             console.log('trying',this.queue)             console.log('trying',this.queue)
             }             }
Line 323: Line 348:
     }     }
     quickRight (){     quickRight (){
-        manuallyMoveHtmlToRight(this.centeredImg,this.centeredImg.getBoundingClientRect().x,100,this.carosel.getBoundingClientRect().right/100+        console.log('quick right'
-        this.currentImage+=1 +        this.currentImage-=1 
-        if (this.currentImage>this.info.length-1){ +        if (this.currentImage<0){ 
-            this.currentImage=0+            this.currentImage=this.info.length-1
         }         }
-        console.log(this.currentImage) +        if (this.centeredImg==this.mainImg1){ 
-        if (this.mainImg2==this.centeredImg){ +            this.changeContent(this.mainImg2)
-            this.mainImg1.style.left=this.caroselLocation.x-this.mainImg1.getBoundingClientRect().width+'px' +
-        this.changeContent(this.mainImg1) +
-        manuallyMoveHtmlToRight(this.mainImg1,this.mainImg1.getBoundingClientRect().x,90,(this.correctCenteredImgPosition.x-this.mainImg1.getBoundingClientRect().x)/91) +
-            this.centeredImg=this.mainImg1 +
-            /*+
             setTimeout(()=>{             setTimeout(()=>{
-                this.centeredImg.style.left=this.caroselLocation/10+'px' +                this.mainImg2.style.transitionProperty='none' 
-            },(this.caroselLocation/10)*14+                this.mainImg2.style.left=this.correctCenteredImgPosition.x-this.mainImg2.getBoundingClientRect().width+'px' 
-            */+                this.centeredImg.style.left=this.carosel.getBoundingClientRect().right+this.centeredImg.getBoundingClientRect().width+'px' 
 +                this.mainImg2.style.transitionProperty='left' 
 +                this.mainImg2.style.left=this.correctCenteredImgPosition.x+'px' 
 +                this.centeredImg=this.mainImg2 
 +            },100)
         }         }
         else{         else{
-            console.log('main img1'+            this.changeContent(this.mainImg1)
-            this.mainImg2.style.left=this.caroselLocation.x-this.mainImg2.getBoundingClientRect().width+'px' +
-            this.changeContent(this.mainImg2) +
-        manuallyMoveHtmlToRight(this.mainImg2,this.mainImg2.getBoundingClientRect().x,90,(this.correctCenteredImgPosition.x-this.mainImg2.getBoundingClientRect().x)/91) +
-            this.centeredImg=this.mainImg2 +
-            /*+
             setTimeout(()=>{             setTimeout(()=>{
-                this.centeredImg.style.left=this.caroselLocation/10+'px' +                this.mainImg1.style.transitionProperty='none' 
-            },(this.caroselLocation/10)*14+                this.mainImg1.style.left=this.correctCenteredImgPosition.x-this.mainImg1.getBoundingClientRect().width+'px' 
-            */+            this.centeredImg.style.left=this.carosel.getBoundingClientRect().right+this.centeredImg.getBoundingClientRect().width+'px' 
 +                this.mainImg1.style.transitionProperty='left' 
 +                this.mainImg1.style.left=this.correctCenteredImgPosition.x+'px' 
 +                this.centeredImg=this.mainImg1 
 +            },100)
         }         }
         return new Promise((resolve,reject)=>{         return new Promise((resolve,reject)=>{
Line 359: Line 382:
     }     }
     quickLeft (){     quickLeft (){
-        console.log('switched left',this.centeredImg) +        console.log('quick left')
-        manuallyMoveHtmlToLeft(this.centeredImg,this.centeredImg.getBoundingClientRect().x,100,(this.carosel.getBoundingClientRect().left+this.centeredImg.getBoundingClientRect().width+90)/100)+
         this.currentImage-=1         this.currentImage-=1
         if (this.currentImage<0){         if (this.currentImage<0){
             this.currentImage=this.info.length-1             this.currentImage=this.info.length-1
         }         }
-        console.log(this.currentImage) +        if (this.centeredImg==this.mainImg1){
-      //  setTimeout(()=>+
-        if (this.mainImg2==this.centeredImg){ +
-                console.log('main img1'+
-                this.mainImg1.style.left=this.carosel.getBoundingClientRect().x+this.mainImg1.getBoundingClientRect().width+150+'px' +
-            this.changeContent(this.mainImg1) +
-            manuallyMoveHtmlToLeft(this.mainImg1,this.mainImg1.getBoundingClientRect().x,90,(this.mainImg1.getBoundingClientRect().x-this.correctCenteredImgPosition.x)/91) +
-                this.centeredImg=this.mainImg1 +
-            } +
-            else{ +
-                console.log('main img2'+
-                this.mainImg2.style.left=this.carosel.getBoundingClientRect().x+this.mainImg2.getBoundingClientRect().width+150+'px'+
             this.changeContent(this.mainImg2)             this.changeContent(this.mainImg2)
-            manuallyMoveHtmlToLeft(this.mainImg2,this.mainImg2.getBoundingClientRect().x,90,(this.mainImg2.getBoundingClientRect().x-this.carosel.getBoundingClientRect().x)/91) +            this.mainImg2.style.transitionProperty='none' 
-                this.centeredImg=this.mainImg2 +            this.mainImg2.style.left=this.correctCenteredImgPosition.x+this.mainImg2.getBoundingClientRect().width+'px
-            } +            this.centeredImg.style.left=this.correctCenteredImgPosition.x-this.centeredImg.getBoundingClientRect().width+'px' 
-       // },10) +            this.mainImg2.style.transitionProperty='left' 
-        return new Promise((resolve,reject)=>{ +            this.mainImg2.style.left=this.correctCenteredImgPosition.x+'px' 
-            setTimeout(()=>+            this.centeredImg=this.mainImg2
-                resolve(true) +
-            },10*35) +
-        }) +
-    } +
-    switchRight (){ +
-        console.log('switched right') +
-        manuallyMoveHtmlToRight(this.centeredImg,this.centeredImg.getBoundingClientRect().x,10,this.carosel.getBoundingClientRect().right/10) +
-        this.currentImage+=1 +
-        console.log(this.currentImage) +
-        if (this.currentImage>this.info.length-1){ +
-            this.currentImage=0+
         }         }
-        console.log(this.currentImage) +        else{
-        if (this.mainImg2==this.centeredImg){ +
-            console.log('main img2'+
-            this.mainImg1.style.left=this.caroselLocation.x-this.mainImg1.getBoundingClientRect().width+'px    '+
             this.changeContent(this.mainImg1)             this.changeContent(this.mainImg1)
-            setTimeout(()=>{ +            this.mainImg1.style.transitionProperty='none' 
-                manuallyMoveHtmlToRight(this.mainImg1,this.mainImg1.getBoundingClientRect().x,10,(this.correctCenteredImgPosition.x-this.mainImg1.getBoundingClientRect().x)/10) +            this.mainImg1.style.left=this.correctCenteredImgPosition.x+this.mainImg1.getBoundingClientRect().width+'px' 
-            },200)+            this.centeredImg.style.left=this.correctCenteredImgPosition.x-this.centeredImg.getBoundingClientRect().width+'px' 
 +            this.mainImg1.style.transitionProperty='left' 
 +            this.mainImg1.style.left=this.correctCenteredImgPosition.x+'px'
             this.centeredImg=this.mainImg1             this.centeredImg=this.mainImg1
-            /* 
-            setTimeout(()=>{ 
-                this.centeredImg.style.left=this.caroselLocation/10+'px' 
-            },(this.caroselLocation/10)*14) 
-            */ 
-        } 
-        else{ 
-            console.log('main img1') 
-            this.mainImg2.style.left=this.caroselLocation.x-this.mainImg2.getBoundingClientRect().width+'px' 
-            this.changeContent(this.mainImg2) 
-            setTimeout(()=>{ 
-                manuallyMoveHtmlToRight(this.mainImg2,this.mainImg2.getBoundingClientRect().x,10,(this.correctCenteredImgPosition.x-this.mainImg2.getBoundingClientRect().x)/10) 
-            },200) 
-            this.centeredImg=this.mainImg2 
-            /* 
-            setTimeout(()=>{ 
-                this.centeredImg.style.left=this.caroselLocation/9+'px' 
-            },(this.caroselLocation/10)*14) 
-            */ 
         }         }
         return new Promise((resolve,reject)=>{         return new Promise((resolve,reject)=>{
             setTimeout(()=>{             setTimeout(()=>{
                 resolve(true)                 resolve(true)
-            },14*100)+            },10*35)
         })         })
     }     }
-    switchLeft (){ +    switchRight (){ 
-        console.log('switched left'+        console.log('switch right')
-        manuallyMoveHtmlToLeft(this.centeredImg,this.centeredImg.getBoundingClientRect().x,10,(this.carosel.getBoundingClientRect().left+this.centeredImg.getBoundingClientRect().width+90)/10)+
         this.currentImage-=1         this.currentImage-=1
         if (this.currentImage<0){         if (this.currentImage<0){
             this.currentImage=this.info.length-1             this.currentImage=this.info.length-1
         }         }
-        console.log(this.currentImage) +        if (this.centeredImg==this.mainImg1){
-      //  setTimeout(()=>+
-            if (this.mainImg2==this.centeredImg){ +
-                console.log('main img0'+
-                this.mainImg1.style.left=this.carosel.getBoundingClientRect().x+this.mainImg1.getBoundingClientRect().width+150+'px' +
-            this.changeContent(this.mainImg1) +
-            manuallyMoveHtmlToLeft(this.mainImg1,this.mainImg1.getBoundingClientRect().x,10,(this.carosel.getBoundingClientRect().x+this.mainImg1.getBoundingClientRect().x)/10) +
-                this.centeredImg=this.mainImg1 +
-            } +
-            else{ +
-                console.log('main img2'+
-                this.mainImg2.style.left=this.carosel.getBoundingClientRect().x+this.mainImg2.getBoundingClientRect().width+150+'px'+
             this.changeContent(this.mainImg2)             this.changeContent(this.mainImg2)
-                manuallyMoveHtmlToLeft(this.mainImg2,this.mainImg2.getBoundingClientRect().x,10,(this.carosel.getBoundingClientRect().x+this.mainImg2.getBoundingClientRect().x)/10)+            setTimeout(()=>{ 
 +                this.mainImg2.style.transitionProperty='none' 
 +                this.mainImg2.style.left=this.correctCenteredImgPosition.x-this.mainImg2.getBoundingClientRect().width+'px' 
 +                this.centeredImg.style.left=this.carosel.getBoundingClientRect().right+this.centeredImg.getBoundingClientRect().width+'px' 
 +                this.mainImg2.style.transitionProperty='left' 
 +                this.mainImg2.style.left=this.correctCenteredImgPosition.x+'px'
                 this.centeredImg=this.mainImg2                 this.centeredImg=this.mainImg2
-            } +            },100) 
-       // },10)+        } 
 +        else{ 
 +            this.changeContent(this.mainImg1) 
 +            setTimeout(()=>
 +                this.mainImg1.style.transitionProperty='none' 
 +                this.mainImg1.style.left=this.correctCenteredImgPosition.x-this.mainImg1.getBoundingClientRect().width+'px' 
 +            this.centeredImg.style.left=this.carosel.getBoundingClientRect().right+this.centeredImg.getBoundingClientRect().width+'px' 
 +                this.mainImg1.style.transitionProperty='left' 
 +                this.mainImg1.style.left=this.correctCenteredImgPosition.x+'px' 
 +                this.centeredImg=this.mainImg1 
 +            },100) 
 +        }
         return new Promise((resolve,reject)=>{         return new Promise((resolve,reject)=>{
             setTimeout(()=>{             setTimeout(()=>{
                 resolve(true)                 resolve(true)
-            },14*100)+            },10*35)
         })         })
     }     }
Line 469: Line 453:
     autoScroller (){     autoScroller (){
         this.scrollInterval=setInterval(()=>{         this.scrollInterval=setInterval(()=>{
-            this.sequenceActions('switchRight'+            if (this.queue.length==0 && imageAutoSwitchCooldown==false){ 
-        },5000)+                imageAutoSwitchCooldown=true 
 +                resetImageSwitchCooldown() 
 +                this.sequenceActions('switchRight') 
 +            } 
 +        },8000) 
 +    } 
 +    imageJumpAnimationRight (amount){ 
 +        this.currentImage-=amount 
 +        if (this.currentImage<0){ 
 +            this.currentImage=this.info.length+this.currentImage 
 +        } 
 +        this.centeredImg.style.left=this.carosel.getBoundingClientRect().right*3+'px' 
 +        let jumpInterval=setInterval(()=>
 +            this.centeredImg.style.left=this.correctCenteredImgPosition.x+'px' 
 +        },amount/0.3) 
 +        setTimeout(()=>
 +            clearInterval(jumpInterval) 
 +            this.changeContent(this.centeredImg) 
 +        },amount/0.6)
     }     }
     textDesciption (){     textDesciption (){
Line 497: Line 499:
             }             }
             else{             else{
-                toChangeTo.src=this.info[this.currentImage].potraitSrc +                toChangeTo.src=this.info[this.currentImage].portraitSrc
-            } +
-            if (this.infoText!=undefined){ +
-                this.infoText.textContent=this.info[this.currentImage].description+
             }             }
         }         }
 +     addSpaceAbove (amount){
 +         for (let i = 0; i < amount; i++) {
 +             this.carosel.parentElement.insertBefore(document.createElement('br'),this.carosel)
 +         }
 +    }
 } }
 +
 +function loadImg (){
 +    let imageElemForLoading= new Image()
 +    if (deviceOrientation == ' portrait'){
 +        info.forEach(x=>{
 +            imageElemForLoading.src=x.portraitSrc
 +        })
 +    }
 +    else{
 +        info.forEach(x=>{
 +            imageElemForLoading.src=x.imageSrc
 +        })
 +    }
 +}
 +
 +
 function manuallyMoveHtmlToRight (elem,startX,moveBy,times,counter){ function manuallyMoveHtmlToRight (elem,startX,moveBy,times,counter){
     if (counter==undefined){     if (counter==undefined){
Line 531: Line 551:
     }     }
 } }
 +
 +async function sequencingSwitchingImages (imageCaroselNumber){
 +   let currentImageCarosel=carosels[imageCaroselNumber]
 +   await currentImageCarosel[currentImageCarosel.queue[0]]()
 +   //document.getElementById('console_output').innerHTML+='<br><br>'+currentImageCarosel.queue[0]
 +   currentImageCarosel.queue=safeSplice(currentImageCarosel.queue,1,0)
 +    if (currentImageCarosel.queue.length>0){
 +        sequencingSwitchingImages(imageCaroselNumber)
 +    }
 +}
 +
 */ */
  
 +let imageAutoSwitchCooldown=false
 async function sequencingSwitchingImages (imageCaroselNumber){ async function sequencingSwitchingImages (imageCaroselNumber){
 +   imageAutoSwitchCooldown=true
    let currentImageCarosel=carosels[imageCaroselNumber]    let currentImageCarosel=carosels[imageCaroselNumber]
    await currentImageCarosel[currentImageCarosel.queue[0]]()    await currentImageCarosel[currentImageCarosel.queue[0]]()
Line 539: Line 572:
     if (currentImageCarosel.queue.length>0){     if (currentImageCarosel.queue.length>0){
         sequencingSwitchingImages(imageCaroselNumber)         sequencingSwitchingImages(imageCaroselNumber)
 +        resetImageSwitchCooldown(currentImageCarosel)
     }     }
 +}
 +
 +function resetImageSwitchCooldown (currentImageCarosel){
 +    setTimeout(()=>{
 +        if (currentImageCarosel.queue.length==0){
 +            imageAutoSwitchCooldown=false
 +        }
 +        else {
 +            setTimeout(()=>{
 +                resetImageSwitchCooldown(currentImageCarosel)
 +            },5000)
 +        }
 +    },3000)
 } }
  
Line 546: Line 593:
      browserZoomLevel = Math.round(window.devicePixelRatio * 100);      browserZoomLevel = Math.round(window.devicePixelRatio * 100);
 if (window.innerWidth<window.innerHeight){ if (window.innerWidth<window.innerHeight){
-    console.log('potrait mode'+    console.log('portrait mode'
-    deviceOrientation='potrait'+    deviceOrientation='portrait'
 } }
 else{ else{
Line 553: Line 600:
     deviceOrientation='landscape'     deviceOrientation='landscape'
 } }
 +loadImg()
 console.log('loaded') console.log('loaded')
 //higs=new ImageCarosel(new Point(1920,1000),info,'main') //higs=new ImageCarosel(new Point(1920,1000),info,'main')
Line 560: Line 608:
 carosels.push(higs) carosels.push(higs)
 //higs.sequenceActions(higs.quickRight) //higs.sequenceActions(higs.quickRight)
 +higs.quickRight()
 //higs.autoScroller() //higs.autoScroller()
-setTimeout(()=>{ 
-higs.carosel.style.height=window.innerHeight+'px'; 
-higs.carosel.style.width=window.innerWidth-100+'px';      document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public').appendChild(higs.carosel) 
-//higs.carosel.style.top='250px'; 
 /* /*
-if (deviceOrientation=='portrait'){ +    setTimeout(()=>
-higs.carosel.style.top=document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public').getBoundingClientRect().y+document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public').getBoundingClientRect().height+'px' +        if (deviceOrientation=='landscape'){ 
-+            higs.carosel.style.height=window.innerHeight+'px'
-else if (browserZoomLevel<300)+            higs.carosel.style.width=window.innerWidth-100+'px';       
-//higs.carosel.style.top=document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public').getBoundingClientRect().y+browserZoomLevel/2+'px' +            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public_計畫如何做出改變來協助年長者及社會大眾紓解壓力').appendChild(higs.carosel) 
-higs.carosel.style.top=document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public').getBoundingClientRect().y+document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public').getBoundingClientRect().height+'px' +            higs.caroselLocation=new Point(0,300) 
-+        
-else +        else{ 
-//higs.carosel.style.top=document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public').getBoundingClientRect().y+browserZoomLevel/1.5+'px' +            higs.carosel.style.height=window.innerHeight+'px'; 
-higs.carosel.style.top=document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public').getBoundingClientRect().y+document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public').getBoundingClientRect().height+'px' +            higs.carosel.style.width=window.innerWidth+'px';       
-+            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public_計畫如何做出改變來協助年長者及社會大眾紓解壓力').appendChild(higs.carosel) 
-*/ +            higs.caroselLocation=new Point(100,300) 
-//createWikiSpacing() +        
-higs.caroselLocation=new Point(0,300+    },1000) 
-},1000)+    */ 
 +    setTimeout(()=>
 +           //higs.carosel.style.width=document.getElementsByClassName('permalink')[0].getBoundingClientRect().right-higs.carosel.getBoundingClientRect().x+'px';       
 +      higs.carosel.style.width='80%' 
 +           // higs.carosel.style.width='1600px' 
 +            //higs.carosel.style.height='400px' 
 +            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public_計畫如何做出改變來協助年長者及社會大眾紓解壓力').appendChild(higs.carosel) 
 +            higs.caroselLocation=new Point(0,900) 
 +            setTimeout(()=>
 +                higs.addSpaceAbove(2) 
 +                //higs.carosel.style.height=higs.mainImg1.getBoundingClientRect().height+'px'; 
 +           // higs.carosel.style.height='800px' 
 +                higs.carosel.style.height=higs.mainImg1.getBoundingClientRect().height+'px' 
 +            },100
 +    },300)
 }) })
 +
 +function getDeviceType () {
 +  const ua = navigator.userAgent;
 +  if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(ua)) {
 +    return "tablet";
 +  }
 +  if (
 +    /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(
 +      ua
 +    )
 +  ) {
 +    return "mobile";
 +  }
 +  return "desktop";
 +};
 +
 +let deviceType=getDeviceType()
  
 document.addEventListener("click", e => { document.addEventListener("click", e => {
Line 614: Line 690:
  
 let switchImageCooldown=false let switchImageCooldown=false
-document.addEventListener('pointermove', ((e) => { +if (deviceType!='mobile'){ 
-    mouse.x = e.pageX +    document.addEventListener('pointermove', ((e) => { 
-    mouse.y = e.pageY +        mouse.x = e.pageX 
-    if (mouse.x>=window.innerWidth-2 && switchImageCooldown==false){ +        mouse.y = e.pageY 
-        checkIfSwitchImageRight() +        if (mouse.x>=window.innerWidth-2 && switchImageCooldown==false){ 
-    +            checkIfSwitchImageRight() 
-    else if (mouse.x<2 && switchImageCooldown==false){ +        
-        checkIfSwitchImageLeft() +        else if (mouse.x<2 && switchImageCooldown==false){ 
-    +            checkIfSwitchImageLeft() 
-}))+        
 +    })) 
 +}
  
-/* +if (deviceType!='mobile'){ 
-window.addEventListener("resize", function(e){ +    window.addEventListener("resize", function(e){ 
-    if (window.innerWidth<window.innerHeight && deviceOrientation!='landscape'){ +        console.log('options',deviceType!='mobile',deviceOrientation!='portrait')  
-        document.location.reload() +        if (window.innerWidth<window.innerHeight){ 
- console.log('potrait mode'+            //document.location.reload() 
- //deviceOrientation='landscape' +                console.log('Resize detected: portrait mode'
-        //adaptToOrientationChange() +                deviceOrientation='portrait' 
-    +                higs.sequenceActions('quickRight') 
-    else if (deviceOrientation!='potrait'){ +                setTimeout(()=>{ 
-        document.location.reload() +                    higs.carosel.style.height=higs.centeredImg.getBoundingClientRect().height+'px' 
- console.log('landscape mode'+                },300) 
- //deviceOrientation='potrait+            } 
-        //adaptToOrientationChange() +            //adaptToOrientationChange() 
-    +        else{  
-}) +            //document.location.reload() 
-*/+            console.log('Resize detected: landscape mode'
 +                deviceOrientation='landscape' 
 +                higs.sequenceActions('quickRight'
 +               setTimeout(()=>
 +                    higs.carosel.style.height=higs.centeredImg.getBoundingClientRect().height+'px' 
 +                },200) 
 +            //adaptToOrientationChange() 
 +        
 +    }) 
 +
 +else
 +    screen.orientation.onchange=(()=>
 +        if (screen.orientation.type == 'portrait-primary' || screen.orientation.type == 'portrait-secondary'){ 
 +            //document.location.reload() 
 +                console.log('Resize detected: portrait mode'
 +                deviceOrientation='portrait' 
 +                higs.sequenceActions('quickRight') 
 +                setTimeout(()=>{ 
 +                    higs.carosel.style.height=higs.centeredImg.getBoundingClientRect().height+'px' 
 +                },300) 
 +            } 
 +            //adaptToOrientationChange() 
 +        else{  
 +            //document.location.reload() 
 +            console.log('Resize detected: landscape mode'
 +                deviceOrientation='landscape
 +                higs.sequenceActions('quickRight'
 +               setTimeout(()=>
 +                    higs.carosel.style.height=higs.centeredImg.getBoundingClientRect().height+'px' 
 +                },200) 
 +            //adaptToOrientationChange() 
 +        
 +    }) 
 +
 + 
 +//Screen orientation on mobile devies: https://stackoverflow.com/a/5499030/19515980 
 +//screen.orientation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/orientation 
 +//screenorientation API: https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation
  
 /* /*
Line 662: Line 777:
 */ */
  
-document.addEventListener('touchstart', handleTouchStart, false);         +window.addEventListener('touchstart', handleTouchStart, false);         
-document.addEventListener('touchmove', handleTouchMove, false);+window.addEventListener('touchmove', handleTouchMove, false);
  
 var xDown = null;                                                         var xDown = null;                                                        
Line 679: Line 794:
 };                                                 };                                                
                                                                                                                                                    
 +let swipeCooldown=false
 function handleTouchMove(evt) { function handleTouchMove(evt) {
 +console.log('swipe 1')
     if ( ! xDown || ! yDown ) {     if ( ! xDown || ! yDown ) {
         return;         return;
     }     }
 +console.log('swipe 2')
     var xUp = evt.touches[0].clientX;                                         var xUp = evt.touches[0].clientX;                                    
     var yUp = evt.touches[0].clientY;     var yUp = evt.touches[0].clientY;
Line 691: Line 808:
                                                                                                                                                    
     if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/     if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/
-        if ( xDiff > 0 ) {+        if ( xDiff > 0 && swipeCooldown==false) { 
 +            console.log('swiped left'
 +            swipeCooldown=true
             checkIfSwitchImageLeft(evt.target)             checkIfSwitchImageLeft(evt.target)
-        } else {+            setTimeout(()=>
 +                swipeCooldown=false 
 +            },500) 
 +         
 +        else if (swipeCooldown==false) { 
 +            console.log('swiped right'
 +            swipeCooldown=true
             checkIfSwitchImageRight(evt.target)             checkIfSwitchImageRight(evt.target)
 +            setTimeout(()=>{
 +                swipeCooldown=false
 +            },500)
         }                                }                       
     } else {     } else {
         if ( yDiff > 0 ) {         if ( yDiff > 0 ) {
-            /* down swipe */ +            console.log('donw swipe')
         } else {          } else { 
-            /* up swipe */+            console.log('up swipe')
         }                                                                          }                                                                 
     }     }
Line 709: Line 837:
  
 //swiping code by: https://stackoverflow.com/a/23230280/19515980 //swiping code by: https://stackoverflow.com/a/23230280/19515980
 +
  
 function adaptToOrientationChange (){ function adaptToOrientationChange (){
Line 772: Line 901:
 } }
 function createWikiSpacing (){ function createWikiSpacing (){
-    for (let i = 0; i < (1/browserZoomLevel)*3000; i++) {     document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public').appendChild(document.createElement('br'))+    for (let i = 0; i < (1/browserZoomLevel)*3000; i++) {     document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public_計畫如何做出改變來協助年長者及社會大眾紓解壓力').appendChild(document.createElement('br'))
     }     }
 } }
Line 783: Line 912:
 </script> </script>
 </html> </html>
-{{:aging.png?400|}} {{:service.png?400|}} [[destressing-images-overview|{{:destressing.png?400|}}]] 
- 
-====== old headline: Aging & Society, Empathy & Assistance, Service & Design ======  
  
  • steve-image-carosel-test-page.1672476033.txt.gz
  • Last modified: 2022/12/31 00:40
  • by steve.wang