1
When creating a table and enabling the Datatable
in the same case if the width of the table is larger than the screen where the plugin is being displayed automatically creates a scroll
side. In the documentation they call Scrollx(horizontal).
So I have the following problem:
A Javascript so that according to the mouse drive on X the table moves, facilitating the user’s usability, with this I am not able to obtain the total table width to implement in the Javascript.
I would like a help to get this value and so make the code more efficient, because today was the value was set manually in the width of the table.
Below the código
used to make the scroll
via the mouse:
**
* Função que realiza o processo para fazer o scroll na tabela de acordo com a posição do mouse,
* é aplicado na classe table-responsive, portanto todas as tabelas que possuirem essa classe será aplicado.
*/
if (jQuery.browser.mobile === false) {
var $gal = $('.table-responsive');
if ($gal.length > 0) {
var galW = $gal.outerWidth(true),
// É adicionado o valor de 450 pois não consegui pegar o tamanho do scroll pelo JS...
// quando é utilizado o table-responsive não foi possível obter o valor do scroll.
galSW = $gal[0].scrollWidth + 450,
wDiff = (galSW / galW) - 1,
mPadd = 60,
damp = 20,
mX = 0,
mX2 = 0,
posX = 0,
mmAA = galW - (mPadd * 2), // the mousemove available area
mmAAr = (galW / mmAA); // get available mousemove didderence ratio
$gal.mousemove(function (e) {
mX = e.pageX - $(this).parent().offset().left - this.offsetLeft;
mX2 = Math.min(Math.max(0, mX - mPadd), mmAA) * mmAAr;
});
setInterval(function () {
posX += (mX2 - posX) / damp; // zeno's paradox equation "catching delay"
$gal.scrollLeft(posX * wDiff);
}, 5);
}
}
Henrique, you could edit your question by adding the code you implemented to get a faster answer.
– RXSD
Sure, sorry I’ll make the change right now.
– Henrique de Souza