Skip to content

Commit cfa0832

Browse files
committed
Fix getElementRect for iOS8
Scrolling/panning now changes the properties of the rect returned by Element#getClientRects and Element#getBoundingClientRect.
1 parent b81ba65 commit cfa0832

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

interact.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@
284284
supportsTouch &&
285285
navigator.userAgent.match('Presto'),
286286

287+
// scrolling doesn't change the result of
288+
// getBoundingClientRect/getClientRects on iOS <=7 but it does on iOS 8
289+
isIOS7orLower = (/iP(hone|od|ad)/.test(navigator.platform)
290+
&& /OS [1-7][^\d]/.test(navigator.appVersion)),
291+
287292
// prefix matchesSelector
288293
prefixedMatchesSelector = 'matchesSelector' in Element.prototype?
289294
'matchesSelector': 'webkitMatchesSelector' in Element.prototype?
@@ -646,7 +651,7 @@
646651
}
647652

648653
function getElementRect (element) {
649-
var scroll = /ipad|iphone|ipod/i.test(navigator.userAgent)
654+
var scroll = isIOS7orLower
650655
? { x: 0, y: 0 }
651656
: getScrollXY(),
652657
clientRect = (element instanceof SVGElement)?

0 commit comments

Comments
 (0)