The way i have coded it at the moment is to simply create a new slider
the same as the other one but with an up to date range.
There must be a better way to do this as its causing a lot of lag
sliding after a new slider is created.
code is below thanks for any help in advance.
slider_t and b are seperate from the problem.
var slider;
var slider_t;
var slider_b;
var width;
var element;
var position;
var slider_obj;
//Event.observe(window, 'resize', update);
document.observe("dom:loaded", function() {
slider_obj = this;
element = $('plist_con');
width = (element.scrollWidth-element.offsetWidth);
$('plist_con').setStyle({ maxwidth: (width) + 'px' });
slider = new Control.Slider('handle', 'track',
{
range: $R(0, width),
sliderValue: 0, // won't work if set to 0 due to a bug(?) in
script.aculo.us
currentValue: 0,
onSlide: function(v)
{
scrollHorizontal(v, $('plist_con'), slider);
$('pageination').innerHTML = 'slide: ' + v
//alert(this);
},
onChange: function(v)
{
scrollHorizontal(v, $('plist_con'), slider);
$('pageination').innerHTML = 'changed: ' + v
}
});
slider_t = new Control.Slider('side_t_bar', 'side_t_track', {
axis: 'vertical',
onSlide: function(v) { scrollVertical(v, $('side_type'),
slider_b); },
onChange: function(v) { scrollVertical(v, $('side_type'),
slider_b); }
});
slider_b = new Control.Slider('side_b_bar', 'side_b_track', {
axis: 'vertical',
onSlide: function(v) { scrollVertical(v, $('side_brand'),
slider_b); },
onChange: function(v) { scrollVertical(v, $('side_brand'),
slider_b); }
});
// disable vertical scrolling if text doesn't overflow the div
if ($('side_type').scrollHeight <= $('side_type').offsetHeight) {
slider_t.setDisabled();
$('side_t_wrap').hide();
}
// disable vertical scrolling if text doesn't overflow the div
if ($('side_brand').scrollHeight <= $('side_brand').offsetHeight)
{
slider_b.setDisabled();
$('side_b_wrap').hide();
}
// disable horizontal scrolling if text doesn't overflow the div
if ($('plist_con').scrollWidth <= $('plist_con').offsetWidth) {
slider.setDisabled();
$('wrap').hide();
}
});
function update()
{
width = (element.scrollWidth-element.offsetWidth);
position = (element.scrollLeft);
slider = new Control.Slider('handle', 'track',
{
range: $R(0, width),
sliderValue: position,
onSlide: function(v)
{
scrollHorizontal(v, $('plist_con'), slider);
$('pageination').innerHTML = 'slide: ' + v
},
onChange: function(v)
{
scrollHorizontal(v, $('plist_con'), slider);
$('pageination').innerHTML = 'changed: ' + v
}
});
//setTimeout('update()', 1120);
}
function scrollVertical(value, element, slider)
{
element.scrollTop = Math.round(value/
slider.maximum*(element.scrollHeight-element.offsetHeight));
}
function scrollHorizontal(value, element, slider)
{
element.scrollLeft = Math.round(value/
slider.maximum*(element.scrollWidth-element.offsetWidth));
}
function moveP()
{
x = document.getElementById('plist_con');
var col = Math.floor(x.offsetWidth / 214)
var scrollby = col * 214
new Effect.Scroll('plist_con',{x:-scrollby, mode:'relative'});
setTimeout('setscroll()', 1120)
}
function moveN()
{
x = document.getElementById('plist_con');
//alert("Position: " + x.scrollLeft + ", Viewable: " +
x.offsetWidth + ", Total: "+ x.scrollWidth + ", Total(S): " +
slider.maximum);
update();
var col = Math.floor(x.offsetWidth / 214)
var scrollby = col * 214
new Effect.Scroll('plist_con',{x:scrollby, mode:'relative'});
setTimeout('setscroll()', 1120)
}
function setscroll(){
var browserName=navigator.appName;
update();
if (browserName=="Microsoft Internet Explorer")
{
x = document.getElementById('plist_con');
//alert("scroll left:" + x.scrollLeft);
slider.setValue(x.scrollLeft);
}
else
{
x = document.getElementById('plist_con');
//alert("scroll left:" + x.scrollLeft);
slider.setValue(x.scrollLeft);
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---