CoderMJLee / MJRefresh

An easy way to use pull-to-refresh.
MIT License
13.8k stars 3.55k forks source link

fixed crash loop infinitive when compare float by using FLT_EPSILON #1581

Closed vancucit closed 1 year ago

vancucit commented 1 year ago

This PR is to improvement fix this crash

https://github.com/CoderMJLee/MJRefresh/issues/1461

Look compare float equal on not correct in some case

https://stackoverflow.com/questions/4732645/iphone-objective-c-comparing-doubles-not-working

This debug log has demonstrated this issue

 if (fabs(self.scrollView.mj_insetT - insetT) > FLT_EPSILON) {
        self.scrollView.mj_insetT = insetT;
    }else{
      if (self.scrollView.mj_insetT != insetT ) {
        NSLog(@"_--------- same value dif epsilon %f  %f ", self.scrollView.mj_insetT, insetT);
      }
    }

2023-04-02 10:09:15.886546+0700 App[58013:10076967] _--------- same value dif epsilon 172.333333 172.333333