Эх сурвалжийг харах

improve the user experience; bug fix: #75 and #78

ibireme 9 жил өмнө
parent
commit
54de3d14a8

+ 1 - 1
YYText/Component/YYTextEffectWindow.m

@@ -296,7 +296,7 @@
     if (mag.type == YYTextMagnifierTypeRanged) {
         mag.alpha = 0;
     }
-    NSTimeInterval time = mag.type == YYTextMagnifierTypeCaret ? 0.06 : 0.1;
+    NSTimeInterval time = mag.type == YYTextMagnifierTypeCaret ? 0.08 : 0.1;
     [UIView animateWithDuration:time delay:0 options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState animations:^{
         if (mag.type == YYTextMagnifierTypeCaret) {
             CGPoint newCenter = CGPointMake(0, -mag.fitSize.height / 2);

+ 4 - 0
YYText/Component/YYTextSelectionView.m

@@ -90,6 +90,8 @@
 - (void)layoutSubviews {
     [super layoutSubviews];
     [self setDotDirection:_dotDirection];
+    CGFloat minWidth = MIN(self.bounds.size.width, self.bounds.size.height);
+    self.layer.cornerRadius = minWidth / 2;
 }
 
 - (CGRect)touchRect {
@@ -243,6 +245,8 @@
 - (void)setCaretRect:(CGRect)caretRect {
     _caretRect = caretRect;
     self.caretView.frame = [self _standardCaretRect:caretRect];
+    CGFloat minWidth = MIN(self.caretView.bounds.size.width, self.caretView.bounds.size.height);
+    self.caretView.layer.cornerRadius = minWidth / 2;
 }
 
 - (void)setSelectionRects:(NSArray *)selectionRects {

+ 2 - 1
YYText/YYTextView.m

@@ -59,7 +59,7 @@ static float _YYDeviceSystemVersion() {
 
 #define kAutoScrollMinimumDuration 0.1 // Time in seconds to tick auto-scroll.
 #define kLongPressMinimumDuration 0.5 // Time in seconds the fingers must be held down for long press gesture.
-#define kLongPressAllowableMovement 9.0 // Maximum movement in points allowed before the long press fails.
+#define kLongPressAllowableMovement 10.0 // Maximum movement in points allowed before the long press fails.
 
 #define kMagnifierRangedTrackFix -6.0 // Magnifier ranged offset fix.
 #define kMagnifierRangedPopoverOffset 4.0 // Magnifier ranged popover offset.
@@ -3263,6 +3263,7 @@ typedef NS_ENUM(NSUInteger, YYTextMoveDirection) {
     
     [_inputDelegate selectionWillChange:self];
     _selectedTextRange = selectedTextRange;
+    _lastTypeRange = _selectedTextRange.asRange;
     [_inputDelegate selectionDidChange:self];
     
     [self _updateOuterProperties];