function isScrollToBottom(e, fn) { // e.srcElement存在兼容性问题,并非标准特性 // https://developer.mozilla.org/zh-CN/docs/Web/API/Event/target // 支持 IE6-8 var target_ = e.target || e.srcElement, // 距离顶部高度 scrollTop = target_.scrollTop, // 滚动区域高度 scrollHeight = target_.scrollHeight, // 文档元素高度 clientHeight = target_.clientHeight; // 文档坐标和视口坐标转换,判断元素滚动到了底部 if(scrollTop + clientHeight == scrollHeight) { if(fn) { fn.call(); } } }
将源对象合并到目标对象中去
* src: 源对象 * to: 目标对象 * return 目标对象 * a = {"a": "a"} * b = {"b": "b"} * extend_(b, a) → {a: "a", b: "b"} */ function extend_(srcObj, toObj) { for(var key in srcObj) { toObj[key] = toObj[key]; } return toObj; }
判断是否为字符串
function isString_(o) {
return Object.prototype.toString.call(o) === "[object String]";
}