Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Enable Javascript for Android?
- Date: Mon, 05 Oct 2009 16:27:36 +0900
- From: Dave M G <dave@example.com>
- Subject: Re: [tlug] Enable Javascript for Android?
- References: <4AB2455F.9000509@example.com> <184110a70909172155h65beefb8oa5a158b863bbaf90@example.com> <4AB321CD.4080905@example.com> <70CD4388-E0F0-40FF-9B6F-268DE268270F@example.com> <4AB343CB.6030409@example.com> <2000d7bd0909191716y5d3c82cr6f16219126f8af59@example.com> <2000d7bd0909192154w2d28a3dcuaf65990d9177d1d3@example.com> <4AB5BC53.9020506@example.com> <35F83D52-1C49-41F7-9F86-75F54AEA1C03@example.com>
- User-agent: Thunderbird 2.0.0.23 (X11/20090817)
TLUG, In trying to get my web page with modified YUI sliders to work on Android, I have learned that I need to get my sliders to respond to "touch" events. Specifically, I need to utilize the "touchmove" event, which is when a user drags their finger across the screen. I have attempted to modify the YUI slider code as follows. Can any JavaScript experts tell me what might be going wrong? Also, please be gentle with the code critiques, as 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. Thank you for any advice! Here's the code (which relies on having the YUI libraries available in order to work): (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 }); // This is where I added in code to try and identify the slider // thumb and get it to respond to a touchmove event. // Right now, this code causes the slider to freeze entirely, // even on my home desktop browser. 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); } }); }); })();
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Firewall options
- Next by Date: Re: [tlug] Ubuntu installer
- Previous by thread: Re: [tlug] Firewall options
- Next by thread: [tlug] List of Japanese Open Source Projects?
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links