Skip to content

Commit

Permalink
update SJScrollingTextMarqueeView
Browse files Browse the repository at this point in the history
  • Loading branch information
changsanjiang committed Apr 10, 2021
1 parent 453abf1 commit c5d4889
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, readonly, getter=isScrolling) BOOL scrolling;
@property (nonatomic, getter=isScrollEnabled) BOOL scrollEnabled;
@property (nonatomic, getter=isCentered) BOOL centered;
@end
NS_ASSUME_NONNULL_END
8 changes: 8 additions & 0 deletions SJVideoPlayer/Common/Implements/SJScrollingTextMarqueeView.m
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ - (void)_reset {
- (void)_prepareForAnimation {
[self _setRightFadeMask];

if ( _centered ) {
_leftLabel.sj_x = 0;
}

_rightLabel.hidden = NO;
_rightLabel.attributedText = _leftLabel.attributedText;
_rightLabel.sj_x = _leftLabel.sj_w + _margin;
Expand All @@ -163,6 +167,10 @@ - (void)_prepareForNormalState {
[self _removeFadeMasks];

_rightLabel.hidden = YES;

if ( _centered ) {
_leftLabel.sj_x = self.sj_w * 0.5 - _leftLabel.sj_w * 0.5;
}
}

- (void)_startAnimationIfNeededAfterDelay:(NSTimeInterval)seconds {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, readonly, getter=isScrolling) BOOL scrolling;
@property (nonatomic, getter=isScrollEnabled) BOOL scrollEnabled; ///< default value is YES
@property (nonatomic, getter=isCentered) BOOL centered; ///< default value is NO. 标题太短无法滚动时, 是否居中显示
@end
NS_ASSUME_NONNULL_END

Expand Down
22 changes: 18 additions & 4 deletions SJVideoPlayer/Common/Utils/SJProgressSlider/SJProgressSlider.m
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ - (void)setValue:(CGFloat)value_new animated:(BOOL)animated {
CGFloat value_old = _value;
if ( value_new < _minValue ) value_new = _minValue;
else if ( value_new > _maxValue ) value_new = _maxValue;
if ( _showsStopNode ) {
CGFloat stop = _stopNodeLocation * _maxValue;
if ( value_new > stop ) value_new = stop;
}
// if ( _showsStopNode ) {
// CGFloat stop = _stopNodeLocation * _maxValue;
// if ( value_new > stop ) value_new = stop;
// }
_value = value_new;

if ( animated ) {
Expand All @@ -212,6 +212,20 @@ - (void)setValue:(CGFloat)value_new animated:(BOOL)animated {
}
}

- (void)setMinValue:(CGFloat)minValue {
if ( minValue != _minValue ) {
_minValue = minValue;
[self _needUpdateContainerLayout];
}
}

- (void)setMaxValue:(CGFloat)maxValue {
if ( maxValue != _maxValue ) {
_maxValue = maxValue;
[self _needUpdateContainerLayout];
}
}

/// add 此次增加的值
- (CGFloat)_calculateAnimaDuration:(CGFloat)add {
add = ABS(add);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ - (void)videoPlayerPlaybackStatusDidChange:(__kindof SJBaseVideoPlayer *)videoPl
[self _showOrHiddenLoadingView];
[self _updateContentForBottomCurrentTimeItemIfNeeded];
[self _updateContentForBottomDurationItemIfNeeded];
[self _updateContentForBottomProgressIndicatorIfNeeded];
}

- (void)videoPlayer:(__kindof SJBaseVideoPlayer *)videoPlayer pictureInPictureStatusDidChange:(SJPictureInPictureStatus)status API_AVAILABLE(ios(14.0)) {
Expand Down

0 comments on commit c5d4889

Please sign in to comment.