javascript - Workaround for a premature touchcancel event on Android Browser -
i'm trying modify jquery code website-based dropdown menu. working on workaround premature touchcancel event being fired on android browser build 4.4.2 samsung galaxy s4.
here's code i'm trying work with:
jquery(document).ready(function ($) { 'use strict'; $('.taptap-by-bonfire ul li ul').before($('<span><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 512 512" xml:space="preserve"><polygon id="arrow-24-icon" points="206.422,462 134.559,390.477 268.395,256 134.559,121.521 206.422,50 411.441,256 "/></svg></span>')); $(".menu > li > span, .sub-menu > li > span").on('touchstart click', function(e) { e.preventdefault(); if (false == $(this).next().is(':visible')) { $(this).parent().siblings().find(".sub-menu").slideup(300); $(this).siblings().find(".sub-menu").slideup(300); $(this).parent().siblings().find("span").removeclass("taptap-submenu-active"); } $(this).next().slidetoggle(300); $(this).toggleclass("taptap-submenu-active"); }) $(".menu > li > span").on('touchstart click', function(e) { e.preventdefault(); if($(".sub-menu > li > span").hasclass('taptap-submenu-active')) { $(".sub-menu > li > span").removeclass("taptap-submenu-active"); } }) $(".taptap-menu-button-wrapper").on('touchstart click', function(e) { if($(".menu > li > span, .sub-menu > li > span").hasclass('taptap-submenu-active')) { $(".menu > li").find(".sub-menu").slideup(300); $(".menu > li > span, .sub-menu > li > span").removeclass("taptap-submenu-active"); } }) });
it works on devices , on browsers. on particular android browser, menu drops down , slides again. i'm assuming premature touchcancel event being fired. i've tried various things, can't seem have these elements , not have touchcancel firing on device no matter try.
is there can around issue android browser?
Comments
Post a Comment