Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加嗅探css3属性方法&获取鼠标滚动值&fix销毁component时清理工作 #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,10 @@ define(function (require) {
* @method dispose
*/
dispose: function () {
var body = document.getElementsByTagName('body')[0];
this.data = null;
this.content = '';
body.remove(this.el);
this.destroyEvents();
}
};
Expand Down
31 changes: 31 additions & 0 deletions src/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,36 @@ define(function (require) {
}
};

/**
* 是否支持CSS3特定属性
* @param {string} property 待检测的属性
* @return {boolean}
*/
util.isSupportCSS3 = function (property) {
// 目前兼容这些就可以了吧
var properties = [property, '-webkit-' + property, '-ms-' + property, '-moz-' + property, '-o-' + property];
var style = document.createElement('body').style;
for (var i = 0, l = properties.length; i < l; i++) {
if (style.hasOwnProperty(properties[i])) {
return true;
}
}
return false;
};

/**
* 获取鼠标滚动时的值
* @param {Event} event 鼠标滚动时事件对象
* @return {number} 1:向上 -1:向下
*/
util.getMouseScrollVal = function (event) {
event = event || window.event;
var val = event.originalEvent.wheelDelta
? (event.originalEvent.wheelDelta > 0 ? 1 : -1)
: (-event.originalEvent.detail > 0 ? 1 : -1);

return val;
};

return util;
});