javascript - Image Slider w/ Controls -


building simple javascript slider controls, i'm having hard time control triggers (left,right -arrows) , dealing loop moving smoothly left-to-right when transitioning end-to-beginning or vice-versa.

function slider(tag,count){     var self = this;     this.build=(buildset)=>build(buildset,self),     this.activeslide = 0;     this.totalslides = count,     this.slidewidth = (window.screen.width * -self.totalslides),      this.getslider=()=>get(tag),     this.controls={         left:()=>{         },         right:()=>{             var slider = self.getslider();             append(slider,slider.children[0]);             self.clear();             settimeout(()=>self.start(), 5000);             self.activeslide++;             self.activeslide = (self.activeslide === self.totalslides) ? 0 : self.activeslide;             var slideto = window.screen.width * -self.activeslide;             slider.style.transform = "translatex("+slideto+"px)";         }        },     this.start=()=>{         this.interval = setinterval(()=>{             var slider = self.getslider();             append(slider,slider.children[0]);             self.activeslide++;             self.activeslide = (self.activeslide === self.totalslides) ? 0 : self.activeslide;             var slideto = window.screen.width * -self.activeslide;             slider.style.transform = "translatex("+slideto+"px)";         },5000);     },     this.clear=()=>{         clearinterval(this.interval);     } } 

//html

<wrapper data-wrapper="slider">      <control class="fa fa-arrow-circle-o-left fa-2x"></control>      <slider id="slide1">          <img src="/media/slide-1.jpg">          <img src="/media/slide-2.jpg">          <img src="/media/slide-3.jpg">      </slider>      <control class="fa fa-arrow-circle-o-right fa-2x"></control> </wrapper> 

question: how can make slider transistion end-to-start, start-to-end "infinite" loop smooth left-to-right (ease)?


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -