After much looking around on the subject, it is far from clear how I can get my slider to respond to a touch event.
I have attempted to modify the YUI slider code as follows. What might be going wrong? Also, please note, I am a total JavaScript beginner. Not only is the code cobbled together from online examples, but if you can help me to alter it, please explain as you would to a child. Don't assume any prior knowledge, because I have almost none. Much appreciated! Thank you for any advice. (function() { var Event = YAHOO.util.Event var Dom = YAHOO.util.Dom var lang = YAHOO.lang var bg = "slider-bg" var thumb = "slider-thumb" var slider; // Determines starting point of slider var topConstraint = -20; // Determines end point of slider var bottomConstraint = 280; // Custom scale factor for converting the pixel offset into a real value var scaleFactor = 1.5; // The amount the slider moves when the value is changed with the arrow // keys var keyIncrement = 3; Event.onDOMReady(function() { slider = YAHOO.widget.Slider.getHorizSlider(bg, thumb, topConstraint, bottomConstraint, 3); // Sliders with ticks can be animated without YAHOO.util.Anim slider.animate = true; slider.getRealValue = function() { return Math.round(this.getValue() * scaleFactor); } slider.subscribe("change", function(offsetFromStart) { // This will get called each time the slider changes. // The offsetFromStart value is the pixel offset horizontally of the current slider position. //alert("slider value = " + slider.getValue()); }); slider.subscribe("slideStart", function() { // this will be done when the slider starts //alert("slider start"); }); slider.subscribe("slideEnd", function() { // this will be done when the slider ends }); var thumb = document.getElementById('slider-thumb'); thumbStyle = thumb.style; thumb.addEventListener('touchmove', function(event) { event.preventDefault(); console.info("touch move :"+ event.targetTouches); if (event.targetTouches[0] == thumb) { var oldPos = thumbStyle.left; var changePos = event.targetTouches[0].pageX - oldPos; thumb.setValue(thumb.getValue() + changePos, true, false, false); } }); }); })(); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---