auto scroll x without scroll
Works,
I'm working in speed and smoot
CSS:
html{overflow:hidden;}
JS:
//scroll to div (left and right)
function scrolltoDiv(id_divto){
var table = document.getElementById("table").style.left;
//si ce n'est pas un nombre
if(isNaN(table) == false){
// on donne une valeur a notre tableau
document.getElementById("table").style.left = "0px";
// on lance la function du déplacement de div
goTofunc(id_divto);
}else{
// notre tableau est deja un nombre on lance la function du déplacement de div
goTofunc(id_divto);
}
}
function goTofunc(id_divto){
//methode qui va permettre l'amination
var Divabord = setInterval(function(){
//incrementation de la vitesse
var incrementX;
// position de la div
var destinatPos = document.getElementById(id_divto).offsetLeft;
var depPosX = document.getElementById("table").style.left;
var compdepPosX = depPosX.replace("px","");
var dcompdepPosX = compdepPosX.replace("-","");
var x = 1;
if(compdepPosX < destinatPos){
var incrementX = x++;
var gttd = parseInt(compdepPosX)-(incrementX) + "px";
var compgttd = gttd.replace("-","");
var compgttdd = compgttd.replace("px","");
}
if(dcompdepPosX > destinatPos){
var incrementX = x++;
var gttd = parseInt(compdepPosX)+(incrementX) + "px";
var compgttd = gttd.replace("-","");
var compgttdd = compgttd.replace("px","");
}
if(compgttdd == destinatPos){
clearInterval(Divabord);
}
document.getElementById("table").style.left = gttd;
},1);
}Written by Valentin Beuret
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
iatek
512.9K
praveenvijayan
482.6K
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#