Skip to content

Commit

Permalink
0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
xjArea committed Oct 15, 2021
1 parent 89b1ca7 commit d15fe1e
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 572 deletions.
11 changes: 10 additions & 1 deletion dist/xj.focus.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** xj.focus(区分聚焦模式) | V0.3.1 | Apache Licence 2.0 | 2018-2021 © XJ.Chen | https://github.com/xjZone/xj.focus */
/** xj.focus(区分聚焦模式) | V0.3.2 | Apache Licence 2.0 | 2018-2021 © XJ.Chen | https://github.com/xjZone/xj.focus */

/* 在 tap 模式下,取消所有的聚焦 outline 外边框,在 tab 模式下,取消所有聚焦 outline 并且使用 */
/* box-shadow 制造外边框,因为和 outline 一样不占位置但又能实现圆角,虽然在 Safari 中可能无效 */
Expand All @@ -10,4 +10,13 @@
.xj-focus-outline.xj-focus-ontap:focus{outline:0;}
.xj-focus-outline.xj-focus-ontab:focus{outline:2px solid rgba(51,153,255,0.75);outline-offset:0;}

/* 由于 audio 标签和 video 标签无法捕捉到鼠标和键盘事件,所以无法判断出聚焦是由哪种行为导致的 */
/* 插件只好将这两个标签的所有聚焦行为都判断为是鼠标点击导致的,所以聚焦的时候不会显示出外边框 */
/* 这里用 CSS4 的 :focus-visible 伪类选择器做补充,Firefox85+ 和 Chrome86+ 开始支持这个选择器 */
/* 支持这个选择器的时候使用键盘聚焦还是能显示出外边框的,但是使用鼠标点击的时候就不显示外边框 */
audio.xj-focus-shadow:focus:focus-visible,
video.xj-focus-shadow:focus:focus-visible{outline:0;box-shadow:0 0 0 2px rgba(51,153,255,0.75);}
audio.xj-focus-outline:focus:focus-visible,
video.xj-focus-outline:focus:focus-visible{outline:2px solid rgba(51,153,255,0.75);outline-offset:0;}


8 changes: 4 additions & 4 deletions dist/xj.focus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** xj.focus(区分聚焦模式) | V0.3.1 | Apache Licence 2.0 | 2018-2021 © XJ.Chen | https://github.com/xjZone/xj.focus */
/** xj.focus(区分聚焦模式) | V0.3.2 | Apache Licence 2.0 | 2018-2021 © XJ.Chen | https://github.com/xjZone/xj.focus */
;(function(global, factory){
if(typeof(define) === 'function' && (define.amd !== undefined || define.cmd !== undefined)){ define(factory) }
else if(typeof(module) !== 'undefined' && typeof(exports) === 'object'){ module.exports = factory() }
Expand All @@ -22,7 +22,7 @@ var pub_hasClass,pub_addClass,pub_delClass;!function(){pub_hasClass=function(a,b
var pub_global = (typeof(globalThis) !== 'undefined' ? globalThis : typeof(window) !== 'undefined' ? window : typeof(self) !== 'undefined' ? self : global);

// public nothing, version, keyword
var pub_nothing = function(){}, pub_version = '0.3.1', pub_keyword = 'focus';
var pub_nothing = function(){}, pub_version = '0.3.2', pub_keyword = 'focus';

// public config, advance set
var pub_config = {
Expand Down Expand Up @@ -184,7 +184,8 @@ var pub_sameTarget = function(focusTarget){ // 判断 tap 和 focus 是否同
var result = false;
var element = pub_ontapNode;

while(result === false && element !== null && element.nodeType === 1){
while(result === false && element !== null
&& element !== undefined && element.nodeType === 1){
if( /^label$/i.test( element.nodeName ) === true
|| element === focusTarget){ result = true }
else{ element = element.parentElement };
Expand Down Expand Up @@ -521,7 +522,6 @@ pub_win.addEventListener('blur', function(event){
pub_return.other = false;
pub_return.ontab = false;
pub_return.ontap = false;

if(pub_config.debug === true){ return };

pub_frameNodes = pub_doc.querySelectorAll('.'+pub_frameClass);
Expand Down
4 changes: 2 additions & 2 deletions dist/xj.focus.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/xj.focus.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d15fe1e

Please sign in to comment.