JavaScriptã§Eventã¾ããã®ã³ã¼ãããã¹ãããæã®ã¢ã¬
addEventListenerã®ã©ããã¨ããæ¸ããããªãã§ããã
iPhoneãAndroidã§swipe eventçãªãã®ãç¨æããããã«ãDOMContentLoadedå¼ã°ããã¨ãã«bindãã¦ããã¦event delegation使ã£ã¦ã»ãã»ãããã³ã¼ããæ¸ããããªãã§ããã
ã§ãããã¤ãããã¹ãããã³ã¼ããæ¸ããããªãã§ããã
ç´æ¥ç»é¢ãã¿ãã/ã¯ãªãã¯ãã¦åä½ç¢ºèªããã®ããã¡ããå¿ è¦ã ãã©ãã¾ãã¯èªåãã¹ãæ¸ããããªãã§ããã
ã§ãããæã«ã¯ã¾ãããããé¢æ°ãé©å½ã«ç¨æãã¦ãèªå®¶çºé»ããã¨æããã ãã©
function emit(el, event) { var e = document.createEvent("Event"); e.initEvent(event, true, true); el.dispatchEvent(e); }
å½ããåç°ã®ã¯ã©ãã«ã¼ã§ããããããã風ã«ãã¦çæãããã¤ãã³ãã«ã¯ãã¦ã¼ã¶ã®ã¢ã¯ã·ã§ã³ã«ãã£ã¦çã¾ããã¢ããã³ã®ã¤ãã³ãã«ã¯åãã£ã¦ããã¯ãã®ç¨®ã
ã®ã¢ããåãã£ã¦ãªãã®ã§ãã
ä¾ãã°ãiOS/Androidã§touchstart / touchmove / touchend ãå¼ã°ããæã®Eventãªãã¸ã§ã¯ãã«ã¯ãæ¬æ¥ e.touches ã£ã¦ããååã§ã¿ããããå ´æã®åº§æ¨ã¨ããæã£ããªãã¸ã§ã¯ãã®Arrayããã£ã¤ãã¦ãã¦ãe.touches[0].pageX ã§ä¸æ¬ãã®æã®ã¿ããããå ´æã®X座æ¨ãe.touches[1].pageXã§äºæ¬ãã®æã®ãããã¨ãåããããã ãã©ãã
document.createEventã§èªå®¶çºé»ãããªã¬ãªã¬Eventã«ã¯ããããããã®ã¯ãã£ã¤ãã¦ããªãããã§ããï¼ããããã¦ã¼ã¶ãã©ãããã¿ããããããã§ããªãã®ã§ãã¿ããããå ´æã®åº§æ¨ã¨ããªãã®ãå½ããåï¼ãªã®ã§ããããããã®ãå¿ è¦ãªãã¹ããæ¸ãå ´å㯠e.touches = [ ... ]; ã¨ããã¦ãã£ã¤ãã¦ãããå¿ è¦ãããã¾ãã
åã¯10åã»ã©ããã§ãããã¾ããã
ã¢ãã§ããã