這里的if (el instanceof SVGElement)用意應該是一個能力檢測,但是我發現傳入的元素el,他的原型鏈上是否有SVGElement和它是否具有getBoundingClientRect好像并沒有什么關系吧?即使一個元素的原型鏈上沒有SVGElement,它還是有getBoundingClientRect方法的,那這里的寫法到底是什么意思呢? me.getRect = function(el) { if (el instanceof SVGElement) { var rect = el.getBoundingClientRect(); return { top : rect.top, left : rect.left, width : rect.width, height : rect.height }; } else { return { top : el.offsetTop, left : el.offsetLeft, width : el.offsetWidth, height : el.offsetHeight }; } };感謝!CRIMX有理有據,令人信服!
關于iscroll的一段代碼,希望有人解釋
泛舟湖上清波郎朗
2018-11-16 14:15:27