Passa al contingut principal

Intercepting mouse events on an iPad

In the last post we saw how we could easily work with mouse events on an iPad. Touchscreen devices like the iPad do not have a cursor, so the user cannot exactly move the mouse over an HTML element triggering a ‘mouseover’ event. One of the readers requested on how we could use a different interaction pattern on an iPad for a ‘mouseover’ event than on a desktop browser. For example in the following web page code the image-container class is attached to images div which displays a preview link overlay on mouseover.









$('.image-container').live('mouseover', function(){
$(this).children('div').attr('class', 'image-info-active');
});


ipad-mouseover


Obviously this will not work exactly on an iPad like it would on a desktop browser. The overlay will be displayed on a single tap, but will not disappear till we tap another clickable element. One different interaction pattern for the above example is to trigger the overlay on a touchstart event and remove the overlay after some delay. The first step however is to detect if the site is being viewed on an iPad using the browser user-agent string.









var isiPad = navigator.userAgent.match(/iPad/i) != null;


Later we can run the appropriate code depending the viewing device.









if(isiPad)
{
$('.image-container').live('touchstart', function(){
$(this).children('div').delay(100).fadeIn();
$(this).children('div').attr('class', 'image-info-active');
$(this).children('div').delay(2000).fadeOut();
});
}
else
{
$('.image-container').live('mouseover', function(){
$(this).children('div').attr('class', 'image-info-active');
});
}


Now on an iPad the above code will ‘fadeIn’ the preview overlay once the image is touched and then ‘fadeOut’ after a delay. Of course you could try some different interaction pattern to make better use of the touch capabilities of a tablet.







via code-diesel http://www.codediesel.com/javascript/intercepting-mouse-events-on-an-ipad/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Code-diesel+%28code-diesel%29

Comentaris

Entrades populars d'aquest blog

10 alternativas a Cuevana para ver películas online

10 alternativas a Cuevana para ver películas online : Durante este último tiempo, en Cuevana se sucedieron varios “problemas” por los cuales hubo que ajustar algunas cosas antes de tiempo (como el rediseño del sitio), que dejaron a algunos usuarios ciertos problemas para acceder a las películas o series del portal. Pero realmente esto es algo que no incumbe a los usuarios y, como sabemos, existen muchas otras alternativas a Cuevana dando vueltas por Internet, que intentaremos presentar aquí mismo. Los sitios que repasaremos funcionan del mismo modo que Cuevana, mediante la instalación de un plugin que permite visualizar los videos de Megaupload o WUShare, entre otros servicios, en una calidad de imágen realmente excelente. Tal como sucede con el más popular servicio, todos ellos tienen publicidad que en algunos casos resulta insoportable, pero como dice Federico en DotPod “a caballo regalado no se le miran los dientes”. Alternativas a Cuevana 1. Moviezet Posiblemente el mejor clon d

Sitio alternativo a Cuevana: Moviezet

Sitio alternativo a Cuevana: Moviezet : Nadie se quiere enfrentar al monstruo Cuevana , tan popular por estos días que es casi imposible ver tu serie favorita o tu película sin tener problema de saturación de tráfico. Pero hay proyectos muy sanos y prometedores, sobre todo porque están basados como una muy buena alternativa . Señores estamos hablando obviamente de un sitio alternativo a Cuevana, llamado Moviezet. Como bien dijimos, Moviezet es una excelente alternativa a Cuevana, ya que podremos ver películas y series de forma gratuita sin necesidad de que existan cortes – al mejor estilo Megavideo – y que podremos tener un seguimiento, es decir, si miramos una serie, podremos ver toda la lista con los capítulos disponibles. Lo que tiene de novedoso este sitio web Moviezet , es que tiene películas y series que quizá en Cuevana no se puedan conseguir, pero atención, que puede suceder lo mismo, pero al revés. Entonces aquí intervenimos nosotros y te daremos un sabio consejo, para no

Learn Composition from the Photography of Henri Cartier-Bresson

“Do you see it?” This question is a photographic mantra. Myron Barnstone , my mentor, repeats this question every day with the hopes that we do “see it.” This obvious question reminds me that even though I have seen Cartier-Bresson’s prints and read his books, there are major parts of his work which remain hidden from public view. Beneath the surface of perfectly timed snap shots is a design sensibility that is rarely challenged by contemporary photographers. Henri Cartier-Bresson. © Martine Franck Words To Know 1:1.5 Ratio: The 35mm negative measures 36mm x 24mm. Mathematically it can be reduced to a 3:2 ratio. Reduced even further it will be referred to as the 1:1.5 Ratio or the 1.5 Rectangle. Eyes: The frame of an image is created by two vertical lines and two horizontal lines. The intersection of these lines is called an eye. The four corners of a negative can be called the “eyes.” This is extremely important because the diagonals connecting these lines will form the breakdown