react-native-jet-markdown 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/JetMarkdownView.mm +33 -2
- package/package.json +1 -1
package/ios/JetMarkdownView.mm
CHANGED
|
@@ -34,6 +34,7 @@ using namespace facebook::react;
|
|
|
34
34
|
|
|
35
35
|
static void JMDSetNeedsDisplayDeep(UIView *view);
|
|
36
36
|
static CGRect JMDScreenFrameOfView(UIView *view);
|
|
37
|
+
static BOOL JMDIsScrollInProgress(UIView *view);
|
|
37
38
|
|
|
38
39
|
@implementation JetMarkdownView {
|
|
39
40
|
NSString *_markdown;
|
|
@@ -166,10 +167,17 @@ static CGRect JMDScreenFrameOfView(UIView *view);
|
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
// Touches that do not start on an interactive range are never tracked, so
|
|
169
|
-
// they cannot interfere with an ancestor scroll view's pan.
|
|
170
|
+
// they cannot interfere with an ancestor scroll view's pan. A touch that
|
|
171
|
+
// lands mid-scroll is a scroll-stopper, not a press (Pressable semantics) —
|
|
172
|
+
// checked from the deepest content view so nested code/table scrollers and
|
|
173
|
+
// the outer list both count.
|
|
170
174
|
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)recognizer
|
|
171
175
|
shouldReceiveTouch:(UITouch *)touch {
|
|
172
|
-
|
|
176
|
+
const CGPoint point = [touch locationInView:self];
|
|
177
|
+
if (![self jmdIsInteractiveAtPoint:point]) {
|
|
178
|
+
return NO;
|
|
179
|
+
}
|
|
180
|
+
return !JMDIsScrollInProgress([self jmdContentViewAtPoint:point inView:self]);
|
|
173
181
|
}
|
|
174
182
|
|
|
175
183
|
// Non-interactive points fall through to ancestors so a wrapping pressable
|
|
@@ -182,9 +190,32 @@ static CGRect JMDScreenFrameOfView(UIView *view);
|
|
|
182
190
|
if (result == self && ![self jmdIsInteractiveAtPoint:point]) {
|
|
183
191
|
return nil;
|
|
184
192
|
}
|
|
193
|
+
// Mid-scroll, an interactive point is not claimed either: hit-testing runs
|
|
194
|
+
// before the touch is delivered, so isDecelerating is still reliable here
|
|
195
|
+
// (by shouldReceiveTouch: time the same touch may have already stopped the
|
|
196
|
+
// scroll). Falling through lets the ancestor scroll view take the touch
|
|
197
|
+
// and stop, exactly like tapping a Pressable during momentum.
|
|
198
|
+
if (result == self && JMDIsScrollInProgress(self)) {
|
|
199
|
+
return nil;
|
|
200
|
+
}
|
|
185
201
|
return result;
|
|
186
202
|
}
|
|
187
203
|
|
|
204
|
+
// YES when any scroll view on the path from `view` up through the window is
|
|
205
|
+
// being dragged or is decelerating — a press landing then must only stop
|
|
206
|
+
// the scroll, never fire.
|
|
207
|
+
static BOOL JMDIsScrollInProgress(UIView *view) {
|
|
208
|
+
for (UIView *ancestor = view; ancestor != nil; ancestor = ancestor.superview) {
|
|
209
|
+
if ([ancestor isKindOfClass:UIScrollView.class]) {
|
|
210
|
+
UIScrollView *scroll = (UIScrollView *)ancestor;
|
|
211
|
+
if (scroll.isDecelerating || scroll.isDragging) {
|
|
212
|
+
return YES;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return NO;
|
|
217
|
+
}
|
|
218
|
+
|
|
188
219
|
// Scrolling always wins: a drag that begins on a link still pans the list
|
|
189
220
|
// (the tap/long-press simply fail on movement).
|
|
190
221
|
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)recognizer
|