在項目中遇到一個問題,就是點擊任意鍵關閉彈窗的處理;出現了一個bug;就是在angularjs項目中兩個controller之間的事件跳轉,使用的ng-show =“iscontext” ;
如所示;
<p onmousedown="mouseDown()">請點擊此文本!</p>
定義和用法
onmousedown 屬性在鼠標按鈕在元素上按下時觸發。
提示:相對於 onmousedown 事件的事件次序(限於鼠標左/中鍵):
onmousedown onmouseup onclick相對於 onmousedown 事件的事件次序(限於鼠標右鍵):
onmousedown onmouseup oncontextmenu注釋:onmousedown 屬性不適用以下元素:<base>、<bdo>、<br>、<head>、<html>、<iframe>、<meta>、<param>、<script>、<style> 或 <title>。
document.onmousedown = function() { $scope.isShowDisQuit = false; $scope.isShowJoinGroup = false; };
//點擊任意出關閉表情框 $(document).off('click').on('click', function(e) { if($(e.target).closest('.clickHeadTo').length || $(e.target).closest('.content-right-empty').length){ return; } if(!$(e.target).closest('.not-hide-floater').length){ $('.em-floater').hide(); } $scope.isShowGroupMember = false; $scope.isShowMember = true; $scope.isHideMember = false; if($scope.deptCount > 1){ $scope.countVisible = true; } $scope.visible = false; $scope.$apply(); $('[recentUserId=' + localStorage.getItem('recentUserId') + ']').addClass('on'); });
//點擊任意出關閉右鍵彈窗 $(document).off('click').on('click', function(e) { $scope.iscontextMenus = false; if (!$scope.$$phase) { $scope.$apply(); } })
//群會話消息滾動事件觸發關閉右鍵彈層 groupTarget.onscroll = function (){ isContextMenusHide(); } //鼠標抬起時關閉右鍵彈層 document.onmouseup = function() { isContextMenusHide(); }; function isContextMenusHide (){ $scope.iscontextMenus = false; if (!$scope.$$phase) { $scope.$apply(); } }