angular.jsã®è©±ã§ã™ã€‚çªç„¶ã§ã™ãŒã€ng-clickã¨ã„ã†ã®ã¯ã‚¯ãƒªãƒƒã‚¯ãŒå®Œäº†ã—ãŸã¨ãã«å®Ÿè¡Œã•れã€ng-mousedownã¨ã„ã†ã®ã¯æŠ¼ã—ãŸã ã‘ã§å®Ÿè¡Œã•れã¾ã™ã€‚ã—ã‹ã—ã€ng-mousedownã¯ã‚¿ãƒƒãƒãƒ‘ãƒãƒ«ã§ã¯ç™ºç«ã—ã¾ã›ã‚“。mousedownイベントã¯ãƒžã‚¦ã‚¹ã ã‘ã§ã‚りã€ã‚¿ãƒ–レットやスマートフォンã®ãƒ–ラウザã§ã¯touchstartイベントãŒã‚りã¾ã™ã€‚ãªã®ã§ã€ã¦ã£ãりng-touchstartã¨ã„ã†ã®ãŒç”¨æ„ã•れã¦ã„ã‚‹ã‚‚ã®ã¨æ€ã£ã¦ã„ã¾ã—ãŸã€‚
ãŒã€ãれã¯å‹˜é•ã„ã§ã—ãŸã€‚å°‘ãªãã¨ã‚‚ç¾æ™‚点ã§ã¯ã€‚ ng-clickより細ã‹ã„制御をã—ãŸã‹ã£ãŸã®ã§ã€ng-touchstartã¯ã©ã†ã—ã¦ã‚‚欲ã—ã„ã§ã™ã€‚
ã¨ã“ã‚ã§ã€angular.jsã®directiveã¯ã¨ã¦ã‚‚å”力ã§ã™ãŒã€ã‚¢ãƒ—リケーション実装ã™ã‚‹ã¨ãã«directive開発ã™ã‚‹ã®ã¯ç„¡é§„ã ã¨æ€ã£ã¦ã„ã¾ã™ã€‚標準ã§ç”¨æ„ã•れãŸdirectiveã¨controllerã§æ¸ˆã‚€ã“ã¨ãŒå¤šã„ã§ã™ã€‚directiveã¯å†åˆ©ç”¨æ€§ãŒé«˜ã„ã‚‚ã®ã‚’開発ã™ã‚‹ã¨ãã«ä½¿ã†ã‚‚ã®ã§ã—ょã†ã€‚アプリã§ã¯ãªãライブラリ開発ã™ã‚‹ã¨ãã§ã™ã。
ã¨ã“ã‚ãŒã€ã‚¢ãƒ—リ開発ã—ã¦ã„ã‚‹ã¨ãã«ã©ã†ã—ã¦ã‚‚ng-touchstartãŒæ¬²ã—ããªã£ã¦ã—ã¾ã£ãŸã®ã§ã€directive書ã„ã¦ã¿ã¾ã—ãŸã€‚今ã¾ã§é£Ÿã‚ãšå«Œã„ã§ã—ãŸãŒã€ç°¡å˜ãªdirectiveãªã‚‰æ›¸ã„ã¦ã¿ã‚‹ã¨ã™ã£ãりã™ã‚‹ã“ã¨ã‚‚ã‚ã‚‹ãªã€ã¨ã¡ã‚‡ã£ã¨è€ƒãˆç›´ã—ã¾ã—ãŸã€‚
ã¨ã„ã†ã‚ã‘ã§ã€é–‹ç™ºã—ãŸdirectiveを貼り付ã‘ã¦ãŠãã¾ã™ã€‚
angular.module('MyModule').directive('myTouchstart', ['$parse', '$swipe',
function($parse, $swipe) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var handler = $parse(attrs.myTouchstart);
$swipe.bind(element, {
start: function() {
scope.$apply(function() {
handler(scope);
});
}
});
}
};
}
]);
ã“れã ã¨ã€touchstartã¨mousedown両方ã«å応ã™ã‚‹ã®ã§ã™ãŒã€ã¡ã‚ƒã‚“ã¨ã‚„ã‚‹ãªã‚‰ãã®ã‚ãŸã‚Šã‚‚制御ã—ãŸæ–¹ãŒã„ã„ã§ã™ã。ã‚ã¨ã€touchstartã ã‘ã§ãªãã€touchmoveã¨touchendã‚‚ã‚ã£ãŸã»ã†ãŒã„ã„ã§ã—ょã†ã€‚ãã“ã¾ã§ã‚„ã£ãŸã‚‰ã€pullreqã§ããã†ã§ã™ã€‚ã¨ã„ã†ã‹ã€ã‚‚ã†èª°ã‹ãŒã‚„ã£ã¦ã„ã‚‹ã®ã§ã¯ãªã„ã§ã—ょã†ã‹ã€‚
ã“れãŒä¸€ç•ªè¿‘ãã†ã§ã™ã€‚
https://github.com/angular/angular.js/issues/5334
ã¾ã 解決ã—ã¦ã„ãªã„模様。確ã‹ã«ã€ng-mousedownã‚’overrideã—ã¦ã‚‚ã„ã„ã‹ã‚‚ã—れã¾ã›ã‚“。åå‰ãŒç›´æ„Ÿçš„ã§ã¯ãªã„ã§ã™ãŒã€‚