How to optimize website for touch devices

It sounds to me like you want to have a touch-screen-friendly option, to cover the following scenarios: iPhone-like devices: small screen, touch only Small screens, no touch (you didn’t mention this one) Large screens, no touch (i.e. conventional computers) Touch-screen-enabled large screens such as iPad, notebooks/pcs with touch screens. For case 1 and 2 you … Read more

Detect touch press vs long press vs movement?

This code can distinguish between click and movement (drag, scroll). In onTouchEvent set a flag isOnClick, and initial X, Y coordinates on ACTION_DOWN. Clear the flag on ACTION_MOVE (minding that unintentional movement is often detected which can be solved with a THRESHOLD const). private float mDownX; private float mDownY; private final float SCROLL_THRESHOLD = 10; … Read more

Variation of e.touches, e.targetTouches and e.changedTouches

We have the following lists: touches: A list of information for every finger currently touching the screen targetTouches: Like touches, but is filtered to only the information for finger touches that started out within the same node changedTouches: A list of information for every finger involved in the event To better understand what might be … Read more

Android How to draw a smooth line following your finger

An easy solution, as you mentioned, is to simply connect the points with a straight line. Here’s the code to do so: public void onDraw(Canvas canvas) { Path path = new Path(); boolean first = true; for(Point point : points){ if(first){ first = false; path.moveTo(point.x, point.y); } else{ path.lineTo(point.x, point.y); } } canvas.drawPath(path, paint); } … Read more

Understanding touch events

If you haven’t already, I would suggest reading the source code for Hammer.js https://github.com/hammerjs/hammer.js/blob/master/hammer.js Between comments and code it’s about 1400 lines, there is great documentation and the code is easy to understand. You can see how the author has chosen to solve a lot of the common touch events: hold, tap, doubletap, drag, dragstart, … Read more

Basic Drag and Drop in iOS

Assume you have a UIView scene with a background image and many vehicles, you may define each new vehicle as a UIButton (UIImageView will probably work too): UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button addTarget:self action:@selector(imageTouch:withEvent:) forControlEvents:UIControlEventTouchDown]; [button addTarget:self action:@selector(imageMoved:withEvent:) forControlEvents:UIControlEventTouchDragInside]; [button setImage:[UIImage imageNamed:@”vehicle.png”] forState:UIControlStateNormal]; [self.view addSubview:button]; Then you may move the vehicle wherever you want, … Read more

Eliminate 300ms delay on click events in mobile Safari

Now some mobile browsers eliminate 300 ms click delay if you set the viewport. You don’t need to use workarounds anymore. <meta name=”viewport” content=”width=device-width, user-scalable=no”> This is currently supported Chrome for Android, Firefox for Android and Safari for iOS However on iOS Safari, double-tap is a scroll gesture on unzoomable pages. For that reason they … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)