touch-event

Detect if element has stopped momentum scrolling?

谁都会走 提交于 2019-12-01 03:55:09
Is it possibile to detect if an element has stopped scrolling in Mobile Safari via Javascript? I have an element that has momentum scrolling by using -webkit-overflow-scrolling:touch , and I need to detect if the element has stopped scrolling, including after the momentum affects the scroll. Is this possible? Using the onscroll event is not working as it should within my app. dagge You can calculate a swipe velocity and try to figure out if momentum scroll will occur based on some threshold value. I've done some testing and about 0.25 pixels/ms seems to be a good value. Note: Sometimes

Android: handling clicks on image view inside recycler's view item using touch framework

a 夏天 提交于 2019-12-01 02:09:45
I am trying to capture the clicks on ImageView which is enclosed inside the RecyclerView item. I have implemented RecyclerView.OnItemTouchListener and has gesture detector process the motion events for normal clicks and long press on RecyclerView item. Since I want to have the same touch framework to process touch event on child views inside the RecylcerView item, I have set View.OnTouchListener with the image view as well, overriding the onTouch implementation returning true hoping that the touch shall be consumed by the ImageView when it gets clicked. I am intentionally returning false in

How to open a new Intent inside OnTouch Event?

丶灬走出姿态 提交于 2019-12-01 01:49:00
I have a customized OnTouch Method where i check if the touch coordinates contains a rectangle.After checking the condition i want to start a new Activity.But unfortuanlely its not workin.Can someone help me out? public class custom extends SurfaceView implements SurfaceHolder.Callback{ public boolean onTouchEvent(MotionEvent event) { int touchX = (int) event.getX(); int touchY = (int) event.getY(); switch(event.getAction()){ case MotionEvent.ACTION_DOWN: System.out.println("Touching down!"); for(int i =0; i< rectangles.size();i++){ if(rectangles.get(i).contains(touchX,touchY)){ System.out

Detect if element has stopped momentum scrolling?

久未见 提交于 2019-12-01 00:45:20
问题 Is it possibile to detect if an element has stopped scrolling in Mobile Safari via Javascript? I have an element that has momentum scrolling by using -webkit-overflow-scrolling:touch , and I need to detect if the element has stopped scrolling, including after the momentum affects the scroll. Is this possible? Using the onscroll event is not working as it should within my app. 回答1: You can calculate a swipe velocity and try to figure out if momentum scroll will occur based on some threshold

DrawerLayout prevents call of MainActivity.onTouchEvent()

可紊 提交于 2019-11-30 23:34:50
I have an app that overrides the onTouchEvent(MotionEvent ev) of the MainActivity to determine Two-Finger-Swipe and Pich-Open / Pinch-Close . Everything works fine until I add the DrawerLayout to the app (like it's described in Creating a Navigation Drawer ). Problem: the DrawerLayout prevents the call of onTouchEvent() in the MainActivity. I started to write a CustomDrawerLayout , and try to override the DrawerLayout methods onInterceptTouch() and onTouchEvent() . The only way (I found) to transmit the TouchEvent to the MainActivity: // onTouchEvent of CustomDrawerLayout @Override public

Javascript touch event: distinguishing finger vs. Apple Pencil

做~自己de王妃 提交于 2019-11-30 19:44:17
In Mobile Safari, is there any way to distinguish whether a touch event is generated by finger or Apple Pencil? The TouchList object of a touch event contains detailed information about the touch’s individual points. Among the many properties touchType is probably the most interesting for you as it contains either stylus (Apple Pencil) or direct (finger). var body = document.getElementByTagName('body'); body.addEventListener('touchstart', function(evt){ // should be either "stylus" or "direct" console.log(evt.touches[0].touchType); }); You should also have a look at the other properties of

Object to process touch event but also let it through

泪湿孤枕 提交于 2019-11-30 16:29:10
I want to create an object that will work like MultiPointTouchArea (so it will have touchUpdated signal) but also it would not steal touches, so that objects placed beneath it will receive the touch events as well. The solution may require creating C++ object. Is there a simple way to create such object? Is it possible to process (touch) events without "stealing" them? Any hint will be appreciated. Here is an example of what I am trying to do. I want to touch top Rectangle but at the same time I want both MultiPointTouchArea s process touches: import QtQuick 2.3 import QtQuick.Window 2.2

Can't get coordinates of touchevents in Javascript on Android devices

本小妞迷上赌 提交于 2019-11-30 11:50:00
问题 I'm testing the HTML5 canvas and using Javascript to draw for touch enabled devices. While I have it working in iOS devices I cannot get it to work on Android. I have narrowed it down to event.pageX not returning the coordinates, but instead either returning 0, or undefined (based on the Browser). I've tested it on my phone running Cyanogen 7.1 in Opera Mobile and Dolphin browser, and also on a Galaxy Tab 10.1 (Android 3.1) running the standard browser. I've modified the code to show an alert

What's the proper way of binding touchstart on React JS?

前提是你 提交于 2019-11-30 11:42:11
I am learning React JS and as of now I cannot find any example on the source code, tests or on the official docs. On the docs the touchStart event is said to be supported but handleTouchStart does not work. The only place I found and example that actually works was on react-touch project. The following code works, but is this the only way of binding? It looks like a cheap workaround for me. var MyHeader = React.createClass({ handleTouchStart: function() { console.log('handleTouchStart'); }, render: function() { return this.transferPropsTo( <header onTouchStart={this.handleTouchStart}>{title}<

ImageView Drag Limitation In Android

二次信任 提交于 2019-11-30 09:46:37
I have an ImageView in a layout and set OnTouchListener on ImageView to drag the ImageView. It's working perfectly. My problem is how can I prevent from move ImageView to out of layout range? This is my code: Activity class: public class RepositionTestActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.reposition_test_layout); ImageView imageView = (ImageView)findViewById(R.id.android); imageView.setOnTouchListener(new Touch()); } } Touch class: public class Touch implements OnTouchListener {