From 7b979cb2b9e4abaa354a7ff58c111dd9962b9ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Wed, 14 Jun 2023 20:06:18 +0800 Subject: [PATCH] iOS: fix slider cannot scroll in simulator --- doric-demo/src/SliderStyleDemo.ts | 6 +++--- doric-iOS/Pod/Classes/Shader/DoricSliderNode.m | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doric-demo/src/SliderStyleDemo.ts b/doric-demo/src/SliderStyleDemo.ts index b600be8a..8c25824a 100644 --- a/doric-demo/src/SliderStyleDemo.ts +++ b/doric-demo/src/SliderStyleDemo.ts @@ -34,8 +34,8 @@ class SliderStyleDemo extends Panel { } })) - setTimeout(() => { - pager.slidePage(this.context, 2, false); - }, 200) + // setTimeout(() => { + // pager.slidePage(this.context, 2, false); + // }, 200) } } \ No newline at end of file diff --git a/doric-iOS/Pod/Classes/Shader/DoricSliderNode.m b/doric-iOS/Pod/Classes/Shader/DoricSliderNode.m index 83eb4e9c..abb5830e 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricSliderNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricSliderNode.m @@ -441,7 +441,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView { - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { NSUInteger pageIndex; if ([self.slideStyle isEqualToString:@"gallery"]) { - pageIndex = (NSUInteger) (scrollView.contentOffset.x / self.galleryItemWidth); + pageIndex = (NSUInteger) (scrollView.contentOffset.x / self.galleryItemWidth + 0.5f); scrollView.contentOffset = CGPointMake(pageIndex * self.galleryItemWidth, scrollView.contentOffset.y); } else { pageIndex = (NSUInteger) (scrollView.contentOffset.x / scrollView.width);