diff --git a/Pod/Classes/Shader/DoricSliderNode.m b/Pod/Classes/Shader/DoricSliderNode.m index 32e8b96f..23038297 100644 --- a/Pod/Classes/Shader/DoricSliderNode.m +++ b/Pod/Classes/Shader/DoricSliderNode.m @@ -36,6 +36,7 @@ @interface DoricSliderNode () 0) { - [self callJSResponse:self.onPageSelectedFuncId, @(pageIndex), nil]; + if (pageIndex != self.lastPosition) { + [self callJSResponse:self.onPageSelectedFuncId, @(pageIndex), nil]; + } else { + self.lastPosition = pageIndex; + } } } - (void)slidePage:(NSDictionary *)params withPromise:(DoricPromise *)promise { NSUInteger pageIndex = [params[@"page"] unsignedIntegerValue]; BOOL smooth = [params[@"smooth"] boolValue]; - if (smooth) { - [UIView animateWithDuration:.3f animations:^{ - self.view.contentOffset = CGPointMake(pageIndex * self.view.width, self.view.contentOffset.y); - } - completion:^(BOOL finished) { - [promise resolve:nil]; - }]; - } else { - self.view.contentOffset = CGPointMake(pageIndex * self.view.width, self.view.contentOffset.y); + [self.view setContentOffset:CGPointMake(pageIndex * self.view.width, self.view.contentOffset.y) animated:smooth]; + [promise resolve:nil]; + self.lastPosition = pageIndex; + if (self.onPageSelectedFuncId && self.onPageSelectedFuncId.length > 0) { + [self callJSResponse:self.onPageSelectedFuncId, @(pageIndex), nil]; } }