From 885c06a01efa1e0be172890ace2b8b4ff381f92d Mon Sep 17 00:00:00 2001 From: wenber Date: Mon, 15 Jun 2015 10:24:00 +0800 Subject: [PATCH 1/2] add toCamelCase --- src/lib/util.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/lib/util.js b/src/lib/util.js index 9772b87..e2722ca 100644 --- a/src/lib/util.js +++ b/src/lib/util.js @@ -136,5 +136,25 @@ define(function (require) { } }; + /** + * 转驼峰写法 + * @param {string} str 待转换的字符串 + * @return {string} 转后的结果 + */ + util.toCamelCase = function (str) { + if (str == null) { + return str; + } + // 移除前后的空格 + str = str.replace(/(^\s*)|(\s*$)/g, ''); + // 处理以-开头的情况 + str = str.charAt(0) === '-' ? str.substring(1) : str; + // 开始转换 + str = str.replace(/-(\w)/g, function ($0, $1) { + return $1.toUpperCase(); + }); + return str; + }; + return util; }); From 450d70b531c6494f0eeeb9849cd200b01b673bdd Mon Sep 17 00:00:00 2001 From: wenber Date: Mon, 13 Jul 2015 19:15:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=97=85=E6=8E=A2css3?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E6=96=B9=E6=B3=95&=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=BC=A0=E6=A0=87=E6=BB=9A=E5=8A=A8=E5=80=BC&fix=E9=94=80?= =?UTF-8?q?=E6=AF=81component=E6=97=B6=E6=B8=85=E7=90=86=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Action.js | 3 +++ src/lib/util.js | 41 ++++++++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/Action.js b/src/Action.js index bf56b1a..ff61a0a 100644 --- a/src/Action.js +++ b/src/Action.js @@ -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(); } }; diff --git a/src/lib/util.js b/src/lib/util.js index e2722ca..5caeba3 100644 --- a/src/lib/util.js +++ b/src/lib/util.js @@ -137,23 +137,34 @@ define(function (require) { }; /** - * 转驼峰写法 - * @param {string} str 待转换的字符串 - * @return {string} 转后的结果 + * 是否支持CSS3特定属性 + * @param {string} property 待检测的属性 + * @return {boolean} */ - util.toCamelCase = function (str) { - if (str == null) { - return str; + 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; + } } - // 移除前后的空格 - str = str.replace(/(^\s*)|(\s*$)/g, ''); - // 处理以-开头的情况 - str = str.charAt(0) === '-' ? str.substring(1) : str; - // 开始转换 - str = str.replace(/-(\w)/g, function ($0, $1) { - return $1.toUpperCase(); - }); - return str; + 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;