(&self, position: Point<Pixels>)
| 293 | let width = self.progress_bounds.size.width; |
| 294 | if width <= px(0.0) { |
| 295 | return None; |
| 296 | } |
| 297 | |
| 298 | let inner_pos = position.x - self.progress_bounds.left(); |
| 299 | let fraction = (inner_pos.clamp(px(0.0), width) / width).clamp(0.0, 1.0); |
| 300 | Some(total_duration.mul_f32(fraction)) |
| 301 | } |
| 302 | |
| 303 | fn clamp_to_duration(&self, position: Duration) -> Duration { |
| 304 | if let Some(total_duration) = self.total_duration { |
| 305 | position.min(total_duration) |
| 306 | } else { |
| 307 | position |
| 308 | } |